Home » Blockchain » Guide to Atomic Swaps: What are Atomic Swaps & How Does it Work?

This guide to atomic swaps takes a look at an exciting innovation in the cryptocurrency space, with a simplified explanation on what are atomic swaps.

atomic swaps, atomic, swaps, what are atomic swaps, guide to atomic swaps

It is no surprise that the surging popularity of cryptocurrencies are fueling an increasing number of coins and tokens being created. In fact, there are more than 2,000 coins and tokens in the cryptocurrency market with many new projects being created every single day! Blockchain-powered technology has the potential of disrupting a wide-range of industries, with a specific focus on the financial markets.

Currently, cryptocurrency exchanges are an important intermediary in facilitating cryptocurrency trading and exchange between buyers and sellers. If you’re keen on getting some cryptocurrency, you’d have to go through an exchange with a good degree of liquidity like Coinbase or Binance. Once you’ve done so, the next step in securing your coins is to transfer your coins into a cryptocurrency wallet for safekeeping. While the general cryptocurrency market is evolving progressively, many new challengers are constantly presenting themselves. One of the main limitations of blockchain technology is scalability.

(See also: Guide on Identifying Scam Coins)

What is Scalability?

Scalability is defined as the capability of a system or network to expand in size and manage a growing number of transactions. With greater adoption and usage, any system or network will need to be enlarged to accommodate and support that growth. There are limits on the amount of transactions that a blockchain can process. For instance, Bitcoin can only process 7 transactions per second while Visa can handle up to 24,000 transactions per second.

atomic swaps, atomic, swaps, what are atomic swaps, guide to atomic swaps

As we speak, many projects and developers are working hard to solve the scalability issue. Some of these solutions include sharding, lightning network and our topic of interest, atomic swaps. This guide will focus on atomic swaps and how the technology tries to solve one of the biggest issues of blockchain.

(Read also: Bitcoin Vs Bitcoin Cash Scaling: Why Lightning Network is More Expensive than Bitcoin Cash)

What are Atomic Swaps?

An atomic swap is a peer-to-peer (P2P) exchange of cryptocurrencies from one party to another without going through a third party (e.g. cryptocurrency exchange). This allows you to exchange one cryptocurrency for another without using exchanges. The best part about the entire process is that users would have full control and ownership over their private keys throughout the entire swap process.

Private keys are proof that you own your coins. If you do not hold your private keys, you technically do not own the coins!

The atomic swaps can either be directly executed between separate blockchains with different native coins or via off-chain channels that are offshoots of the main blockchain. The first known successful implementation of atomic swaps was executed between Decreed and Litecoin in September 2017.

Another term for atomic swaps is cross-chain trading, since it facilitates a cryptocurrency exchange between 2 separate, independent blockchains.

The idea of atomic swaps was first described in 2013 by Bitcointalk user Tier Nolan. Since then, a tremendous amount of work, innovation and collaboration has been undertaken to make this a reality.

(See also: Category of Cryptocurrency Market: Pure Cryptocurrency)

Why are Atomic Swaps Important?

Atomic swaps represent an innovation that is much needed in the cryptocurrency space due to the following factors:

  • Removing the Need to Trust Intermediaries: Anyone looking to trade or exchange cryptocurrencies usually goes through big, centralized exchanges since they’re extremely efficient, user-friendly and boasts high liquidity that makes cryptocurrency trading much easier. However, the downside is that you have to TRUST the exchange in handling your funds. There will always be a risk of hacking, manipulation and moral hazards that may result in the loss of your funds. After all, Bitcoin – the founding father of cryptocurrencies – was created to eliminate intermediaries and third parties, ensuring that users had absolute control of their funds.
  • Inefficient Trading Process: There are many coins and trading pairs that aren’t supported by cryptocurrency exchanges, thereby requiring users to create different exchange accounts across many different cryptocurrency exchanges. This is extremely inefficient since users need to migrate to different accounts for different trading pairs or make several conversions before acquiring the intended coin.
  • Complexity of Decentralized Exchanges: Decentralized exchanges (DEXs) are a new genre of cryptocurrency exchanges that tries to address the risks of centralization of exchanges by allowing users to trade directly (peer-to-peer) and transparently using a blockchain. However, DEXs can be complex for the average users to use due to their complicated-looking user interfaces. Moreover, DEXs can be much slower than centralized exchange since every transaction is broadcasted onto the blockchain, which are themselves facing scalability issues.

