How-To Guides: Advanced

A Guide to Atomic Swaps: Everything You Need to Know

By Jinia Shawdagor | August 31, 2021

Even though atomic swaps are yet to be tested on a broader scale, they feature a great potential for improving the crypto space. For instance, atomic swaps can mitigate the greater security vulnerabilities posed by centralized exchanges.

Atomic Swaps

Before the advent of centralized and decentralized exchanges, trading one cryptocurrency for another was a headache for most crypto enthusiasts. Although centralized exchanges soon emerged, they featured several challenges, including vulnerability to cyber attacks. 

Centralized exchanges are also limited in terms of a volume spike to a specific crypto token as they can have traffic overload whenever there is a sudden spike in demand. This can lead the price of a cryptocurrency to plummet in some cases. Also, the counterparty risks inherent in most centralized crypto exchanges emerged as one of the many reasons that brought about a need for change. 

Atomic Swaps are a technological solution that enables crypto traders to exchange tokens on a peer-to-peer level. At its core, the concept behind atomic swaps enables crypto traders to exchange tokens from different blockchains directly from their wallets, similar to how you would use your MetaMask wallet or any other Web 3.0 wallet directly on a decentralized exchange.

For this reason, atomic swaps have been lauded among crypto experts for their potential to change not only how crypto traders transfer funds but also the future of the world’s finance system.

What are Atomic Swaps?

More precisely, an atomic swap is a trade or an exchange of cryptocurrencies from one party to another on a purely peer-to-peer basis. Throughout the exchange process, both parties can maintain control of their funds just as it would be in a physical exchange and there are no third parties involved. This type of exchange is possible even for tokens that live on entirely different blockchains. 

For instance, you could exchange Litecoin LTC from your wallet with another trader looking to have LTC for Bitcoin BTC. Since the two cryptocurrencies live on different blockchain networks, you would need an off-chain bridge network of sorts where some small fee will be used to process the exchange. This bridge is the technology that enables atomic swaps.

Atomic Swaps have been around for some time now, with the first-ever atomic swap execution happening on September 20th, 2017 with Decreed and Litecoin. Also known as cross-chain trading, the process can take place via off-chain channels or directly between separate blockchains.

How exactly does it work?

Given that most blockchain networks are accessible to the public, atomic swaps work through a cryptographic process that requires both parties to share a secret in preparation for the exchange. 

The secrets are in the form of cryptographic hashes, and for security reasons, the exchange only takes place when both hashes match. This strategy is designed to prevent any malicious actor from intercepting the communication between both parties. 

After both parties have confirmed that their cryptographic hashes match, a Hashed Timelock Contract (HTLC) is put in place to facilitate the transaction. 

Each party in the transaction will create an HTLC address to which they will deposit their cryptocurrency. One of the parties then creates a secret passcode that is called a preimage. The preimage is passed over to the second party as confirmation of the deposited funds in the HTLC address. 

The second trader will then make their deposit on a separate HTLC address. Through a series of back and forth messages containing secret passcodes, the traders can unlock the funds from the HTLC addresses and complete the trade.

What is a Hashed Timelock Contract?

As the name suggests, Hashed Timelock Contracts are a type of time-bound contract that governs the exchange of the tokens between parties in an atomic swap. HTLCs is a unique off-chain state channel used on platforms such as the Bitcoin lightning network to facilitate payments. The payments are conducted in a two-way communication pattern between transacting parties thus enabling a different set of rules from on-chain transactions. 

In the case of the HTLC, the transaction time is significantly reduced, thus enabling independence from miners and allowing the payments to be validated by the submission of cryptographic proofs. 

In essence, the HTLC acts as the smart contract that facilitated the trade, and therefore both parties have to acknowledge receipt of funds within a specified time frame. The participants can interact on the HTLC network using cryptographic hash functions that are verifiable between the participating partners. If the transaction is not confirmed within the set timeframe. The entire transaction is voided, thus eliminating the risk of counterparty risk.

Crypto platforms using Atomic Swaps

Different platforms take on different approaches in their implementation of atomic swaps. Here is a look at three platforms and how they put the atomic swap technology to use.

1. Atomic Wallet

This is a cryptocurrency wallet that lets you store and trade more than 300 cryptocurrencies and tokens. The wallet operates on a decentralized framework and uses atomic swaps as a cross-chain swapping mechanism for the multiple cryptocurrencies and tokens supported on its platform. Given that this wallet stores the user’s private keys on their device, the user maintains control of their tokens or cryptocurrency throughout the atomic swap process. Also, thanks to the fact that the wallet hosts multiple cryptocurrencies, the user can use it as a form of decentralized exchange as well. 

2. Blockchain .io

Another crypto exchange and wallet implementing atomic swaps is Blockchain.io. This wallet and exchange is one of the order crypto wallet platforms and combines elements of a centralized exchange with decentralized components. Cryptocurrencies traded on the platform can be exchanged with atomic swaps, thus encouraging traders to perform decentralized peer-to-peer exchanges on the platform.

3. Komodo

Founders of Komodo are one of the top researchers and developers of atomic swap technology. Komodo is a decentralized exchange that came up with its version of atomic swaps right after the successful Litecoin Decreed atomic swap. The exchange initially started swapping cryptocurrencies such as DOGE and ETH. Nowadays, Komodo supports atomic swaps for multiple cryptocurrencies and has since operated more than 100,000 atomic swaps. Komodo’s atomic swap protocol is a unique variation that allows Komodo users to trade between the different cryptocurrencies supported on the Komodo decentralized exchange without having to download an entire blockchain.

The Advantages of Atomic Swaps

