All You Want to Know About Atomic Swaps

All You Want to Know About Atomic Swaps


Today we’re going to be taking a deep-dive into cryptocurrency Atomic Swaps. We’ll take a look at:

  1. The definition
  2. Concepts
  3. Examples


Atomic swaps utilize blockchain smart contract technology in order to facilitate the exchange of one form of cryptocurrency for another. This is done without using a centralized entity, such as an exchange.

The exchange of assets between different blockchains can be conducted either on-chain or off-chain. The first ever example of an atomic swap took place between Decred and Litecoin in September 2017.

Since then many other swaps have successfully been completed, including Bitcoin’s Lightning Network, the Ethereum network and more.


Interestingly, despite the ease with which cryptocurrency ledgers can tokenize assets, facilitate cross-border payments, and even reach consensus in space; the business of swapping digital currencies that exist on different ledgers has remained difficult. Interoperability between networks has been slow. Therefore the efforts of protocol’s such as Decred and layering solutions like the Lightning Network have been incredibly important.

To get around counterparty risk atomic swaps use Hash Timeclock Contracts (HTLC). HTLCs are time-bound smart contracts between two parties that generates a cryptographic hash function, allowing for verification. By requiring both parties to acknowledge the receipt of funds within a specific time frame using cryptographic hash functions, if one side of the parties fail to do so the whole transaction fails. This helps to remove what is known as ‘counterparty risk’.


Bob and Alice are often wheeled out this point in order to demonstrate how cryptographic exchanges can work. We’ll take a look at an atomic swap in action.

Bob wants to exchange 2 ETH for the equivalent DCR. He has to first submit his transaction to the Ethereum blockchain. Then, Bob generates a number for the cryptographic hash function to encrypt the transaction. Alice follows exactly the same steps as Bob, submitting her transaction to DCR’s blockchain.

Bob and Alice unlock their funds by using their respective numbers, within a specific timeframe. If they do so, the on-chain swap of Bob’s ETH for Alice’s DCR will succeed. Both Bob and Alice can use any relevant form of atomic swap channel, such as a layer 2 solutions like the Lightning Network in order to process an off-chain exchange.

Interestingly, on-chain atomic swaps are not necessarily useful in all cases. According to Decred’s blog, the process is much more suited to larger trades that ‘do not require a particularly low latency of high-frequency speed’. Because the transactions are bound by the mining of blocks, users are limited by ledger confirmation times, which can be minutes or hours at worst.


Many developers are currently working on both channel scaling solutions and chain interoperability. In order for the cryptocurrency ecosystem to deal with the lack of standardization, atomic swaps are a crucial necessity in order to networks to communicate efficiently.

Some critics may argue that the locking up of digital assets in order to facilitate such swaps creates the very problem of nostro/vostro accounts that fiat fund encounter. However, until some form of agreed standardization is reached, atomic swaps remain the best option for building decentralized liquidity.