Atomic swaps secrets revealed: A complete guide:

Atomic Swaps in 360-degree dimension

Mathibharathi Mariselvan
6 min readOct 20, 2020
Atomic swaps

We have come across the swapping mechanism in the fiat financial portfolio. Yes, if one currency gets devalued and they are about to deteriorate, the country will ask another country’s Federal bank to swap the currency to manage the finances. However, it is very rare to know about swapping in cryptocurrencies.

As we all know, cryptocurrencies are not regulated and there is a wide prevalence that those currencies cannot be swapped. But it can be done. Some of those who are prevalent with cryptocurrency exchanges think that atomic swaps need the intervention of the exchange companies. But in fact, atomic swaps are those which do not need the intervention of the exchanges. One cryptocurrency can be swapped to another cryptocurrency in a minimal amount of time using atomic swaps.

Blockchain smart contracts are used in various cases in the real world, but in atomic swaps, they perform uniquely.

In this blog, let us know about atomic swaps and their entirety like their functions, benefits, area of operation, etc.

What are Atomic Swaps?

The term atomic swaps, first all, came into existence in September of 2017, when one cryptocurrency Dacered intended to swap to another cryptocurrency Litecoin. But the real proposal had been made by Tier Nolan in 2013. Atomic swaps are about swapping cryptocurrencies through the perspective blockchain network. That means, if an atomic swap is conducted, there will be communication between the blockchain of the two involved cryptos, and the coins are interchanged based on the value of the cryptocurrency.

This kind of cross-chain cryptocurrency swapping is made possible using the blockchain technique — public and private key assessment. Despite its emergence in 2017 actively, it has been in the trade perspective in the P2P format. In 2012, it was a trustless exchange protocol that led to the evolution of the peer-to-peer exchange-trading model. Later, it evolved due to the emergence of cryptocurrency exchanges.

In order to understand the atomic swaps in a more effective way, you need to know how the atomic swaps work and its development criteria:

How the Atomic Swap was developed?

After the revitalization and formalization of the Atomic Swaps in 2013, it was further revived by Mike Hearn and others to run the entire program without any protocol support. Only then did it revamp itself to swap the first cryptocurrency from Dogecoin to Litecoin in an effective manner.

They use a specific network to work on atomic swaps in any intrusive manner. But it is only in 2017, the first swap was conducted successfully due to the adjustments made in the swap mechanism. The lightning network came into the introduction and the first swap between the dogecoin and Litecoin was done using the Lightning network. However atomic swaps do not always work on a single mechanism. They work distinctively unlike other features in the cryptocurrency and let us know about some of the features of the atomic swaps.

In order to understand the functioning of atomic swaps, then we should learn about the workings of the atomic swaps in the first place:

Working of Atomic Swaps:

The Atomic Swaps works on the principle of smart contract technology. They use the technology known as the Hashlock and Timelock contract system (HCLT). HCLT technology involves two specific features — Hashlock and Timelock mechanism. Hashlock is the mechanism that is followed by the blockchain. Blockchain, after every transaction, stores in the block and hashs it accordingly. Hashlock is the thing in which the transactions based on swaps will proceed further only after those two parties have signed the respective transactions.

The Timelock mechanism is a particular transaction that will be hashed and locked after a particular time. That means that the transaction should happen within the prescribed amount of time. If not, the entire transaction will get locked and the swapping will halt. In short, securing the transaction within the time constraint is the timelock mechanism.

Let us see how it works with a general example:

First of all, person A wants to swap the cryptocurrency to person B. So the first person will build an HTCL address for the swapping mechanism. Once the address is built he stores the cryptocurrency into the address. Once the storage is done, a passcode is generated for the cryptocurrency. This method is called the preimage and then the transactions get hashed.

After getting hashed person A sends this to person B for reciprocating the same thing on his behalf. After confirmation from the two sides, the blockchain will release the platform for swapping the cryptocurrencies. In the meantime, person B will use the address sent by person A, generate a new address, and hash it. This will help the transaction lock on both ends. It can be accessed only through private keys controlled by persons A and B.

After the locking is done by person B, person A will again access the preimage using the passcode and hash address generated by person B. So, this transaction information can be in complete control of person A and person B. In the meantime, the hash addresses will go to the public and rebounce as private. But you need not think that it can be accessed by the public. The hashed content will completely remain among these two persons and will not get leaked.

The lifetime of the preimage can be fixed by the timelock mechanism present in the atomic swaps. If the preimage has a lifetime of 24 hours, and the preimage generated by person A is not opened by person B, then there are chances that the preimage would get lost and the swap cannot be refunded. So, it is more important to do refunds before the expiry of the preimage generated.

Despite the general principles, the atomic swaps can be divided into two types — On-chain and off-chain atomic swap.

On-chain atomic swap:

The on-chain network works on the principal involvement of the two different blockchains and the coins that are involved to be swapped. This is considered the most effective and safest atomic swap as it is conducted on blockchain technology. It further provides more security to the transactions compared to the off-chain ones.

Off-chain atomic swap:

This function functions in the secondary layer of the blockchain that is, outside the blockchain network. Their efficiency is higher and they perform tasks at a better pace but they are more complex to perform compared to the on-chain atomic swaps.

Benefits of Atomic Swaps:

Decentralization — This is a completely decentralized service and hence does not need any interference from the admin of the exchange or any intermediaries.

Security measures — Apart from the on-chain and off-chain mechanism, the presence of the hashlock and timelock system provides additional security to the atomic swaps.

Low trading fees — Compared to the exchanges, atomic swaps attract very low trading fees, as it does not involve the fiat to crypto but it swaps only one crypto to the other.

Flexibility — No such crypto functions are as flexible as atomic swaps.

Despite these advantages, there are certain restrictions in atomic swaps too. Some of them include liquidity issues, complexity, and certain privacy issues.

Final words:

Atomic swaps are one of the admirable features in the cryptocurrency sector which is available both in the centralized and decentralized medium. The only thing is that there will be no interference in the functioning. An atomic swap is one of the evolving crypto businesses for entrepreneurs. It involves minimal work with no requirement for technical knowledge. With the above information, you could have sensed the urge to start your atomic swap software. If so, contact the best Smart Contract Development Company to fulfill your dream of starting your crypto business.

--

--

Mathibharathi Mariselvan
Mathibharathi Mariselvan

Written by Mathibharathi Mariselvan

Co-Founder and Director - Pixel Web Solutions Helping blockchain startups bring ideas to life.

No responses yet