Friday, October 23, 2026
Learn / DeFi and earning

What is an atomic swap in crypto?

An atomic swap is a trade of coins between two blockchains that either completes fully for both people or not at all, with no exchange holding the funds.

DeFi and earning Illustration: Cryptoweek

An atomic swap is a way for two people to exchange coins on two separate blockchains so that the trade either happens completely or does not happen at all. "Atomic" means it cannot be left half done. Neither side has to trust the other or hand funds to an exchange, because the rules of each blockchain enforce the deal.

How do atomic swaps work?

The method most often described is credited on the Bitcoin Wiki to a forum user called TierNolan. Suppose Alice has bitcoin and Bob has another coin.

  1. Alice picks a secret number and publishes only its hash, a fingerprint that cannot be reversed.
  2. Alice locks her bitcoin in a contract that pays Bob if he shows the secret, or refunds Alice after a deadline.
  3. Bob sees this and locks his coins on the other chain in a contract tied to the same hash, with a shorter deadline.
  4. Alice claims Bob's coins, which forces her to reveal the secret on that chain.
  5. Bob reads the revealed secret and uses it to claim Alice's bitcoin.

If anyone walks away before the end, the deadlines pass and both sides get their own coins back. Bob's deadline is shorter so that he always has time to claim after Alice reveals the secret.

What is an HTLC?

The lock used in each step is a hashed time-locked contract, or HTLC. Bitcoin Improvement Proposal 199, written in 2017, sets out a standard version. One branch lets the receiver spend the funds by revealing the secret that matches the hash. The other branch lets the sender take the funds back after a timeout.

The same tool powers more than swaps. BIP 199 notes that the Lightning Network uses HTLCs so that a payment passing through several channels settles only when the secret is released.

For a swap to work, both chains need compatible features, including the same hash function, signature checks and time locks. The Decred project listed those requirements when it completed what it described as the first on-chain atomic swap between Decred and Litecoin on September 19, 2017.

What is the difference between an atomic swap and a bridge?

A crypto bridge usually locks your coins on one chain and mints a stand-in token on another, so your funds depend on the bridge staying secure. An atomic swap is a trade with another person. You give up your coin and receive theirs, each on its native chain, and no pool of locked funds builds up in the middle.

The trade-offs are real. The Decred post noted that swaps involving bitcoin could take around an hour in the worst case, that fees are paid on both chains, and that its early tools offered no order book for finding a trading partner. Komodo, which builds swap software, adds that not every coin supports atomic swaps and congestion on either network can cause delays. When an app or DEX advertises a cross chain swap, it helps to check whether it uses a true atomic swap or a bridge underneath, since the risks differ.

This guide explains how things work. It is not financial, legal or tax advice. Last updated .