The most common way of exchanging your Cryptocurrency for another is to do it through a Crypto exchange. It can be a pain in the butt when registering an account on a Cryptocurrency exchange and the exchanges that you already have an account on, may not have your desired trading pair.
For example, if you had BTC and instead wanted LTC, and then if your particular exchange or any exchange you have accounts with, do not have BTC > LTC pair, you would have to sell your BTC on a crypto exchange. Once it had been listed and sold you will most likely receive fiat in return, which you then use to buy the LTC you wanted.
Of course, It’s not very difficult, even if the exchange doesn’t have your desired trading pair. As long as you have an account already set up and registered with your crypto exchange of choice, it’s actually pretty quick and easy. Even if you have to first sell your BTC for fiat, it won’t be long before you have the LTC.
But it still doesn’t change the fact that we must rely on a 3rd party (the crypto exchange) to oversee the exchange. Besides, your particular exchange may not even support the cryptocurrency that you’re looking for, forcing you to go and register on other exchanges. Even if you were to use a cryptocurrency exchange service between digital currencies, such as Changelly or Shapeshift.io, their work principles still work via the exchange. The following description of the process is pulled from the Changelly Wikipedia:
And so, this is where Atomic Swaps come into play, as they allow us to go about our exchange without having to rely on a third party, further helping the decentralized cause.
Atomic Swaps uses something called Hash Timelock Contracts (HTLC). It is a timebound smart contract that requires both parties involved to acknowledge and confirm the transaction before a deadline. If either one fails to confirm before the allotted time, the transaction is terminated and voided, which then returns the funds back to their senders.
Pretty cool right? If you’ve ever played some online games such as Warframe, they have the same sort of trading system, where both parties must confirm or the trade is voided. The only differences in an Atomic Swap isthe time-bound deadlines and the fact that when you “confirm” a transaction during an Atomic Swap, you are using a cryptographic hash function to acknowledge receipt of funds.
Atomic Cross Chain Swap protocol diagram. Allows exchanging coins between blockchains quickly and without trust. pic.twitter.com/5YttW0GvNM
— ncklr (@n1ckler) April 8, 2016
Below is an example of an atomic swap transaction:
In our example, Dog wants to trade/sell his 10 BTC for the equivalent in LTC that Fish has. So, Dog submits his transaction to the blockchain and then generates a secret number for a cryptographic hash function which encrypts the transaction and provides proof of payment. Fish then must also generate the same secret number in order for him to claim Dog’s BTC and exchange it with his LTC.
This all has to be done within a specified timeframe or else the entire transaction will not take place.
Most people believe that the technology of Atomic Swaps will help us run decentralized exchanges. Even now, atomic swaps can be used with the Lightning Network and be used in exchanging cryptocurrencies on a layer off-chain.
Right now, in order for you to perform an atomic swap, you need to have both blockchains of the cryptocurrencies you wish to exchange, downloaded.
At the moment, conducting an atomic swap isn’t the easiest thing to do. The original way of going about it is somewhat complicated for the average user. It involves running full nodes on both blockchains in each machine, having an atomic swap package as well as needing to run some protocols. More details on this can be found here: So How Do I Really Do An Atomic Swap
There have been some teams and projects, such as Blocknet, Lykke and Komodo who are working on ways to make doing an atomic swap much easier for the average user. Hopefully, in the near future, it will be as simple as doing a Bitcoin transaction like we already do on our mobile phone, but until that day comes along, be prepared to do a little technical digging if you want to get your atomic swap on.
References and links:
Cover illustration artist ahermin, DeviantArt