An Atomic Swap is a peer-to-peer swap between various cryptocurrencies without an agent. The term “atomic” is a sumptuous computer science word suggesting they either occur exclusively or not at all.
History and principle
In May 2013, Tier Nolan presented the idea of Swaps on BTCTalk . For the theoretical demonstration of an atomic swap, we assume two bitcoin-like blockchains. Frank has 10 Bitcoin he wants to trade for 50 Litecoin. Maria has the 50 Litecoin and agrees to the exchange.
Cross-chain atomic swaps
First, Maria gives the bitcoin address MB, to which she wants the bitcoin. Now Frank hashes a random value x and gets its hash h. Next, Frank sends his 10 bitcoin to a special bitcoin address. This address has the information MB, h and Frank’s bitcoin address from where the bitcoin came and the following conditions:
MB can get the bitcoins if it knows x or Frank can get the bitcoins if, for example, if 24 hours have passed.
Now Frank passes on this special Bitcoin address to Maria, on which he would like to have the Litecoins. Maria checks if the bitcoins are on and the withdrawal conditions are ok. If everything fits, she moves on the Litecoins. She sends the 50 Litecoins to a special Litecoin address. This Litecoin address has FL, h and Maria’s Litecoin address as information. h knows Maria from the special bitcoin address on which Franks store 10 BTC, which is visible on the blockchain. The address has the conditions:
FL can get the litecoins if he knows x or Maria can get the litecoins if 12 (<-play time) hours have passed. All these conditions can represent Bitcoin via the OP codes on-chain.
Scenario 1: Swap will be cashed
Frank checks if the conditions on the Litecoin-blockchain are set correctly and gets the 50 Litecoins with his x. He releases x, it is then in the transaction on the Bitcoin-blockchain. Maria recognizes the x and takes it for the retrieval of bitcoins. The Atomic Swap is complete.
Scenario 2: Time is running out
Something goes wrong with Maria or Frank and Frank can not redeem the swap. After the 12 hours have elapsed, Maria can get her litecoins back from the special address. Frank has to wait another 12 hours longer.
These types of addresses are also called HTLC for Hashed Timelocked Contract, so-called timed lock contract, because you have access to it either with the hash input or after a certain amount of time. It is important that in our example more time must pass for Frank until he can access his bitcoins than for Maria, because he has the key x. He could wait until the expiration date of his time-lock has ended, then get his Bitcoins and Maria’s Litecoin.
See, not all cryptocurrency exchanges back every coin. As such, a trader envying to exchange coin for another one that is not maintained on the prevailing exchange may require to transfer accounts or compose various exchanges between central coins to achieve the goal. There is also affiliated counterparty jeopardy if the trader wants to exchange coins with another trader.
Atomic swaps resolve this dilemma through the application of Hash Timelock Contracts (HTLC). As its signature indicates, HTLC is a time-bound smart contract between individuals that includes the peers of a cryptographic hash function, which can be confirmed between them.
Pros and Cons of Atomic Swaps
With atomic swaps, cross-block token trading can be achieved decentrally. Decentralization gives general benefits. Since every trading party never gives their keys out of hand, the whole thing is pretty safe from hacks. Governments can not stop trading, as with a central exchange such as Atomic Swaps, usually, cost only the transaction fees on the Blockchain. Two transactions are performed per blockchain.
The latencies depend on the block time of the blockchains. For example, an Atomic Swap on Bitcoin can take up to 10 minutes or more. There are different ways to counter this. The blockchains must have some degree of programmability, bitcoin OP codes are sufficient.
Komodo, a project that uses Atomic Swaps
Although the idea was developed in 2013, the first decentralized DEX was only operational in early 2018. The pioneering work has been done by Komodo with its BarterDEX. BarterDEX has an integrated distributed order book. Of course, the process of the atomic swap is taken over completely automatically by the software. Unfortunately, the trading volume is as good as 0. Due to the usual problems, such as the latencies, the traders prefer to move to central crypto exchanges.
Atomic swaps are a promising model for decentralized sales. Unfortunately, development is still in its infancy, yet experts expect that this technology in the future in a networked blockchain world will play a major role. They are the key to interblock communication, the link between technologies, making the last central instance superfluous.
Atomic Swaps are just a portion of the solution for the exchange quandary. We also require Decentralized Exchanges: exchanges not controlled by an individual person but by a system, thereby stopping unique cases of failure.
Disclaimer: This information should not be interpreted as an endorsement of any cryptocurrency. It is not a recommendation to trade. The crypto market is full of surprises and overhyped assets. Do your research before buying anything. Do not invest more than you can afford to lose.
You might also like
More from Education
Privacy coins are the progression of digital modes of money like Bitcoin. Bitcoin exchanges are ambiguous as in the owner …
The hash rate on the LTC network has reached a new all-time high up to a following LTC's growth to …