An atomic swap coordinates an exchange without requiring one party to send assets unconditionally and hope the other pays. The design aims for either a completed exchange or recovery of unclaimed funds under defined conditions. Atomic describes this settlement relationship, not necessarily simultaneous transfers or a single transaction across two chains.
Linking claims with a secret
A common cross-chain design uses hashed timelock contracts. Each party locks assets in a contract with a related hash condition. Claiming one side reveals a secret that enables the other party to claim the opposite side. Different refund deadlines leave time for that second claim.
If the exchange does not proceed, unclaimed funds can become refundable after the applicable timeout. Refunds may require a transaction; they are not necessarily sent automatically. Other atomic-swap designs can use different cryptographic mechanisms.
Conditions behind the guarantee
Safety depends on correct contracts, compatible chain features, adequate confirmations, and participants monitoring and acting before deadlines. Network disruption or reorganizations can undermine timing assumptions.
Atomic swaps do not guarantee instant execution, a willing counterparty, a favorable price, or zero fees. Funds may remain locked while a failed exchange times out. Their main purpose is to reduce the risk of one party taking payment without making the corresponding payment.