An atomic swap is a trustless peer-to-peer exchange of coins across different chains using hash locks and time locks. Either both sides receive assets or neither does. No exchange sits in the middle. The tool is Hash Time-Locked Contracts, HTLCs.
Alice wants Bitcoin for Bob's Litecoin. Alice makes a secret and hashes it. She locks Bitcoin in a contract that pays Bob if he shows the secret within 24 hours, otherwise it returns to Alice. Bob sees the hash and locks Litecoin that pays Alice if she shows the same secret within 12 hours. The shorter timeout is required. Alice claims the Litecoin by revealing the secret.
Bob reads the secret from that claim and takes the Bitcoin. If Alice claims, Bob learns what he needs. If she does not, both contracts time out and funds return. Neither side can take without giving. Atomic swaps remove exchange custody risk. In practice both parties must be online in the window, fees hit both chains, and setup is technical. DEXs and bridges replaced atomic swaps for most users.
The primitive still matters for cross-chain trade without an intermediary. Alice generates a secret and creates its hash. Neither party can cheat. Atomic swaps eliminate exchange counterparty risk and enable truly decentralized cross-chain trading.
Practical challenges limited adoption: both parties must be online during the swap window, transaction fees on both chains add up, and the process requires technical setup. Hash timelock contracts let two chains swap without a custodian. If one side does not reveal the secret, funds return after a timeout.
Atomic Swap Visualization
Interactive demonstration of trustless cross-chain cryptocurrency exchange using Hash Time-Locked Contracts (HTLCs)
Alice
Wants Litecoin
Alice's Contract
Hash: a8b2c4d6
Time Lock: 24h
Status: inactive
Initial Setup
Bob
Wants Bitcoin
Bob's Contract
Hash: a8b2c4d6
Time Lock: 22h
Status: inactive
Alice wants to trade Bitcoin for Bob's Litecoin without a trusted intermediary.