What is an Atomic Swap? - Godex Crypto Blog

What is an Atomic Swap?

atomic swap
Contents

Atomic swap or atomic cross-chain swap (ACCS) is a technology that makes it possible to trade cryptocurrencies across different blockchains without the need for middlemen in a single transaction.

Since each crypto is backed by a certain blockchain, which is applicable only to transactions with particular digital currencies, it is not possible to exchange some tokens in one trade. This applies, for instance, to the exchange of such currencies as BTC and ETH. BTC cannot be converted directly into ETH, or vice versa, since they belong to different blockchains. To exchange them, one will need to either first convert one of the cryptocurrencies into fiat money, in order to then buy the desired crypto for it, or get it through multiple conversions between coins using various exchanges. Atomic cross-chain swaps enable exchange of digital currencies from different blockchains in one go.

Although the idea of P2P transactions was brainstormed almost 10 years ago, it is still an innovation and is in the process of growth and refinement. This means that by no means all blockchains have applied this technology yet, and special wallets or exchangers are required for those who want to carry out an atomic swap.

How Do Atomic Swaps Work?

Atomic Swap technology is very similar to Lightning Network technology, and some resources call them kindred spirits. They are united by the similarity of algorithms, which we will now deal with.

Like the Lightning network, ACCS uses a tool called Hashed TimeLock Contracts (HTLC), which has two essential features: hashlock and timelock. They ensure the reliability of atomic transactions by requiring the participants in the swap to comply with all conditions in order for the transaction to be carried out. 

So, for example, the hashlock function converts data such as transaction details and wallet address into a number that a swap participant needs to know in order to receive their tokens.

Another security solution is timelock, which limits the time within which a trade must be completed. Swap participants determine the time period within which it is necessary to complete a set of actions necessary for the successful completion of the transaction.

All prerequisites for the possibility of an atomic swap are written in a smart contract that monitors their implementation. In case of non-compliance with them, the entire transfer is revoked and the tokens are returned to their holders. This reduces the risk of a counterparty or that one participant, having received their coins, refuses to send theirs.

An example of using atomic swaps

Let’s take a look at atomic swaps in action with the following example. Suppose Bella wants to exchange her Bitcoins (BTC) for Jacob’s Litecoins (LTC). These are the next steps they should take as part of an atomic exchange:

1) Bella deposits her coins to a new address on the BTC blockchain, which acts as a safe, after which access keys to it are also generated.

2) She shares the hash of this key with Jacob, who does not yet have access to BTC, since he owns not the key itself, but the hash. The hashed password or key is proof that Bella has locked her BTC coins for further exchange.

3) Jacob uses the hashed key provided by Bella to create another secure address on the LTC blockchain to which he deposits his coins.

4) To receive LTC coins, Bella uses the same key, which she also shows Jacob using the hashlock function.

5) As soon as Bella receives LTC, Jacob gets access to BTC coins and the crypto bargain is completed.

Atomic exchange technology can be implemented both on-chain, that is, directly across the blockchains of various cryptos, and off-chain – outside the blockchain. The essence of an off-chain transaction differs from a blockchain one in its simplicity. If in on-chain a transaction becomes valid after changing the blockchain that reflects the exchange operation, and is verified and certified by the necessary number of participants who certify it, then in off-chain the exchange takes place outside the blockchain, and as a result, only the result is recorded in the system.

In the simplest off-chain cases, the parties exchange secret keys from wallets containing a fixed amount of crypto. In this case, digital coins do not change addresses, but change their owners.

Why Do I Need to Use Atomic Swaps?

Atomic cross-chain swap is especially the best option for traders who need to quickly and smoothly exchange cryptocurrencies. Since this method of exchange does not require the involvement of centralized mediators such as exchanges, the transaction can be completed faster, cheaper and more securely.

Since all transactions are carried out directly from the personal crypto wallets of the exchange participants, their assets are under greater control. In addition, with the advent of atomic swapping technology, it became possible to trade from various blockchains in one go. And due to the fact that the transaction does not occur if all conditions are not met by all participants, the risk of the counterparty is reduced.

How Do You Do an Atomic Swap?

To perform a P2P token swap using innovative technology, you need an atomic swap-enabled wallet and Hash Timelock Contracts (HTLC). Since the technology is still in the process of expansion, there are few wallets that support this method of exchange, as well as DEXs that are suitable for atomic swaps.

Which Crypto Uses Atomic Swaps?

The first successful trades using atomic swap technology were between Litecoin and Decred, Vertcoin and Bitcoin. They may have attracted increased attention from the community, but the matter is not limited to these cryptocurrencies alone.

It should be noted that for the successful implementation of 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 it is likely that it will soon become available to a wide range of users. So, the Komodo project introduced its own decentralized exchange BarterDEX. In particular, its developers have successfully carried out an atomic swap using the Electrum server, which allows you to interact with cryptocurrency without having to download the entire blockchain.

Also noteworthy is the development of AtomicDEX, an application that combines a non-custodial wallet, a cross-chain bridge, and a cross-network decentralized exchange. Users can store and trade BTC, ETH, ERC-20, BNB, BEP-20, Polygon, PLG-20, KMD tokens and other digital assets from different blockchains.

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

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

Advantages of Atomic Swaps

Using atomic swaps wouldn’t make sense if they didn’t benefit a user. Here are the main advantages of an innovative exchange method:

  • increase the security of transactions, as they exclude the influence of centralized exchanges;
  • allow you to make transactions without paying commission to intermediaries;
  • are completely safe for both parties;
  • make operations with cryptocurrency completely decentralized;
  • expand exchange reserves.

Final Word

Atomic swaps promise to completely eliminate counterparty risk and theft. However, although atomic swaps are highly decentralized and do not require intermediaries to facilitate transactions, transactions can remain limited due to liquidity. Without an exchange platform, it can be arduous to bring traders together. Nonetheless, as atomic swaps evolve, they are beginning to integrate into the DEX and gain more fans of the technology, which guarantees lower fees, higher autonomy, and comprehensive serviceability.

FAQ

Is an Atomic Swap Expensive?

Logically, since atomic swaps exclude the participation of go-betweens who could take their cut, trades using this technology should be cheaper than centralized services. Nonetheless, in reality, low fees are not guaranteed. During an atomic swap, you still need to pay transaction fees on the network, and these can be quite expensive. Off-chain swaps can solve this problem, but there are still other issues that ought to be addressed.

Are Atomic swaps taxable?

The token exchange itself is not a taxable event. However, keeping a good record of the new coin base to calculate capital gains/losses is recommended. Integrating the tax reporting API with crypto tax software can make this task easier.

How will Atomic Swaps impact the market?

The trump card of atomic swaps is improved conditions and opportunities for cross-chain trading. Thus, if a certain exchange or blockchain has a liquidity issue, it can be solved by liquidity compensation on another chain. The entire digital market benefits from increased liquidity, using technology that is not limited to one exchange.

As more wallets become compatible with atomic swap technology, users will be able to make exchanges directly from them while maintaining full control over their funds. This will of course lead to more active crypto trading.

Start a Cryptocurrency exchange
Try our crypto exchange platform

Exchange

Disclaimer: Please keep in mind that the content of this article is not financial or investing advice. The information provided is the author’s opinion only and should not be considered as direct recommendations for trading or investment. Any article reader or website visitor should consider multiple viewpoints and become familiar with all local regulations before cryptocurrency investment. We do not make any warranties about reliability and accuracy of this information.

Leave a comment

Leave your comment

Read more