Atomic Swaps is a fascinating topic to discuss. It has the potential to revolutionize the money transfer system around cryptocurrency. So, without wasting any time, let us jump onto atomic swaps.
Let us assume you have a Television and Mr. Gupta has a washing machine to sell. You want to sell your TV and buy a washing machine. Mr. Gupta wants to sell his washing machine and buy a TV.
You both don’t know each other, and even though the transaction is direct, it is impossible to execute it. Now, let us assume there is a platform that allows you to buy and sell items (OLX is a perfect example). You both can display your products on it and get what you want in exchange. However, there is still a problem with such systems – you first need to sell your items, and then only you can buy. Basically, no exchange is allowed.
A similar thing happens in the crypto world. There are so many cryptocurrencies – you may have Bitcoin and your friend has Dogecoin. Now you want Dogecoin, and your friend wants Bitcoin. To get what you both are looking for you will have to go to a centralized exchange and first sell cryptos and then buy new ones. There are a lot of issues with such a process –
- In the process, the coins can get hacked.
- Exchanges have to maintain demand and supply for a transaction to happen.
- Buying and selling are regulated.
What are Atomic Swaps?
If you understand the above discussion, understanding atomic swaps will be easy. It is a peer-to-peer exchange of cryptocurrencies between two parties without the need of a third party like a crypto exchange. The users have complete control and ownership of private keys during the process. You can execute trade between different native coins having the blockchain architecture.
How do Atomic Swaps work?
Looks very interesting, right? But how is it even possible? There is an interesting point related to atomic swaps. In atomic swaps, either the transaction will complete, or it will not start at all.
When the predetermined conditions are fulfilled, the atomic swap triggers and completes the transaction. If any condition is not fulfilled, the transaction will not initiate.
Let us understand it in more detail. Atomic swap uses are a two-way virtual safe function – Hashed Time Lock Contract (HTLC). HTLC utilizes complex mathematical encryption known as a hash function. It also has time constraints, and if either party fails to fulfill the condition within the decided time, the transaction will be canceled or reversed.
For example, the two parties agree on three different trading conditions. They decide to fulfill these three conditions in 30 minutes. If either party fails to satisfy any of the three conditions in 30 minutes, the crypto coins are sent back to the original owner, and no transaction happens.
The two ways to process the atomic swap are –
- On-chain: the atomic swap happens on a single blockchain network.
- Off-chain: the atomic swap transaction happens via a secondary layer similar to what we have discussed in the Lightning network article.
What are HTLC protocols?
To establish a trustless trading system, the HTLC has two protocols:
Timelock key – Every transaction has a deadline, and a timelock key is a safety mechanism to set that deadline. If for any reason, the swap is not completed, the timelock key ensures the coin is returned to the trader.
Hashlock key – Both the transacting parties have to submit cryptographic proof to complete the transaction. Once the proofs are submitted, the hashlock key ensures the trade gets completed.
Advantages of Atomic Swaps:
Below are some advantages of atomic swaps:
- With so many cryptocurrencies in the market, interoperability between them is a huge problem. A user having one coin first has to sell the coin. Then he can buy a new coin (if he wants to utilize the same fund). Atomic swap changes this for all users – most coins are brought under the same roof and can interact.
- Atomic swaps will encourage diversification. Now that people know they can buy and sell any coin directly, they will be more willing to hold different coins. Someone having Dogecoin will be more comfortable keeping it. He knows he can exchange it with Bitcoin on any given day.
- Central exchanges are open to attacks and hacking. However, with atomic swaps, since there is no 3rd party, the transactions are safe.
- Atomic swaps make transactions faster as the two wallets are directly connected, and no other steps are required for confirmation.
- You save on the exchange fee. You don’t have to pay a fee when you sell and more fees while buying a coin.
Cons of atomic swaps:
With whatever we have discussed above, you must be thinking -atomic swaps are perfect. However, just like every other concept, it has its own limitations.
- Not every set of two cryptocurrencies can engage with each other. There are certain conditions that coins need to satisfy to be eligible to be transacted using atomic swap.
- If the volume increases, the speed of atomic swap transactions will reduce. The lightning network can help here in a big way in the future.
We hope we have been successful in explaining atomic swaps. Are you still stuck at the cons above? Are you wondering about the coins that you can exchange? You should not worry. It allows you to swap more than 7800 different cryptocurrencies. It is a technology that can change the outlook of crypto trading in the coming years.