//Atomic Swaps
Atomic swap explained

Atomic Swaps

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

  • The definition of atomic swaps
  • The core concepts behind it
  • Example
  • Video
  • Jargon Take Away*

Definition


Atomic swaps utilize blockchain smart contracts 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.

Image result for Decred and Litecoin atomic swap tweet
Charlie Lee Tweet, Litecoin creator

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

Concepts


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 Time Lock 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 fails to do so the whole transaction fails. This helps to remove what is known as ‘counterparty risk’ *.

Hash Time Lock Contract Example

Example


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. Bob 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.

‘This specific swap process is much more suited to larger trades that do not require a particularly low latency of high frequency speed’

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.

Conclusion


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.

Still unclear?

Jargon Take Away


Hash Time Lock Contracts : Class of payments that use hashlocks and timelocks to require that the receiver of a payment either acknowledge receiving the payment prior to a deadline by generating cryptographic proof of payment or forfeit the ability to claim the payment, returning it to the payer

Nostro/Vostro accounts:Nostro and vostro are Italian terms that describe the same bank account. They’re used when one bank has another bank’s money on deposit.

On-chain and off-chain transactions : On-chain transactions refer to the cryptocurrency transactions occurring on the blockchain (meaning on the records of the blockchain) – and remain dependent on the state of the blockchain for their validity. All such on-chain transactions occur and are considered to be valid only when the blockchain is modified to reflect these transactions on the public ledger records. Off-chain transactions refer to the transactions occurring on a cryptocurrency network which move the value outside of the blockchain. Due to their zero/low cost, off-chain transactions are gaining popularity, especially among large participants.

Investopedia, Decred, Litecoin, BitcoinIT, IPE, Blockgeeks (Video)