What Are Atomic Swaps And How Do They Work?

What is an Atomic Swap?

Things have been happening around blockchain and recently there was the launch of an exchange, Atomic Swap. Atomic Swap is an exchange of cryptocurrencies from different blockchains. The swap is carried out between two operations without the requirements and involvement of middlemen, brokers, or third parties. The idea is to eliminate centralized middlemen and give token owners full control of their tokens. Atomic swaps, allows cryptocurrencies to be traded peer-to-peer without associating with third parties since they are computerized, self-enforcing exchanges. 

Two types of atomic swaps:

  1. On-Chain Swaps

On-Chain swap transactions are some kind of transaction that is carried out between two contrasting cryptocurrencies on two separate blockchains. Once authenticated , the transaction is attached to the public ledger of a blockchain network. 

  1. Off-Chain Swaps 

Here, transactions are made by handing over some of the work to a blockchain ecosystem, which then reunites with the main blockchain. On an off-chain network, customers can consent to a third party being in charge of authentication and transaction validation.

How Does Atomic Swap Work?

In an atomic swap, two token holders consent to exchange their tokens for whatever sum of money they agree on. When the smart contract witnesses that both parties have consented to it, it automatically carries out the trade for them. After this is completed, the transaction is documented in the blockchain and confirmed by the network nodes. After the completion of the whole process, a new block is opened for another transaction.

Users need to understand that transactions cannot be reversed. Both users must agree to another transaction for them to exchange tokens again. Atomic swaps use Hash Timelock Contracts (HTLC) to execute exchange of tokens 

For instance, let’s say Paul and Delvise want to exchange cryptocurrencies through an atomic swap.

Paul stakes his cryptocurrency into a Hash Timelock Contract address, and this acts like an essential safe_deposit box. This safe can only be unlocked by him using a special key that he only has access to.

Afterwards, Lara shares the coded information of the special key with Delvise, who later deposits the cryptocurrencies to the address sent by Paul using the same coded information. 

Once Delvise has deposited the cryptocurrency, Paul can access the money by unlocking the transactions using the special key from his deposit.

Now, when Paul unlocks the transaction, Delvise can access his shares of the exchange. 

 The atomic swap is completed once both parties have obtained their individual funds.

Each cryptocurrency is second on a blockchain, equipped only to allow specific token transactions. For instance, since ETH has its own blockchain and BTC has its own blockchain, users can not easily change ETH or BTC to liquid money since you have to change cryptocurrencies to fiat money.

Latest posts by Andrew Smith (see all)

Source: https://www.thecoinrepublic.com/2023/08/20/what-are-atomic-swaps-and-how-do-they-work/