How Do Atomic Swaps Work?

Atomic Swaps are arguably the ultimate goal for crypto trading. But what are Atomic Swaps exactly? Since the development and release of Bitcoin, cryptocurrencies have become a part of the cultural lexicon. Ten years down the line and there are hundreds of different projects, with applications and functionalities across a seemingly endless list of use cases. However, they are not perfect.

One of the issues that has continued to receive attention from the crypto community is the need for centralized exchanges. A fundamental tenet of cryptocurrencies is the idea of a trustless, decentralized architecture. Yet in order to buy, sell and trade crypto a trusted third party is often involved. This conflict in ideology and functionality has led to the development of different ways of conducting trades and transferring tokens. One of the more interesting of these solutions is Atomic Swaps. Here we will examine this technology and some of the projects that utilize Atomic Swaps and what the implications are for the cryptosphere as a whole.

An Imperfect Landscape

As mentioned above, since Bitcoin’s introduction of cryptocurrency to the world, the majority of transactions have taken place on centralized exchanges. In this scenario, users grant access to their funds to a trusted third party, that acts as an intermediary for transactions. These exchanges also function as networks for users to find each other in order to further facilitate crypto trading.

Centralized exchanges have become the de facto financial institutions—the banks—of the crypto world. While many in the community understand the benefits of these centralized networks, there are many who feel that these exchanges hold too much power and that they have become a form of authority and insecurity that flies in the face of Satoshi’s trustless vision.

Centralized exchanges are also subject to many of the same problems traditional banks have. These exchanges can fall victim to cyber-attacks that can put users’ funds at risk as well as suffer from mismanagement and government regulations depending on where they are located. Add to this the disjointed nature of the ecosystem—i.e. not all exchanges support every trading pair—and it is easy to understand why an alternative is attractive.

Thankfully, now there are more options for crypto enthusiasts.

What Are Atomic Swaps?

Another type of exchange exists, decentralized exchanges, which as the name implies, do not use third parties. If there is no intermediary that can be trusted to facilitate trades, how do they work? One method for trading on decentralized exchanges is through Atomic Swaps.

While there are some disputes, it is widely accepted that the term was first coined in 2013 by Tier Nolan in online crypto forums. However, they did not become widely recognized until around 2017 when the founder of Litecoin, Charlie Lee, executed a successful Atomic Swap of Bitcoin and Litecoin. Since then, interest in this new and different means of exchange has continued to grow.

Smart Contracts & Atomic Swaps

Atomic Swaps make use of smart contract technology, the revolutionary protocols made famous by the Ethereum network. Smart contracts are programmable computer protocols that can be designed to facilitate a practically endless variety of functions: everything from enforcing online gambling rules to blind auctions can utilize smart contracts. These protocols are incredibly useful and form the backbone of Atomic Swap functionality.

These trustless transactions utilize a specific type of smart contract called Hash Timelock Contracts, or HTLCs. As the name suggests these contracts use cryptographic hash functions to operate. Hash functions are a key component of most crypto projects, and are basically complex mathematical problems that serve as a means of verifying some piece of data. In the case of HTLCs, this hash function contains a time-sensitive component that ensures that a transaction is completed within a specific time frame in order for it to be successful.

Next let’s take a look at how to execute Atomic Swaps.

How To Make An Atomic Swap

We will start with an example. Let’s say that Tom and Jerry have tokens they would like to exchange: Tom has BTC and Jerry has Litecoin. The first step is for the initiating party to create an HTLC address and deposit coins into it: In this case, Tom creates the address and drops 1 Bitcoin inside. A unique passcode called a preimage is created for this address with an associated cryptographic hash. This all takes place on the BTC blockchain.

Once the tokens are deposited in the address, Tom sends his hash to Jerry, who then creates his own address using this same hash. Jerry then deposits his LTC into his new address on his respective blockchain. Now that both Tom and Jerry’s tokens are ready to be swapped they can make the exchange. In order for Tom to retrieve his new LTC, he uses the preimage as a key to open the hash lock. Once the preimage is used it is shared on the blockchain so that Jerry is able to use it to access his new Bitcoin. Both parties now have their new tokens and the transaction is complete.

How Do They Work?

This is where the term “Atomic” comes from. In crypto terms, Atomic refers to a transaction that either fully executes, or not at all. There is no way for Tom to access Jerry’s Litecoin without automatically providing the key for Jerry to retrieve his Bitcoin. This is also where the “time lock” in HTLC comes in to play: if Tom doesn’t retrieve the Litecoin within 24 hours—and thus provide Jerry with the preimage—the entire trade is nullified and both users retain their tokens. As you can see these transactions are inherently safe based around the terms of each contract.

Another important feature offered by some services is the ability to conduct off-chain Atomic Swaps. In the case of these off-chain transactions, functionality is achieved using a second layer, hence “off-chain”. These types of Atomic Swaps are practically identical in how they function to on-chain swaps; however off-chain swaps differ slightly in that they use second-layer payment channels as a means to communicate between the users.

When conducting on-chain swaps users must wait for miners to confirm both transactions just like any other operation on the blockchain. Often, this means extended wait times. Off-chain swaps use HTLCs to execute trades, with only the end result of all the transactions being written to the blockchain, saving valuable time and opening the door for more complex functionality in these smart contract swaps. Thanks to their speed they are a preferred method for smaller, interpersonal trades.

What Coins Have Atomic Swaps?

