Cryptocurrency trading volumes rise to hundreds of millions of US dollars on a daily basis. A considerable portion of these trades are exchanges of different digital assets, like trading Bitcoin (BTC) for Ethereum (ETH), Litecoin (LTC) for Ripple (XRP), or thousands of other combinations, since the number of crypto assets is growing by the day.
A large portion of these exchanges of cryptos takes place on cryptocurrency exchange platforms such as Binance, Kraken, or Coinbase, which provide users with fast, secure, and reliable services for a platform fee.
However, there is also another method for exchanging or swapping cryptos without the use of exchange platforms. This method is called atomic swaps and it doesn’t use any sort of centralized intermediaries to facilitate exchanges.
Let’s take a look at how cryptos and blockchain technology work in order to understand what atomic swaps are, how they work, and what are their pros and cons.
Cryptocurrencies and Blockchain Technology
Most cryptocurrencies use blockchain technology to facilitate transactions of funds and information. Blockchains are a form of data storage networks that act as distributed public ledgers of information about a cryptocurrency. Each cryptocurrency has its own blockchain, but some cryptos, such as ERC20 tokens, are built on the Ethereum network’s blockchain and it’s not uncommon that lesser-known tokens are built on the foundation of a larger blockchain.
In any case, these blockchains store data in the form of blocks that are chronologically set, and each of these blocks houses a set amount of data. In the case of the Bitcoin blockchain, each block has 1MB of data and in order for a transaction to get processed through the network, miners have to solve a string of mathematical puzzles that ultimately result in the creation of a new block and the verification of all transfers within that block.
Blockchain technology, which was first introduced with the Bitcoin network in 2009, has become a standard for cryptocurrencies because it is lightning fast, reliable, and secure. Every transaction has to be verified by multiple system nodes that make sure the transfer isn’t some sort of scam or fraud, in case a malicious person tries to double-spend the same assets.
Blockchain technology can be used for far more real-life use cases than just transactions of funds. One of the most innovative and versatile features that can be found on some blockchains is smart contracts.
Smart contracts are a feature that increasing numbers of advanced cryptocurrencies are incorporating. The Ethereum network is well known for its smart contract function that is also one of the main reasons more and more startups and developers are endorsing ETH globally. Smart contracts are basically simple, fast, and automated, self-executing agreements between buyers and sellers that are written directly in programming code.
Smart contracts are used for various purposes, including for automating payment processes, facilitating the flow of information, and creating entire decentralized applications (Dapps) that are independent of big, centralized web platforms. Smart contract technology enables people to directly conduct all sorts of agreements between themselves without the unnecessary implications and costs posed by intermediary institutions that approve or check their agreements.
The specifics of a smart contract as an agreement are up to the parties involved in it. Ethereum is a pioneer in complex smart contracts and other blockchains try to follow in its path. Atomic swaps use smart contract technology to facilitate exchanges of cryptocurrency.
As a concept, atomic swaps were invented by crypto enthusiasts and programmers Charlie Lee and Tier Nolan. Atomic swaps are based on smart contract technology which makes it possible to exchange one crypto for another without going through centralized exchanges, but also evading decentralized exchanges, too. Basically, these swaps are peer-to-peer exchanges of different cryptos.
There are two ways atomic swaps can be executed. An atomic swap can be conducted off-chain, which means away from the main blockchain of a cryptocurrency, using something called a lightning network. The second option is for the swap to be carried out directly between different crypto blockchains. This type of exchange between different cryptos was first introduced in 2017 with the swap between the Litecoin and Decred blockchains. In the following years, atomic swaps grew in popularity as an alternative method of exchanging cryptos without any centralized intermediary.
Atomic swaps don’t use on-chain processes when exchanging funds. The smart contract technology behind atomic swaps is also called cross-chain trading and it enables users to directly swap coins with each other from one wallet to another. The usual additional step of sending your coins to a crypto exchange account and then facilitating an exchange through the platform is thus eliminated.
However, this means that you have to personally find someone who wants to exchange coins with you directly using an atomic swap. When you use exchange platforms, the platform itself finds an interested party for exchanging coins, but it does require an exchange fee. Atomic swaps don’t require any additional fees beyond the transaction fee of the network.
Example of How Atomic Swaps Work: Hashed Timelock Contracts (HTLC)
We mentioned that blockchain transactions are designed to be scam-proof, offering top security by verifying each transaction. The level of security is the same with atomic swaps, as they are created with a protocol that prevents any of the two parties that are swapping coins from cheating and pulling a scam on the other party.
Here is an example:
- Tom would like to trade some BTC for Johnny’s ETH.
- Tom first has to deposit his BTC into a special safe contract address that keeps the funds until the swap is finished.
- Then Tom shares the hash of the safe key with Johnny.
- Johnny can’t access the safe yet because he just has the hash of the key.
- Johnny uses the hash provided by Tom to create another safe contract address and this is where he transfers his ETH.
- In order for Tom to get his ETH from Johnny, he has to use the same key as Johnny and when he does this, he automatically reveals the key to Johnny. So now Johnny has the key along with the hash of the key and both of them can claim their funds.
- The moment when Tom claims his ETH the key is revealed to Johnny so he too can claim the BTC. This automated function is called a Hash Timelock (HTLC) and it acts as a safeguard for scams and fraud during atomic swaps, making it a trustless exchange method that works flawlessly.
Bitcoin Lightning Network
A lightning network is another medium for atomic swaps if users don’t want to directly exchange coins between different blockchains. Lightning networks aren’t exclusive to Bitcoin, but in order to be as clear as possible, we’ll take the BTC lightning network as an example.
The lightning network is basically a network that is built on top of the original BTC blockchain with the key purpose of facilitating extremely fast peer-to-peer transfers of funds. Numerous other cryptos have also built lightning networks on top of their blockchains. This means that this network is an off-chain network that utilizes the basic blockchain, but is considered as a second layer of the chain with its own system nodes and software. However, it still retains a connection to the original blockchain.
Unlike the basic BTC blockchain, the lightning network doesn’t record all of the transactions that ever happened on the blockchain, which enables it to facilitate peer-to-peer exchanges extremely fast. When someone wants to use the lightning network, they need to create a specific type of smart contract that signals the blockchain to use the lightning network instead of the traditional chain.
Some of the key benefits of using lightning networks to facilitate atomic swaps between users are scalability, privacy, and fast micropayments without delays.
Advantages of Atomic Swaps
The main advantage of atomic swaps and the reason for their popularity is the decentralization of the whole swapping process. There is no need for using any type of crypto exchange to facilitate a swap of cryptos. Cross-chain exchanges of different currencies can easily be carried out between interested parties and you don’t need to trust the other side, because the hash timelock makes sure no one can trick you and steal your funds.
Another advantage of atomic swaps is that the security level of a transaction is higher compared to exchange platforms because you don’t have to send your funds to a third party. Instead, you deal directly with someone who wants to exchange cryptos with you. Exchange platforms are generally quite secure, but cyber attacks do happen sometimes and it is always safer to avoid an extra step (such as an intermediary) when exchanging funds. This is possible with atomic swaps because the exchanges happen directly between the wallets of two users.
What’s more, atomic swaps are much cheaper than the use of exchange platforms because you don’t have to pay any platform fees; even the transaction fees are considerably lower. In some cases, there are no transaction fees whatsoever. Payment channels operated by atomic swaps mean less operating costs.
Finally, the usual hassle of converting less popular altcoins to Bitcoin or Ethereum first in order to trade them with someone is totally eliminated because atomic swaps make it possible to instantly convert all sorts of different cryptos. No intermediary coin is required. Generally, atomic swaps offer smoother liquidity of funds and higher transactional interoperability.
Limitations of Atomic Swaps
The key limitation of atomic swaps is that not all cryptocurrencies can be exchanged this way. In order for an atomic swap to be possible, the two cryptos that you want to exchange need to be on blockchains with the same hashing algorithm, such as the SHA-256 hash algorithm of BTC. The exchanged cryptos also need to be able to conduct hash timelock contracts.
This might sound like a huge disadvantage, but actually, more and more cryptos support HTLC and it isn’t that difficult to find crypto pairs with the same hashing algorithm, especially when it comes to seasoned crypto traders with an extensive portfolio of cryptocurrencies. When you have various cryptos in your portfolio, it is easy to find one that is compatible with the other asset you wish to exchange your funds for.
A Few Words Before You Go…
Atomic swaps are an easy and handy way for exchanging different cryptocurrencies without the need for using a crypto exchange platform. This functionality is becoming increasingly popular as a means for facilitating exchanges that need to be carried out quickly, securely, and at a lower cost.