An atomic swap is a smart contract technology that enables the exchange of one cryptocurrency for another directly between two parties, without the need for a centralized exchange or trusted third party.
How Atomic Swaps Work
Atomic swaps use Hash Time-Locked Contracts (HTLCs) to ensure that either both parties complete the trade or neither does. The "atomic" part means the swap is indivisible — it either happens completely or not at all.
The Process
1. Party A creates a secret and generates a cryptographic hash of it, then locks their tokens in an HTLC.
2. Party B sees the hash and creates their own HTLC locked with the same hash, depositing their tokens.
3. Party A claims Party B's tokens by revealing the secret.
4. Party B uses the revealed secret to claim Party A's tokens.
Types
On-Chain Atomic Swaps: Occur directly on the respective blockchains. Slower but fully decentralized.
Off-Chain Atomic Swaps: Use Layer 2 channels (like Lightning Network) for faster, cheaper exchanges.
Significance
Atomic swaps represent a key step toward true decentralization in crypto trading, eliminating the need to trust centralized exchanges with custody of your funds.