How it works
Both parties lock their respective coins in a hash time-locked contract (HTLC) on each chain. The contracts release the funds only when both parties reveal a shared secret, or refund automatically if the timer expires. The atomicity is mathematical: it is computationally impossible for one side to claim while the other fails. The whole exchange happens in minutes without ever placing funds with a third party.
Example
You hold 1 BTC and want 25 ETH from a counterparty. You both agree on a rate and lock funds: 1 BTC in an HTLC on Bitcoin, 25 ETH in an HTLC on Ethereum. A secret hash links both contracts. When you reveal the secret to claim the ETH, the counterparty learns the secret from the on-chain reveal and uses it to claim the BTC. If either party fails to act within the timer (usually 24 to 48 hours), both sides automatically refund.
Why it matters
Atomic swaps eliminate exchange counterparty risk entirely. They were the original DeFi primitive before automated market makers became dominant. They are still used in privacy-focused exchanges, lightning-network swaps, and some Bitcoin-Ethereum bridges. The downside is friction: setting one up requires more technical sophistication than using a centralised exchange, and discovering counterparties takes time. The modern equivalent for most users is a DEX with its own bridge.