Atomic Swap

What Is an Atomic Swap?

An atomic swap is an exchange of cryptocurrencies from separate blockchains. The swap is conducted between two entities without a third party's involvement. The idea is to remove centralized intermediaries like regulated exchanges and give token owners total control.

The term atomic derives from the term "atomic state" in which a state has no substates; it either happens or it doesn't—there is no other alternative. This refers to the state of the cryptocurrency transaction; it happens or it doesn't.

Most atomic swap-enabled wallets and blockchains use smart contracts. Smart contracts are programs within blockchains that execute when certain conditions are met. In this case, the conditions are that each party agrees to the transaction before a timer runs out. Using a smart contract in the trade prevents either party from stealing a cryptocurrency from the other.

Atomic swaps are also called cross-chain atomic swaps.

Key Takeaways

  • An atomic swap is a cryptocurrency exchange between two parties that wish to exchange tokens from different blockchains.
  • Atomic swaps are helpful if you only have one cryptocurrency but need to use another in a transaction.
  • Special wallets or exchange services are needed to conduct an atomic swap because the technique is still being developed and refined.

Understanding Atomic Swaps

Each cryptocurrency is supported by a blockchain, designed only to accept transactions in specific tokens. For example, Bitcoin (BTC) has a blockchain, and ETH (ether) has another. You cannot easily exchange BTC and ETH without first converting to fiat currency then buying the other; another technique is to convert between cryptocurrencies and exchanges multiple times to get the one you want. Atomic swaps allow you to exchange tokens from different blockchains in one trade.

Decentralized exchanges can conduct atomic swaps for you. A decentralized exchange (DEX) has no central authority regulating it; it is a platform you can trade on without third parties. You can also choose from cross-chain swap providers, where you transfer your digital assets into another wallet, conduct the swap, and transfer them back out.

Atomic swaps rely on each party to provide proof through key encryption and acceptance of both parties through the encrypted key.

History of Atomic Swaps

The concept was conceived shortly after altcoins—cryptocurrencies other than Bitcoin—materialized. The creation of altcoins meant some cryptocurrency owners became interested in moving capital between coins. This type of token swap first appeared in September 2017, when an atomic swap between Decred and Litecoin was conducted.

Since then, startups and decentralized exchanges have implemented swaps and allowed users the same facility. For example, Lightning Labs, a startup that uses Bitcoin’s lightning network for transactions, has conducted off-chain swaps utilizing the technology.

Special cryptocurrency wallets have also been developed that are capable of cross-chain atomic swaps—Liquality has developed a wallet that will swap Bitcoin, ETH, and more.

Atomic Swap Process

In an atomic swap, two token owners agree to exchange their tokens for any amount they agree on. The smart contract program sees that they both agreed to it, so it executes the trade for them. The transaction is recorded in the blockchain and validated by the network nodes, and then a new block is opened for another transaction.

The transaction cannot be reversed. Both parties must agree to another transaction to exchange the tokens again if they would like them back.

Atomic swaps use Hash Timelock Contracts (HTLC) to automate the exchange of tokens. As its name denotes, HTLC is a time-bound smart contract between parties that involves generating one cryptographic hash on each end.

A cryptographic hash function is an algorithm that converts data of variable length, such as a person's wallet address and transaction information. It converts it to a hexadecimal number with a fixed length. In general, the number that is generated is called the hash.

HTLC requires both parties to acknowledge receipt of funds within a specified timeframe. If one party fails to confirm the transaction within the timeframe, then the entire transaction is voided, and funds are returned. This eliminates counterparty risk, or the risk that one party will accept the offered coins and decline the transfer of their coins.

For instance, suppose Jane wants to convert 1 BTC to an equivalent number of Litecoins with John. She submits the transaction through an atomic swap-capable wallet. A cryptographic hash function generates a hex number to encrypt the transaction during this process. The process is repeated at John's end.

Both Jane and John unlock their respective funds using their encrypted numbers. They have to do this within a specified timeframe, or the transfer will not occur. The HTLC within the blockchains then executes the trade.

Is an Atomic Swap Expensive?

The mainstream's ability to do atomic swaps is new, but they don't yet generate fees unless there are blockchain fees involved.

How Do You Do an Atomic Swap?

It is done using cryptocurrency wallets and Hash Timelock Contracts (HTLC), which enforce the exchange when both parties agree to it. In reality, there are only a few atomic swap wallet providers and decentralized exchanges that can be used in a swap.

What Are Cross-chain Atomic Swaps?

Cross-chain atomic swaps are cryptocurrency exchanges or trades between cryptocurrencies that use separate blockchains.

Investing in cryptocurrencies and other Initial Coin Offerings (“ICOs”) is highly risky and speculative, and this article is not a recommendation by Investopedia or the writer to invest in cryptocurrencies or other ICOs. Since each individual's situation is unique, a qualified professional should always be consulted before making any financial decisions. Investopedia makes no representations or warranties as to the accuracy or timeliness of the information contained herein.

Article Sources
Investopedia requires writers to use primary sources to support their work. These include white papers, government data, original reporting, and interviews with industry experts. We also reference original research from other reputable publishers where appropriate. You can learn more about the standards we follow in producing accurate, unbiased content in our editorial policy.
  1. Decred. "On-Chain Atomic Swaps." Accessed Jan. 24, 2022.

  2. Lightning Labs. "Connecting Blockchains: Instant Cross-Chain Transactions On Lightning." Accessed Jan. 24, 2022.

  3. Liquality. "How to Use the Liquality Wallet: Basic Features 101 Guide." Accessed Jan. 24, 2022.

Take the Next Step to Invest
The offers that appear in this table are from partnerships from which Investopedia receives compensation. This compensation may impact how and where listings appear. Investopedia does not include all offers available in the marketplace.