An atomic swap is a trustless peer-to-peer exchange of cryptocurrencies across different blockchains using cryptographic hash locks and time locks, ensuring that either both parties receive their assets or neither does, no intermediary required. The mechanism uses Hash Time-Locked Contracts (HTLCs). Alice wants to trade Bitcoin for Bob's Litecoin. Alice generates a secret and creates its hash. She locks her Bitcoin in a contract that releases to Bob if he provides the secret within 24 hours, or returns to Alice after timeout. Bob sees the hash and creates a matching contract on Litecoin: his coins release to Alice if she provides the same secret within 12 hours (shorter timeout is critical). Alice claims Bob's Litecoin by revealing the secret. Bob learns the secret from Alice's claim transaction and uses it to claim Alice's Bitcoin. The atomicity guarantee: if Alice claims, she reveals the secret Bob needs; if she doesn't claim, both contracts timeout and funds return. 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. DEXs and bridges have largely replaced atomic swaps for casual users, but the primitive remains important for trustless cross-chain interoperability without intermediaries.
Back to Glossary