What Is an Atomic Swap?
An atomic swap is a direct exchange of cryptocurrencies on two different blockchains without an intermediary, on an all-or-nothing basis. It relies on hash time-locked contracts (HTLCs) so neither side has to trust the other.
On this page 6
An atomic swap is a way to exchange cryptocurrencies on two different blockchains directly, without an exchange or any other intermediary. “Atomic” means the trade can’t be split: either both sides of the swap complete, or neither does. That removes the risk of one party taking the funds without paying, so the two parties don’t need to trust each other.
How does an atomic swap work?
Atomic swaps rely on a hash time-locked contract, or HTLC. The contract has two conditions: revealing a secret (the hash lock) and a deadline (the time lock). Say Alice wants to swap bitcoin for Bob’s litecoin:
- Alice picks a secret number and locks BTC in a contract tied to that number’s hash, with a 48-hour time lock.
- Bob uses the same hash to lock LTC on the Litecoin chain, with a shorter time lock of, say, 24 hours.
- Alice claims the LTC by revealing the secret. Because that reveal is recorded on-chain, Bob can now see it.
- Bob uses the secret to claim the BTC. If the swap isn’t completed in time, the time locks expire and both parties get their funds back.
The staggered time locks stop the party who knows the secret from claiming the other side’s funds and then also reclaiming their own.
Advantages of atomic swaps
- No intermediary: funds are never handed to an exchange or custodian; users keep their private keys.
- No counterparty risk: the swap either completes in full or the funds are returned.
- No wrapped tokens: assets stay on their native chains, so no synthetic representation is created.
The same HTLC logic underpins Bitcoin’s Lightning Network, where it lets payments be routed safely across multiple channels.
Limitations
Both chains must support the same hash function and time-lock features, so not every pair of coins is compatible. A counterparty can walk away mid-swap if the price moves; the funds come back, but time and opportunity are lost. Finding someone to trade with is another hurdle, since there’s no deep order book like on a centralized exchange.
One of the first known atomic swaps took place in 2017 between Decred and Litecoin. Some decentralized exchanges have tried to use the technique behind the scenes to offer cross-chain trading, but limited liquidity and usability have kept atomic swaps from going mainstream.
Atomic swaps vs bridges and DEXs
Blockchain bridges usually lock an asset on one chain and mint a wrapped version on another, which requires trusting whoever holds the locked funds and creates a large target for attackers. With an atomic swap, assets stay on their own chains and only ownership changes hands. DEXs, by contrast, mostly handle swaps between tokens on the same chain.
Frequently asked questions
Are atomic swaps safe? The protocol removes counterparty risk, but the software used must be bug-free and each step must be completed within the time locks.
Do I need an exchange account for an atomic swap? No. Both parties use their own wallets; no identity verification or custodial account is needed.
Which coins support atomic swaps? Any two chains that share a hash function and support time locks can swap. Bitcoin, Litecoin and many Bitcoin-derived coins meet these requirements, and on smart contract chains an HTLC can be written as a contract.