Atomic Swaps Definition
An atomic swap is the exchange of one cryptocurrency for another cryptocurrency without the requirement of a trusted third party. Atomic swaps are also referred to as atomic cross-chain trading because they allow two parties to trade coins despite utilizing different blockchains.
Atomic swaps use hash time-locked contracts (HTLCs) which ensure that both sides of the transaction fulfill their end of the bargain. Cryptographic proofs of payment are generated to confirm completion of the transactions.
The contracts are “time-locked” in that if the recipient of the payment does not acknowledge receipt of the payment prior to the contract’s deadline, the payment will be returned to sender and the recipient loses the right to receive the payment.
In order for atomic swaps to function properly, two key components must be in place:
1. The Lightning Network – The Lightning network must be implemented, which allows payments to be safely routed across multiple peer-to-peer channels. In effect, it links two blockchains together.
2. Cryptographic Hash Functions – Both blockchains–those of the sender and receiver–must use the same cryptographic hash function.
What are the Benefits of Atomic Swaps?
Atomic swaps allow cryptocurrency users to exchange coins without the need of a centralized exchange. This allows the parties to cut down on transaction costs and avoid trading delays that can befall cryptocurrency exchanges.
Atomic swaps also allow users to keep other personal financial information private, in contrast to trading through an exchange, which requires users to give up information like bank account numbers or credit / debit card numbers.
An Example of an Atomic Swap
Joe has 10 Bitcoins and wants to trade Suzy for 200 Litecoins. The blockchains use the same SHA-256 hash function and the Lightning network has been implemented.
Both parties submit their transactions to their respective blockchains. In order for Joe to receive Suzy’s 200 Litecoins, he must generate a number to produce a cryptographic hash. This is his proof of payment. In the same fashion, for Suzy to receive the 10 Bitcoins, she must provide the same number, thereby completing the atomic swap.