What are Atomic Swaps?

The terms “new” and “in development” tend to be thrown around a lot when explaining certain systems within the cryptocurrency sphere. It only makes sense, considering that cryptocurrency itself is no more than a decade old. The blockchain industry players are constantly churning out newer functions and technological designs. But there is one particular protocol where you can take the terms “new” and “in development” quite literally. Despite the seeds being planted a little over five years ago, it only now being fully realized. This budding form of technology is a system known as ‘atomic swaps.’

Because it’s so early in the game, some people may be hesitant to embrace atomic swaps. This is mainly due to the common misconception that something is still developing, it can’t be fully functional. But these crypto-swaps provide promising benefits for all traders that deserve to be given attention.

What are Atomic Swaps?

Atomic swaps utilize smart contract technology. This allows for the exchange of one cryptocurrency for another without the use of centralized intermediates. They take place between blockchains of differing cryptocurrencies. Alternatively, they can be conducted off-chain and away from the blockchain.

‘Smart contracts’ are self-executing digital contracts with the terms of the agreement between the buyer and the seller written directly into the lines of code. The agreement and any other data associated all exist across a decentralized blockchain network, so there is no need for a middleman participant.

Atomic swaps came into existence – and prominence – in September of 2017, following a Litecoin atomic swap with Decred.


Decred (DCR) is an autonomous cryptocurrency that is open-source and whose function is entirely blockchain-based. Its network operates on the ‘proof of activity’ concept. This protocol amalgamates the two most commonly used algorithms: ‘proof of work’ (POW) and ‘proof of stake’ (POS).

Litecoin is an open-source software that works with a peer-to-peer cryptocurrency. It’s also a decentralized system with a blockchain that can handle higher volumes of transactions when compared to Bitcoin.

Following this exchange, atomic swaps have garnered a massive amount of attention and are being used by other systems. One of these systems is Lightning Labs, a startup that uses Bitcoin’s Lightning Network (more on that later) for their transactions. Lightning Labs uses this swap technology for off-chain swaps. Other cryptocurrencies that utilize this technology are Ox and Altcoin.io.

The Origins

Before we go into how atomic swaps work, let us explore the timeline of how they developed. Then we can discover what led to them being a highly-regarded form of budding technology.

The first draft of this ‘trustless’ exchange custom was created in July of 2012 by a developer named Sergio Demain Lerner. It was an interesting idea, but as it was not fleshed out, that is all it was: an “idea.” It was not until May of 2013 when the first full account of an atomic swap procedure was provided by Tier Nolan. He would go on to be credited as the true inventor of the atomic swap.

At this point, the atomic swap was still nothing more than a concept. No proper code for this particular system had been written quite yet and the first atomic swap would not occur until one year later.

The First Atomic Swaps

The code initially only allowed atomic swaps to be between NXT assets, but soon after, a method was developed to grant the exchange of NXT assets with Bitcoin. It was later extended to support atomic swaps between any type of Bitcoin-protocol coins.

Early evidence of the ‘work in progress’ atomic swaps existed only in chat forums. Not surprisingly, many of the first swaps were performed through a command line interface between developers who were testing out the up and coming technology.

In the summer of 2017, BarterDEX rolled out its atomic swap-powered trading market. They initiated the integration with multiple Bitcoin-protocol coins by Komodo. Soon after they began to publicly perform thousands of atomic swaps on BarterDEX. Later that same year, atomic swaps gained traction thanks to supportive tweets from Litecoin founder, Charlie Lee.

How Do Atomic Swaps Work?

The typical exchange is time-consuming, complex, and delicate. We don’t have the capabilities to support all the different kinds of exchanges. They may have to go through a conversion process between intermediate coins, just to be able to exchange them. This problem is where recent atomic swap technology comes in. The scheme solves this by using a system called Hash Timelock Contracts (HTLC).

An HTLC is a time-bound smart contract involving all parties. It includes the generation of a cryptographic hash function which can be easily verified amongst them. Atomic swaps require the validation of all parties concerning the receipt of funds within a specified timeframe through the use of a cryptographic hash function. Failure to confirm the transactions from one of the parties within the stated timeframe results in the entire transaction becoming void. In that case, no funds are exchanged.

This cardinal rule and action assists in the system’s removal of any counterparty risk.

There are two ways of explaining the process of how atomic swap transactions work. One is more concise than the other. Investopedia editor, Jake Frankenfield, provides this straightforward explanation:

Explanation #1

Suppose Alice is a trader who wants to convert 100 Bitcoins to an equivalent in Litecoins with Bob. She submits her transaction to Bitcoin’s blockchain. During this process, Alice generates a number for a cryptographic hash function to encrypt the transaction. Bob repeats the same process at his end by similarly submitting his transaction to Litecoin’s blockchain.

Both Alice and Bob unlock their respective funds using their respective numbers. They have to do this within a specified timeframe or else the transfer will not take place. Atomic swaps also have a utilization in conjunction with a lightning network to conduct off-chain exchanges

Explanation #2

