What Are Atomic Swaps? The Most Comprehensive Guide Ever!

in atomicswaps •  5 years ago  (edited)

When the Bitcoin was introduced, it did not only introduce a new form of currency. It also introduced a new technology called blockchain. In addition to that, it gave a new perspective to finance and money. It meant that no longer was a centralized authority required to perform transactions.

This peer-to-peer exchange of cryptocurrencies from one party to another without the involvement of a third party is performed using atomic swaps. This type of exchange is decentralized in its fullest sense. During the entire process, the users exercise complete control over the ownership of their private keys.

Decred and Litecoin did the first successful implementation of the atomic swap on 20th September 2017. Ever since then, atomic swaps have been considered one of the mainstream methods of Exchanging Cryptocurrencies.

Why atomic swaps?

  • Until the advent of atomic swaps, the exchange between cryptocurrencies was effected only by exchanges. These exchanges were largely centralized. They brought in all the disadvantages that come with centralization.

  • Centralized exchanges have always been vulnerable to getting hacked. Coincheck’s $550 million worth NEMs lost in a hack is a good example of this.

  • Exchanges might not be able to deal with an increase in demand. BCHs value went down by 50% because of the rise in demand. The downtime of the exchange Bithumb that lasted for about 90 mins resulted in a loss of 60000 Bitcoins.

  • Centralization and regulation go hand in hand. Any centralized exchange has to comply with the requirements of the Government.

How do atomic swaps work?

If a simple real-world analogy has to be given, the two people who like to engage in exchange agree on a shared secret. It is only upon the secret matching that they will share the cryptos. Therefore, even if someone snoops into the transaction, they will still not be able to get their hands on the currency because they do not know the shared secret.

In the cryptographic context, atomic swaps use Hashed Timelock Contracts (HTLCs). These contracts are special forms of payment channels that exist off the main blockchain (off-chain state channels). These side channels or off-chain state channels help in conducting interactions that are supposed to happen in the blockchain but are done off the blockchain. This translates into a lesser transaction time as there are no miners involved invalidating your transaction.

So how does the validation occur?

A specific segment of the blockchain is locked using a multi-signature smart contract which is mutually agreed upon by a specific set of participants.

The participants interact by signing transactions among each other, and it does not involve any external miners.

After the entire transaction is done, the transaction set is then added to the blockchain.

This state channel can be closed by using predetermined factors decided by the participants. It could be a leader in terms of time or the amount of transaction. In HTLCs, Hashlocks are introduced along with timelocks. The funds are transferred within a pre-agreed deadline. The acknowledgment is done using the submission of cryptographic proofs. The HTLC presents one of the most convenient applications of payment channels.

What actually happens in an atomic swap?

Let us say two parties would like to exchange two cryptocurrencies. The person who initiates the exchange for the swapping creates a contract address on a new payment channel. The contract address can be considered as a multi-lock safe that takes care of both the funds. The initiating party deposits their currency and produces a value. This particular value acts like a key, and the hash generated from it acts as a lock. After this step, the hash or the lock is sent to the other party.

Using this hash, the receiving party can create a contract address. The receiving party sends its contract address to the initiator. Since this contract address was created using the hash that was sent by the initiator, this contract address is pretty much useless to anyone other than the initiator. The initiator can receive their coins by signing a transaction for the receiver’s contract address. The receiver can do the same with the initiator’s contract address.

Different Types of Atomic Swaps:

Atomic swaps can be classified mainly into two different types - the on-chain swap and the off-chain swap. The first type happens on the blockchain of one of the two currencies that are being exchanged. The second type of swapping facilitates this process outside the blockchain. This swapping happens on what is commonly known as layer 2.

Advantages of atomic swaps

  • Atomic swaps enable interoperability between different assets.

  • Atomic swaps are bringing the crypto ecosystem to a currency-agnostic mode. It enables people processing different crypto assets to interact with each other. It contributes to the democratization of the entire crypto world.

  • This kind of peer to peer exchange removes a lot of the disadvantages of centralization like minimizing the possibility of malicious attacks, mismanagement, and internal maintenance issues.

Conclusion

Although this new mode of transaction and exchange might face hiccups due to lack of adoption, speed, and compatibility, it might not be long before atomic swapping becomes a mainstream method of exchange, not only in the crypto world but also in the fiat world.

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!