What Is An Atomic Swap?



Nov 22, 20222 min read

What Is An Atomic Swap?

An atomic swap (or cross-chain atomic swap) is a cryptocurrency exchange between two blockchains. The exchange is carried out between two entities with no intervention from a third party. The goal is to eliminate centralized middlemen such as regulated exchanges and give token owners complete power.

The phrase atomic comes from the term "atomic state," which refers to a state that has no substates; it either happens or it doesn't—there is no other option. This relates to the status of the bitcoin transaction; it either occurs or does not occur.

Smart contracts are used by the majority of atomic swap wallets and blockchains. Smart contracts are programs that run within blockchains when certain conditions are met. The conditions, in this case, are that each party agrees to the transaction before a timer runs out. The use of a smart contract in the transaction prevents one party from stealing cryptocurrency from the other.

How An Atomic Swap Works

Each cryptocurrency is backed by a blockchain that is solely designed to handle transactions in certain tokens. Bitcoin (BTC), for example, has one, while ETH (ether) has another. You cannot simply trade BTC and ETH without first converting to fiat money and then purchasing the other; another method is to convert between cryptocurrencies and exchanges many times to obtain the desired one. Atomic swaps allow you to exchange tokens from several blockchains in a single transaction.

Atomic swaps can be performed via decentralized exchanges. A decentralized exchange (DEX) is a platform that allows you to trade without the involvement of third parties. You can also use cross-chain swap providers, which allow you to transfer your digital assets into another wallet, perform the swap, and then transfer them back out.

Atomic Swap Process

Two token owners agree to trade their tokens for whatever amount they agree on in an atomic swap. When the smart contract computer notices that they have both agreed, it conducts the deal for them. The transaction is recorded in the blockchain and validated by network nodes before a new block is created to accommodate another transaction.

The transaction is irreversible. If they want the tokens back, both parties must agree to another transaction to exchange them.

Atomic swaps automate the exchange of tokens by utilizing Hash Timelock Contracts (HTLC). HTLC, as the name implies, is a time-bound smart contract between two parties that entails generating one cryptographic hash on each end.

Both parties must acknowledge receipt of cash within a certain timeframe, according to HTLC. If one of the parties fails to confirm the transaction within the timeframe specified, the entire transaction is canceled and the money is refunded. This reduces counterparty risk or the chance that one party may take the provided coins while refusing to transfer their own coins.

Assume Alex and May wish to convert 1 BTC to an equivalent amount of Litecoins. She submits the transaction using an atomic swap wallet. During this process, a cryptographic hash function generates a hex number to encrypt the transaction. At the end of Alex's life, the process is repeated.

Alex and May both use their encrypted numbers to unlock their respective funds. They must complete this within a certain time frame or the transfer will be canceled. The trade is then executed by the HTLC within the blockchains.


GameFi.org is a one-stop destination for web3 gaming. We aim to build digital communities and manage virtual economies for mainstream adoption. GameFi.org offers a suite of solutions covering the entire games and gamified projects' lifecycle, following a vision of one digital platform, and one virtual identity requiring zero blockchain knowledge. Visit https://gamefi.org/ for more information.

Twitter | Telegram Channel | Main Chat | Discord | Facebook | LinkedIn | YouTube