Hot wallets are the norm among cryptocurrency exchanges nowadays. Every centralized exchange comes with a set of hot wallets that give traders limited control over their digital assets. While there is an undeniable level of convenience trading on a centralized exchange, the investment is forever at the mercy of the exchange platform and its security features. For this reason, most crypto traders rarely leave their funds on crypto exchanges. Atomic swaps offer an alternative solution as they enable decentralization, control, and reduce the overall trading fees that come with centralized exchanges. Here is a breakdown.

Interoperability

Interoperability is one of the biggest challenges for blockchains in general. Although most blockchains today borrow inspiration from Bitcoin’s blockchain network, they feature different architectural designs that make them suitable for solving all sorts of needs. Today’s blockchains come with varying programming languages, varying consensus protocols, and even varying standards for token creation and smart contracts. Atomic swaps bridge this ever-widening gap with a technology that allows network users on one blockchain to communicate and exchange value as if they belonged to the same blockchain.

Decentralization

The entire ethos of cryptocurrencies and blockchain is centered around decentralization and financial freedom. Atomic swaps carry on this philosophical standpoint by allowing traders to exchange digital assets independent of third-party intermediaries such as Binance, Coinbase, or OkCoin to mention a few centralized exchanges. With atomic swaps, wallet-to-wallet exchange of tokens and cryptocurrencies is enabled thus bringing back freedom and decentralization to the crypto space.

Increased security

Atomic swap’s use of the HTLC technology gives it a greater degree of security and assurance to crypto traders than the security of most centralized exchanges. With atomic swaps, the trader remains in control of their funds the entire time, adding to the increased level of trust. And in case there is a delay for whatever reason, the transaction is reversed.

Reduced fees

Adding to the security of atomic swaps is reduced operational costs in terms of transaction costs compared to centralized exchanges. The only fee you pay in an atomic swap transaction is the standard blockchain fee for the specified cryptocurrencies you are exchanging.

Flexibility and speed

Compared to the experience on most centralized exchanges, atomic swaps feature a more speedy and flexible transaction. With atomic swaps, you can trade multiple varieties of cryptocurrencies even if they are not paired with one another. For instance, Bob (a trader of XRP) can get Bitcoin in exchange for XRP even if there are no Bitcoin / XRP pairs. In most cases, using a centralized exchange will require you to trade your XRP for a stable coin then back to BTC, thus adding to the cost and time of the transaction.

Limitations of Atomic Swaps

Privacy concerns

Like any other emerging technology, atomic swaps have a long way to go especially in terms of privacy. Sure, the traders have complete control of their private keys during the transaction; however, given that the trade is dependent on Timelock’s timeframe, the trade might end up taking longer in certain circumstances. This gives hackers more time to intercept the transaction and gather the cryptographic hashes produced by both traders. With enough time to figure out the cryptographic hashes of the transactions, the private information of the traders can be exposed. 

Lack of convenience

Even though centralization comes with several challenges, as discussed above, centralized exchanges offer an unrivaled level of convenience that is hard to find with atomic swaps. For instance, you can trade using different techniques and implement tools such as a stop-loss order, among other trading techniques. 

Too complex

Atomic swaps are too complex for the average crypto trader as they require both parties to interact under stringent measures and without any direct communication. On a centralized exchange, the trade can be executed with a simple click of a button; however, an atomic swap will require several rounds of exchanging information and cryptographic hashes. 

Limited liquidity

Another downside of atomic swaps is the fact that liquidity with each trade is dependent on the availability of counterparties to trade with. Therefore, without a counterparty trader, the exchange cannot be facilitated.

Recent developments in Atomic Swaps

Decentralized exchanges are using atomic swaps to bring about a convenient and intuitive experience for traders.

With time, technological advancements are creating new possibilities with atomic swaps. Early adopters of atomic swaps such as Komodo are working on versions of the technology that allows users to bypass the timely requirement of downloading an entire blockchain. Komodo is implementing a toolkit that enables users to create an entire blockchain network in minutes, thus adding speed and flexibility to the process. 

Rubix, a crypto exchange that uses atomic swaps, is also implementing new atomic swap techniques where transactions can be done via non-custodial wallets. This makes it possible for traders to exchange their cryptocurrencies with fiat. 

Other blockchain-related projects that are pushing the boundaries of atomic swaps include Decred’s on-chain atomic swap capability that disintermediates the exchange process. 

FAQs?

Do atomic swap exchanges exist?

Yes, several exchange platforms use atomic swaps, including the likes of Lykke exchange and Blocknet project.

Who is the inventor of the atomic swap?

Tyler Nolan is widely credited as the inventor of atomic swaps. Research and development of atomic swap began in earnest with the introduction of Nolan’s first full procedure for an atomic swap in 2013. 

When do you close a state channel in atomic swaps?

The state channel is closed based on the stipulation of Timelock’s timeframe. This can be predetermined by both parties participating in the trade. 

The Necessity of Atomic Swaps

Even though atomic swaps are yet to be tested on a broader scale, they feature a great potential for improving the crypto space. For instance, atomic swaps can mitigate the greater security vulnerabilities posed by centralized exchanges. Interoperability is also a real possibility with atomic swaps as they enable cross-chain trading capabilities. 

What’s more, more wallets are emerging with atomic swap capabilities, and even though not all cryptocurrencies can be used on atomic swaps, many that can introduce a new era for the sector and beyond. 

For instance, atomic swaps will make it possible such that Alice in Canada can send money to Bob in the UK through a borderless transaction with minimal fees. Already, several crypto traders are ripping the benefits of atomic swaps with wallet to wallet transactions that epitomize decentralization in its purest form. Considering centralized exchanges are constantly targeted by regulators, atomic swaps offer a much-needed alternative for crypto traders.