Guide: What is an Atomic Swap
By: Kript Team
Tags: Cryptocurrency, Blockchain, Guides And Tutorials

Atomic swaps are becoming more and more popular in the world of cryptocurrency. Therefore, this concept is worth figuring out.

Meaning and history

The word “atomic” was adopted from computer science and refers to as a number of database operations that either occur altogether or do not occur at all, and in crypto this term emphasizes that the trade happens indivisibly. An atomic swap is a cryptographically powered smart contract technology that enables the parties to exchange different cryptocurrencies without intermediaries as it eliminates the risk of one party defaulting on the trade. In order to be effected with the use of an atomic swap, transactions must be complete, solid and whole. If any of the conditions is not met, the swap is not confirmed. That means that neither of the parties can lose their funds using atomic swaps.

The concept of atomic swaps was initially introduced by Tier Nolan in May 2013. The first ever atomic swap took place in September 2017 between Litecoin and Decred. And in October 2017 there took place the first atomic swap between Bitcoin and Ethereum on Altcoin.io exchange. Up to date atomic swaps are available for different cryptocurrencies.

On-chain/off-chain

Atomic swaps can be made directly between different blockchains (on-chain) or affected outside of the blockchain (off-chain). Every on-chain atomic swap uses a hashed time-locked contract (HTLC). The exchanged currencies must support HTLC and have the same hash algorithm. HTLC is a smart contract for an agreed amount of cryptocurrency that uses hashlocks and timelocks providing a one-way encryption with a determined result. As for off-chain atomic swaps, they take place using an off-chain open channel between the parties. The first atomic swap of this kind took place between Litecoin and Bitcoin with the use of Bitcoin Lightning Network instead of blockchain.

A closer look

All atomic swaps have two stages:

1. Order matching: on this stage the parties must agree on transaction conditions in order to enter an atomic swap.

2. Order execution: the amount of cryptocurrency is sent to a predetermined wallet after providing the hash within the given time frame, than the receiver either acknowledges receiving the agreed amount of crypto prior to a deadline by generating cryptographic proof of payment or the sent amount returns to the sender.

Let’s explore an example of an atomic swap between Bob and Eric where Bob has a certain amount of BTC and wants to exchange it to ETH with Eric:

Step 1: The first thing Bob and Eric have to do is to agree on the exchange value.

Step 2: After that Bob generates a hash using his private key and sends it to Eric. He also generates a pre-image of the hash.

Step 3: In response Eric generates his own hash using his private key and sends it to Bob and also generates a pre-image of the hash.

Step 4: As soon as Bob receives Eric’s transaction he signs it by using the same original key he has in the form of pre-image. Eric does the same with Bob’s transaction.

After all these steps are fulfilled the transaction is done. But in case one of the parties doesn’t sign the transaction for some reason or use an incorrect key, the transaction won’t be fulfilled.

Pros and cons

Atomic swaps have quite a lot of advantages over traditional crypto exchanges. Due to their strengths they can significantly facilitate cryptocurrency exchange between the parties and increase liquidity of cryptocurrency payments.

➕ P2P exchange

➕ Instant transactions

➕ High level of security

➕ Low cost

➕ Increased privacy

Still, atomic swap technology is quite a new thing and there are some limitations creating barriers to its mainstream adoption.

➖ The process of agreeing on the value isn’t automatic and can be difficult due to high volatility of cryptocurrencies

➖ The exchanged currencies must have the same hash algorithm and support time lock contracts

➖ Quite a few cryptocurrencies and cryptocurrency wallets can currently support atomic swaps

➖ There are problems with handling big volume of data

🔍 Up to date there are quite a lot of services and exchanges allowing their users to exchange crypto with the use of atomic swaps. Here are some of them:

✔ Altcoin.io

✔ Komodo

✔ Lightning Labs

✔ Swap.online