Many of the newcomers to the cryptocurrency world might not know that digital currencies can be exchanged without the need of online exchanges. The magic happens thanks to a technology often referred to as atomic swaps. But what are they really? Put simply, they are just a smart contract technology, which enables parties to directly exchange one currency for another.
Many of the newcomers to the cryptocurrency world might not know that digital currencies can be exchanged without the need of online exchanges. The magic happens thanks to a technology often referred to as atomic swaps. But what are they really? Put simply, they are just a smart contract technology, which enables parties to directly exchange one currency for another. And yes, only the two parties are involved because there is no need of centralized intermediaries.
The first recorded atomic swap took place in September last year when Decred and Litecoin were exchanged. Swaps can happen either off-chain or between the main blockchains of the currencies in hand. Atomic swaps have been regularly conducted by startups and decentralized exchanges since then. Lightning Labs who utilize bitcoin’s lightning network frequently uses this smart contract technology to perform off-chain swaps. Moreover, decentralized exchanges and some digital currencies such as 0x and Altcoin.io have adopted the technology as well.
Many of you would agree that some tokens are difficult to obtain and the whole process is time-consuming and let’s just say it as it is – it’s a pain. Exchanges do not support each and every cryptocurrency out there so traders are forced to jump back and forth until they supply themselves with the desired coins.
Let’s imagine I have a Coinbase account but I want to buy some altcoins, which are not available there. I am lucky to find them on another exchange but unfortunately, the exchange does not accept fiat. Now I have to transfer some BTC or ETH to the second exchange and purchase those tokens. When the prices are good and I decide to sell the altcoins the whole process takes place once again. And this is not the most complicated scenario.
Thanks to atomic swaps, we can bypass all the hassle. They simply use Hash Timelock Contracts or in other words, a smart contract is generated between the parties for a specific timeframe. When both parties verify the transaction funds meet their new owners. The opposite is also true. If someone does not validate the transaction all funds go back to their original owners.
A quick example to make it all clear. If Joe wants to exchange litecoins for the bitcoins Nick has, Joe submits his coins to litecoin’s blockchain. This generates a cryptographic hash function that encrypts the transaction. Nick does the very same thing but on bitcoin’s network. Then Joe and Nick unlock the funds within a specified period, otherwise, the transaction will not take place. As simple as that.