The second explanation – provided by Komodo – is significantly more detailed. For the purpose of keeping this illustration simple, we will use a scenario in which two participants wish to make an exchange. Let’s say that Trader #1 has BTC (Bitcoin) and they want to exchange it for KMD (Komodo). Trader #2 possesses KMD and wishes to swap it for BTC. Trader #1 posts a trade order on Komodo’s DEX and once that is ready to go, the swap process can begin.

The Atomic Swap Process – Six Steps

  1. Trader #2 sees the posted offer and accepts it, committing to the trade by paying the atomic swap fee that only measures to 0.15% of the total trade amount. The purpose of this fee’s presence in the procedure is to make sure that Trader #2 and all other users do not spam the network with any rapid requests. This transaction fee must be a separate UTXD (the unspent output from Bitcoin transactions) from the one that Trader #2 will ultimately swap with Trader #1.
  2. Trader #1 will then send a deposit of the funds to a secure address. Atomic swaps have a decentralized nature. So no one will have access to these funds until the trade either times out or is complete. This includes Trader #1, Trader #2, and any administrators belonging to a third party. Trader #1’s deposit must be 112% of the order of the original order. Whether the atomic swap fails or it is complete, Trader #1’s deposit will definitely go back to them. All this deposit does is remove any and all incentives to cheat the swap.
  3. Trader #2 then sends their KMD to another secure address. Just like with the address Trader #1 sent their funds to, absolutely no one has the ability to access these funds until the swap process comes to an end. If the trade were to fail at this point for some reason, then the swap would time out and cancel out. Following the cancellation, Trader #1’s BTC deposit releases. Then it goes back into his custody, as would Trader #2’s KMD deposit.
  4. Trader #1 sends in their BTC payment to Trader #2, which completes their end of the deal. If you remember, this sum of BTC is separate from – and additional to –  the deposit of BTC that had been paid back in step 2, and now Trader #2 is able to claim Trader #1’s BTC payment.
  5. Trader #2 can now accept Trader #1’s BTC payment. Once it has been officially claimed, Trader #1 is granted the ability to claim ownership of Trader #2’s KMD payment.
  6. Trader #1 is finally able to accept Trader #2’s KMD payment. By this stage, both participating parties have now obtained the funds that they desired and the atomic swap has successfully been completed.

The Atomic Swap is Complete

Once both parties exchange their funds, Trader #1 may reclaim his deposit of BTC. And with that, the atomic swap process has officially come to an end.

The design of the entire swap procedure provides all those involved with enough stimulus to move onward to the next step and so on in the trade. As it is an ‘atomic’ process, this means that one of these two end results will occur. Either:

  1. The swap goes forward exactly as all traders involved agreed and want it to, or
  2. Nothing takes place and/or the trade does not pan out as the traders agreed and their funds go back to them, excluding the atomic swap fee.

A brief look at “Lightning Network”

Regarding systems that have incorporated atomic swaps into their technology, there’s a brief reference to Lightning Labs. They use a protocol called a ‘Lightning Network’ for their transactions. It’s important to know that this network actually plays a role in how atomic swaps operate. That being the case, it would be criminal not to provide context into what it is and why it is so significant. Its importance lies not just with atomic swaps, but with Bitcoin in general.

The Lightning Network is a form of second layer technology for Bitcoin that harnesses the use of micropayment channels to measure the capability of its blockchain to conduct transactions. By rooting through transactions and subsequently removing them, the lightning network’s main purpose is to clear up Bitcoin and reduce – “decongest” it, if you will – the transaction fees.

How the Lightening Network is Key for Atomic Swaps

This network is the key element that allows atomic swaps to function. It’s what enables the exchange of one certain cryptocurrency for another.

As Bitcoin’s lightning network is still in its infancy (not unlike atomic swaps themselves) and susceptible to drawbacks and inevitable development, there are a few noted problems to the general network.

  1. While it claims to be the solution to Bitcoin’s infamous transaction fee issue due to transaction congestion, this network does not solve it in its entirety. Compare this problem to Dash, which uses a series of free software plug-ins for merchants to download. These in turn offsets the costs of adding it to their methods of payment.
  2. Nodes on the lightning network have to be online at all times. This requirement results in the nodes becoming vulnerable to hacks and thefts. Going offline does not fare any better. Because, according to Thaddeus Dryja (co-writer of the Lightning Network white paper), there is the possibility that one of the parties in a payment channel can close the channel. Then that party could pocket the funds unbeknownst to the other parties.
  3. The lightning network’s arrival and implementation ideally will reinforce Bitcoin’s complete success as a transaction medium. However, it might not solve Bitcoin’s network effects issue. The increase in the system’s transactions volumes, due largely in part to the rise in trading volumes, means the lighting network’s reduction on transaction fees may be limited.

Cryptographic Hash Functions

Along with the Lightning Network, an additional key requirement for an atomic swap is that the blockchains must share the same cryptographic hash function, such as SHA-256. This will allow for the hash-time locked contract to function properly when the time comes for the user to provide the number from the hash function.

Limitations of an on-chain atomic swap are:

  • Both currencies in the exchange absolutely need the same hash algorithm.
  • Both currencies need to support the time lock contracts.
  • At this point in time, all involved individuals need specific programming skills in order to use atomic swaps.