Atomic swaps are therefore an important tool that facilitates trustless and efficient exchange of cryptocurrencies, solving various issues of the fragmented cryptocurrency market.

(Readmore: Will A Crash in Bitcoin’s Price Lead to Its Demise?)

How it Works

Atomic swaps enable users to exchange different types of cryptocurrencies instantaneously without any third party or escrow services. In order to understand how it works, let’s take an example where Frodo has 1 Ether (ETH) and he wants to swap with Sam, who has 5 Litecoin (LTC).

atomic swaps, atomic, swaps, what are atomic swaps, guide to atomic swaps

Step 1: Creation of Smart Contracts

In order to start the atomic swap process, a special type of smart contract called Hash TimeLock Contract (HTLC) must be created. HTLC is similar to a safety deposit box that requires special keys. A HTLC has two important features:

  1. HashLock: A hashlock is a cryptographic key that allows users to access funds only when both parties have signed off on each of their transaction.
  2. TimeLock: A timelock is a safety mechanism that ensures both parties will be automatically given back their funds if the exchange isn’t successful under a specific time duration. It acts sort of like an insurance policy.

Frodo will initiate the atomic swap process by creating a HTLC contract address and depositing his 1 ETH into the contract address on the Ethereum blockchain. When Frodo creates the smart contract, a secret passcode (called ‘preimage’) will be generated. This secret passcode will go through a hash function, thereby generating a hashed value (also called ‘hash’).

atomic swaps, atomic, swaps, what are atomic swaps, guide to atomic swaps

Hashing is a process of converting a string of values to a shorter, fixed-length value. In this case, the secret passcode will go through a ‘one-way’ hash function and be converted into a ‘hash’, which is basically random text to our eyes.

In the context of a safety deposit box, the hash is similar to the lock while the original preimage (secret passcode) is the key. After generating the hash, Frodo will send it to Sam. It is called a one-way hash function since converting the passcode to the hash is simple but converting the passcode from the hash is impossible. Therefore, Sam cannot unlock the funds unless Frodo gives him the secret passcode.

(See also: Guide To Cryptocurrency Valuation: A Look into On-Chain Data)

Step 2: Creation of 2nd Smart Contract on A Different Blockchain

atomic swaps, atomic, swaps, what are atomic swaps, guide to atomic swaps

After receiving Frodo’s hash, Sam will verify Frodo’s smart contract that contains 1 ETH by looking at the public blockchain. Once Sam has verified it, he can then create a separate contract address on Litecoin’s blockchain with the same hash previously used. Sam will need to deposit 5 LTC into the contract address that has the same passcode (key) as Frodo’s first contract. Since both smart contracts share the same hash, both transactions are locked together and are dependent on each other.

Step 3: Unlocking the Coins

In order for the coins to be unlocked, Frodo must initiate the process by using his initial secret passcode to unlock the funds (LTC) that Sam has sent him. Once that has been executed, the passcode (preimage) will be publicly broadcasted to the blockchain and Sam can therefore use the public passcode to unlock Frodo’s 1 ETH, since the same hash was used to lock both smart contracts.

Atomic swaps avoid the risk of another party leaving with your funds. Since atomic swaps are based on smart contracts, the locked funds will not be released until all the conditions have been met. When an atomic swap contract is open, both parties must receive their coins. An added advantage is that minimal fees will be charged for atomic swap transactions.

(Read also: Guide to Cryptocurrency Liquidity: Understanding Liquidity & Its Importance)

Benefits of Atomic Swaps

Here are the main benefits of atomic swaps:

