What are atomic swaps?

1. What are atomic swaps?

An atomic swap is a transaction to exchange one cryptocurrency for another, which can be executed instantly without the need to rely on a trusted third party (intermediary) such as an exchange or an exchange platform. As a result, the parties involved have sole control over the transaction.

Atomic swaps can be executed both onchain, that is, directly between the blockchains of different cryptocurrencies, and offchain, outside of the blockchain. The first such exchange was made on September 19, 2017 between the cryptocurrencies Decred and Litecoin.

2. What causes the need for atomic swaps?

The process of exchanging cryptocurrencies on exchanges and other specialized platforms can still be quite time-consuming and is often associated with inflated commissions. In addition, not all exchanges support all coins or the right trading pairs, making a trader who wants to exchange one cryptocurrency for another forced to make additional conversions.

To solve these problems, including the mentioned third-party trust risks, atomic swap technology was developed. It was first described back in 2013, but has only recently begun to be put into practice.

3. How does it work from a technical point of view?

Atomic swaps use a time-locked hashing contract (HTLC). As the name implies, HTLC is a time-locked smart contract that involves generating a cryptographic hash function that can be verified by exchange participants.

In other words, HTLC requires the recipient of a payment to acknowledge receipt of funds by generating a cryptographic confirmation of the payment before the deadline. Otherwise, the transaction is invalidated and the funds are returned to the sender.

Also you may like >  What are security tokens and Security Token Offering (STO)?

4. How does it work in practice?

Alice has 100 LTC, which she wants to exchange for an equivalent amount of BTC. The traditional mechanism assumes that Alice goes to an exchange, deposits her account, and places an order to sell her LTC coins. In the case of an atomic swap, Alice can directly exchange her LTCs for BTCs, the right amount of which Bob has.

Alice, as the initiator of the transaction, creates a contract address, which can be compared to a safe deposit box. This address holds Alice’s LTC during the swap process. It requires Bob’s signature as well as Alice’s generated number to open it. It is very important that at this stage Alice does not share this number with Bob, because then he can open the cell and take all the funds there before the swap is completed.

Next, Alice comes up with a secret number and creates a hash. The hash acts as a lock, while the secret number is the key. Bob looks up the contract address from Alice, makes sure everything is in order, and then creates his own cell with the same key. To do this, Alice sends Bob the hash he created earlier, but he needs Alice’s signature to open the cell.

From this point on, Alice has the key and also the ability to sign the cell to Bob and therefore redeem the funds tied to the address. Bob is then given the secret number he needs, which up to that point he did not know. Bob can use this secret number to open Alice’s box and collect the funds he is entitled to.

Also you may like >  What is a bitcoin?

As you can see, HTLC structures the transaction in such a way that the parties depend on each other to ensure the successful completion of the exchange. Transactions are set up so that if for some reason the transaction is terminated, all funds are returned to their owners after a certain period of time set by each party.

5. Is the Lightning Network protocol necessary for atomic swaps?

Contrary to widespread misconception, Lightning Network technology is not a prerequisite for successful atomic swaps, but it can make the exchange process simpler, faster and more efficient.

Like atomic swaps, Lightning Network uses time-locked hashing contracts, the difference being that while atomic swaps bind blockchains, Lightning Network binds payment channels. This method assumes that Alice and Bob open a payment channel with Carol and make the exchange through Carol without having to trust her.

The same underlying mechanism means that integrating the Lightning Network into atomic swaps is simple enough that different Lightning Networks can be linked together in different blockchains as a result. Because of this, a swap participant who opens payment channels on both blockchains can act as a payment processor or, for example, a decentralized altcoin exchange.

6. What is the difference between on-chain and off-chain swaps?

On-chain atomic swaps take place directly on the exchanged cryptocurrency’s blockchain, which, in addition to supporting HTLC, must also use the same hashing algorithm for successful exchange.

Off-chain atomic swaps allow the exchange of coins outside the blockchain, an extension of the Lightning Network.

7. Which cryptocurrencies support atomic swap technology?

The first successful exchanges using atomic swap technology were between Litecoin and Decred, Vertcoin and Bitcoin. They may have attracted a lot of attention from the community, but these cryptocurrencies are not the only ones.

Also you may like >  How to choose a bitcoin wallet?

It should be noted that in order to successfully implement atomic swaps in their initial implementation, the user needs to download the blockchains of both currencies. For the average user, this process is quite inconvenient from a practical and technical point of view.

However, a solution to this problem has already been found, and there is a chance that it will soon become available to a wide range of users. Thus, the project Komodo is working on the creation of its own decentralized exchange BarterDEX. In particular, its developers have successfully atomic swap using Electrum server, which allows to interact with the cryptocurrency without the need to download the entire blockchain.

Moreover, the Komodo team claims that after successfully linking bitcoin and Ethereum blockchains and implementing support for ERC-20 format tokens, their exchange BarterDEX now supports p2p exchanges between 95% of all existing coins and tokens.

Other well-known projects actively working on the practical implementation of the atomic swaps concept are Blocknet, which aims to create a blockchain internet based on Xbridge technology; Altcoin.io, which is working on a decentralized exchange based on Plasma technology and a wallet with built-in atomic swaps functions; and Atomic Wallet.

A resource like swapready.net can help you track how close a particular cryptocurrency is to supporting atomic swaps with another asset.

You may also like