What Is an Atomic Swap?-banner-imageAcademy

What Is an Atomic Swap?

Atomic Swap is a smart contract-based technology that enables cryptocurrency exchanges without the involvement of a centralized platform or third parties. Atomic Swap can be performed between different blockchains.

Atomic Swap was introduced by Tier Nolan in 2013. However, the idea of Atomic Swap had been proposed before him. Some consider the P2PTradeX protocol, introduced by Daniel Larimer in 2012, to be the prototype for Atomic Swap.

How Does an Atomic Swap Work?

One of the most important advantages of Atomic Swap is that it allows secure transactions without the involvement of third parties. Users can transact through their own wallets without the need for intermediaries. The approval of both parties is required for an Atomic Swap to take place, otherwise the transaction will be canceled. Thus, the possibility of fraud is eliminated. A certain time limit is given to both parties to approve or reject the transaction. Atomic Swap can be done in two ways, on-chain or off-chain.

For example, Julia wants to convert 1 BTC into Litecoin owned by Anthony. First, Julia deposits her BTC at a smart contract address that acts as a vault. A passcode is generated to access the BTC in the vault. Julia needs to share the cryptographic hash version of this passcode with Anthony to perform the transaction. However, Anthony has the hash, not the passcode. That’s why he cannot access the BTC in the vault yet. In the next step, Anthony deposits his LTC at a smart contract address that acts as another vault, using the hash he received. Julia needs to use the same passcode to access the LTC Anthony has deposited. Julia, who uses the same passcode at this stage, ensures that the passcode is visible to Anthony thanks to a function called Hashlock. Anthony can access the BTC while Julia can access the LTC, and the Atomic Swap is completed. If one of the parties abandons the transaction at any stage, the transaction will be canceled, and the deposited amounts will be returned to the owners.