atomic swaps, atomic, swaps, what are atomic swaps, guide to atomic swaps

  • Decentralization: All transactions will be secured and openly recorded on the blockchain. Atomic swaps transactions will enjoy the advantages that open-source decentralization enables: immutability, transparency and security.
  • Absence of Intermediaries: Unlike centralized cryptocurrency exchanges where counterparty risks exists, users need only a compatible wallet to start using atomic swaps without the need to trust any intermediaries. With atomic swap technology, users stay in total control of their funds and trades are settled directly between users.
  • Blockchain Interoperability: Users can exchange coins directly from two different blockchains. This is a progressive step towards a collaborative and integrated blockchain experience that will reduce friction in the market.
  • Fair Trading: Since orders are created and transmitted directly between two parties, transactions will not be influenced by external parties that can manipulate the markets. Participants interact directly with one another without fear of being taken advantage of by automated, low-latency trading strategies.

(See more: Crypto Beginners Guide: 5 Things Crypto Newbies Should Know)

Progress of Atomic Swaps

Lightning Labs – a company focused on blockchain solutions – announced the first successful implementation of cross-chain atomic swaps between Bitcoin (BTC) and Litecoin (LTC) back in November 2017. Since then, Litecoin has been successfully completed atomic swaps for other coins that include Decred (DCR) and Vertcoin (VTC). There are also other projects that are making progress with atomic swap technology such as Komodo.. Komodo has successfully completed atomic swaps with Electrum servers and are also building their own decentralized exchange called BaterDex. Up to date, Komodo has successfully conducted over 100,000 successful atomic swaps.

With regards to cryptocurrency exchanges, there are several projects that look to integrate atomic swap technology. Altcoin.io, for example, is building a decentralized exchange and wallet with built-in atomic swap features while hybrid (party centralized) exchanges such as Lykke are looking to leverage on atomic swaps.

(Read also: Guide to Valuing Cryptocurrency: How to Value a Cryptocurrency)

Limitations of Atomic Swaps

Here are some current limitations of air swap technology:

  1. Slow: Atomic swap technology is still being refined and lots of enhancement needs to take place before atomic swaps become fast enough to handle large volumes of transactions. Lightning Network is one of the innovations that has the potential to facilitate instant atomic swaps transactions.
  2. Lack of Compatibility Support: Not all wallets and exchanges allow the ability for a user to partake in an atomic swap at the moment. Newer wallets are beginning to adopt atomic swap technology, but greater support needs to come via large established wallets and exchanges that has a significant user base.
  3. Needs Smart Contract Functionality: Atomic swaps technology can be implemented only in blockchains with smart contract functionality. Therefore, coins that are built on blockchains that do not support smart contracts cannot leverage atomic swaps.

Summing it up

The concept of atomic swapping has made an impact in the cryptocurrency trading space. You no longer need to trust a trading platform with your coins, nor would you need to create multiple accounts across different exchanges to trade coins. With continued innovation, the technology of atomic swaps will allow us to streamline trading in decentralised exchanges, focusing on user-friendliness and convenience for the masses. With greater development on the technology, expect more wallets, exchanges and coins to integrate support for this interesting technology.

(You might also be interested in: Bitcoin vs Alt Coins Returns: Comparison of Gains Between Bitcoin & Altcoins Investing)

Beneficial Resources To Get You Started

If you’re starting your journey into the complex world of cryptocurrencies, here’s a list of useful resources and guides that will get you on your way:

atomic swaps, atomic, swaps, what are atomic swaps, guide to atomic swaps

Trading & Exchange


Read also: Crypto Trading Guide: 4 Common Pitfalls Every Crypto Trader Will Experience and Guide To Cryptocurrency Trading Basics: Introduction to Crypto Technical Analysis.

Enroll in our Free Cryptocurrency Webinar now to learn everything you need to know about crypto investing.

Get our exclusive e-book which will guide you on the step-by-step process to get started with making money via Cryptocurrency investments!

You can also join our Facebook group at Master The Crypto: Advanced Cryptocurrency Knowledge to ask any questions regarding cryptos!