Now that we have a basic understanding of how this technology works, we will examine a couple of the exciting projects taking advantage of Atomic Swaps. These Atomic Swap coins utilize this method of trading in some way and are paving the way to further adoption and development of the technology.


A good project to start with is Komodo. They have been instrumental in the development and adoption of Atomic Swap technology and are worth a closer look.

After Tier Nolan started throwing the idea and term Atomic Swap around message boards, the Komodo team was one of the first groups to take notice and proceed with further research. Some of the first swaps were possible thanks to Komodo’s lead developer, jl777, writing the required code.

Soon after, Komodo developed BarterDEX, the first platform allowing for an Atomic Swap marketplace and ecosystem where they incorporated Bitcoin-protocol coins and facilitated thousands of Atomic Swaps. Since then their team has continued to innovate, eventually adding ETH and DOGE to their supported pairs. As of March 2018, Komodo supported over 90% of all available crypto pairs on BarterDEX, with over 100,000 Atomic Swaps having already been completed using the exchange.

How Komodo Works

Komodo is straightforward in how it functions. Let’s take a look.

Tom and Jerry are back and want to make another trade from Komodo tokens to BTC, this time using BarterDEX on the Komodo platform. First, Tom will place a trade order on Komodo’s DEX to find an interested party. Jerry sees Tom is looking to trade KMD for BTC and accepts the offer. Next Jerry will commit to the transaction by paying 0.15% of the total amount as a transaction fee: once the fee is paid the swap begins.

Tom then pays a transaction fee to secure the address. After Tom has secured the address Jerry sends his BTC and waits for him to complete the transaction. Once Tom sends his KMD to another address the swap is done and both users collect their tokens. As this is an HTLC Atomic Swap, if any portion of the process is not completed in the allotted time frame the entire transaction is scrapped and both parties are returned their tokens.

Komodo is an interesting project that has played an integral role in developing these protocols and is worth further investigation for anyone interested in Atomic Swaps.


Another interesting project developing in the world of Atomic Swaps and decentralized exchanges is 0x. In the simplest of terms 0x is an open protocol that facilitates decentralized crypto exchanges. This protocol is a message format built on the Ethereum blockchain that allows users to interact and exchange tokens without the need for a trusted third party.

This message format is basically just a data package that sets the parameters for each trade. This data package indicates what tokens will be traded by each party, what prices and the expiration time for the transaction as well as identifying specific trading partners. Initiating parties set these trade parameters and then verify them by “signing”. Anyone interested in participating in an order can use 0x smart contracts to execute the trade.

What Makes 0x Unique

One interesting aspect of the 0x process is the use of “relayers”. In the 0x ecosystem, relayers are dApps that basically act as aggregators of orders: when someone wants to make a trade, their signed order will be posted to the relayer of their choice, where it is then visible to the larger pool of 0x participants. These relayers are built by developers on top of the 0x protocol and serve multiple purposes, the biggest being the increase in the speed of transactions. These relayers allow for off-chain swaps that keep transaction times down. The open-source nature of these dApps means users can find relayers that are better suited to their individual needs.

Let’s use another example to illustrate a 0x trade.

Tom creates an order on 0x which is then picked up by a relayer of his choosing where it is sent to the order book database. It can also be shared to other relayers to present the order to a larger audience. Jerry sees the order and wants to make a trade. The relayer matches both sides of the trade and it is sent to a 0x smart contract for completion. These smart contracts deduct the funds from their wallets and the order is verified and written to the blockchain.

The native token ZRX is used to pay for all transaction fees and associated fuel costs.

0x is an interesting project that has achieved a high level of liquidity and functionality for their market. However, it is important to note 0x greatest weakness: the 0x protocol only works with Ethereum assets, which severely limits its appeal to many crypto enthusiasts. While 0x works well for what it is, this myopic focus ensures it will never become the industry standard with addressing the issue.

Market Implications

As we can see Atomic Swaps have huge potential in reorganizing the crypto ecosystem. Decentralization has always been at the center of the ideals of cryptocurrency, despite the practical limitations. Issues of complexity gave rise to the use of centralized exchanges, with the community favoring functionality over philosophy. The continued development of Atomic Swaps pushes back against this centralization.

Eventually, Atomic Swaps and decentralized architecture could replace traditional exchanges, putting the power to trade back in the hands of individual users and slow down the consolidation of power we have seen in the industry.

While there is major potential for Atomic Swaps to continue to increase decentralization, at this point, there are a number of hurdles in the way. Tokens must have the same hash algorithm to utilize Atomic Swaps, as well as being HTLC compatible. Not all wallets accommodate these swaps, hampering further widespread adoption. Future protocols will also need to increase their handling capacity as the projects now are best suited for small scale transactions.

With a growing base of Atomic Swap coins already using this technology, there is no doubt that Atomic Swaps will continue to change, evolve and become more refined. It is just a case of waiting to see how they impact the ecosphere as a whole.



Stay up to date with the latest on KuCoin

Join KuCoin Today


Mironichev, E. (2019). Top-5 Smart Contracts And How To Use Them. Retrieved from:

Reiff, N. (2019, June 25). What Are Centralized Cryptocurrency Exchanges? Retrieved from:

Peaster, W. (2019, July 26). The Best Decentralized Exchanges For Cryptocurrency Trading. Retrieved from:

Komodo. (2019). The Industry’s Only Truly Decentralized Exchange: AtomicDEX. Retrieved from:

0x. (2019). Powering Decentralized Exchange. Retrieved from:

Sign up our newsletters for the latest creative news, projects and more delivered straight to your inbox