These limitations result in commonplace hesitance and resistance towards adopting atomic swaps into the mainstream. This is why Lightening Network-powered atomic swaps that are off-chain are in testing now for mainstream consumption. This aims to solve the problems and conquer any of the limitations pertaining to on-chain atomic swaps.

Benefits of Atomic Swaps

Atomic swaps have a lot to offer in terms of efficiency, security, and above all, reliance. In spite of the aforementioned limitations associated mostly with on-chain swaps, there are plenty of benefits to the system:

  • Users do not have to give up their ‘private keys’ at any time. When you are trading through atomic swaps, you are always in possession of your private keys (and by extension, your coins and tokens). Additionally, you never have to relinquish the control of your funds to a third party.
  • The technical design of atomic swaps ensures that the swap takes place. It also makes sure the parties participating receive the funds they desire. Otherwise, nothing happens and the parties each retain their original funds (minus a small transaction fee intended for the “order-taker”). This establishes as much security and reliance as possible when it comes to crypto-trading.
  • Atomic swaps are a lot cheaper than conventional trading on centralized exchanges. Most centralized exchanges charge fees of 0.2% of every transaction for each party involved in the trade. In addition, a good chunk of the exchanges also charges a fee to withdraw funds.
  • Atomic swap’s design allows the users to trade between a wider variety of coins and tokens. An example of that would be that someone with a BTC-based altcoin can directly trade it in for an ERC-20 token. Before the Komodo platform made this function possible, a trader would have to go through a tedious and strenuous process of making multiple exchanges just to get the same effect. The trading procedure would have gone as follows: “BTC-based altcoin—>Bitcoin—>Ether—>ERC-20 token.” Moreover, a fee for each of the transactions is part of the final cost as well. With the atomic swap tech on BarterDEX, a user can go directly from BTC-based altcoin to ERC-20 token (or vice versa if the situation calls for it).

Connecting to the final benefit, in February of 2018 the Komodo platform became the first project to bridge the hefty gap between Bitcoin-protocol-oriented coins and Ethereum-based ERC-20 tokens. Atomic swap technology has made this otherwise unorthodox integration possible.

What the future holds

Komodo describes the influence atomic swap technology has had on cryptocurrency by saying each blockchain was like “an island.”

“…with only one bridge off: to either Bitcoin (for BTC-protocol coins) or Ether (for Ethereum-based ERC-20 tokens). Once on the larger islands of BTC and ETH, traders had more bridges to choose from. However, every other bridge just led to another isolated island with only one exit option.

Komodo’s atomic swap technology builds bridges between 95% of all the coins and tokens in existence. As a result, traders will never be stranded on a small blockchain island ever again. This is the first stage of blockchain interoperability.”

This technology is gradually building bridges that will bestow upon its users the freedom of exchanging diverse funds and connecting differing coin types.

First Stages of Interoperability

The most interesting aspect, aside from the continuous efforts on behalf of atomic swaps to maintain the process of building proverbial bridges, is that Komodo says that this is only the first stage of ‘blockchain interoperability.’ The next stage is cross-chain transaction proofs and fungibility (a factor that is greatly associated with Monero cryptocurrency). With the rapidly developing “Cross-Chain Smart Contract” technology, exchanges that can take place between two chains without the need for a swap or a trade occurring.

Overall, this new technology will further construct ‘blockchain interoperability.’ It will also provide those who use it with two primary benefits. The first being that if a project launches a blockchain – specifically on Komodo – and one of the chains is no longer sufficient enough to handle the needs of the project, supplementary chains can then be created and synchronized with the first.

Why Cross-Chain Smart Contracts are Important

The cross-chain smart contracts make this operation possible. This is due to their ability to permit numerous blockchains to interact with one another. Inevitably, they function as a single chain. As a singular project’s demands increase, they can add additional chains to keep the performance from falling behind. Repating this process is possible by including chain after chain if one in particular does not work out.

The second advantage stems from Komodo’s ‘MoMoM scaling solution technology’. It distributes the perk that any chain on the Komodo platform can verify transactions that have been put into action on any other chain in the ecosystem. These specialized smart contracts allow a smooth transfer of value between the chains. What makes it complete ‘blockchain interoperability’ is when the coins leave one chain while the value appears on a totally different chain.


Atomic swaps are an ever-growing system that is pushing the envelope in cryptocurrency transactions. It provides a stable operation that is simple to use – in comparison to most other transaction procedures – and breaks the boundary that is the exchange of tokens and coins conceived in separate platforms. As briefly touched upon in this article’s introduction, it would be so easy to dismiss a technology this young out of a strong hesitance regarding its dependability and worth. This response is exceedingly inappropriate for such an innovation like atomic swaps.

It is refreshing to encounter a cryptocurrency function like atomic swaps where the positives outweigh the flaws. Still, it remains under development. Many people consider this ttechnology to be a mere stepping stone towards a larger, more outstanding system in crypto technology. From the looks of it, we are surely in for something monumental.