What Are Atomic Swaps?

Right now, conversion of bitcoins to other altcoins can only be done through centralized services and cryptocurrency exchange markets. If you owned 100 Litecoins and wanted 5 bitcoins, you can only do that through a cryptocurrency exchange. You can't directly exchange the 100 Litecoins with another user who owns the 5 bitcoins in a different network. That process takes time, is more costly and introduces additional risks as heard in the past.

There has been a growing need for ways that users can convert bitcoin into altcoins in a more direct way and it seems atomic swaps could answer to that problem. Atomic swaps are also known as user-activated soft fork (UASF) activation or atomic cross-chain trading and utilize lightning Network.

In other words, there has been a growing need for a system that allows a user with the 100 Litecoins to find and exchange the 100 coins with someone having 5 bitcoins on the Bitcoin network, directly without the need to go through a cryptocurrency exchange service.

With UASF, everyone's on the same protocol and ecosystem but individual users can opt in for a soft fork or not and these forks have minimal impacts on the network. The changes are made on the protocol by enforcing existing rules in a stricter manner. UASF has been proposed as the other better alternative to the Bitcoin Unlimited and Segregated Witness.

An atomic swap is an idea that dates back in 2013 but it has not been easy to see its realization in the developer circles.

How atomic swaps work

Atomic swaps work in the same manner as peer-to-peer crypto sending services but with major differences. In other words, it allows users to cross-trade different cryptocurrencies without centralized parties and trusts on a trustless system. It allows for the immediate transaction once the parties owning different cryptocurrencies agree on the transaction.

There would obviously be a case where someone wants to receive the 100 Litecoins and never send the 5 bitcoins to the owner of the Litecoins. How does an atomic swap deal with that?

Atomic swaps employ the hashed time-locked contract (HTLC) that requires the two transacting parties to fulfill the requirements of the trade, trustlessly. Each party submits their transactions individually to the appropriate blockchain on their network (for instance user A sending bitcoins to the Bitcoin blockchain and B sending ethereum to Ethereum blockchain). The transaction is claimed by the user with a secret number.

HTLC requires that the two recipients generate, separately,  cryptographic proofs of payment to acknowledge reception of transferred funds within a set deadline.  If one cannot confirm the transaction within the time frame, then the funds are returned back to the sender. In other words, when you send the 100 Litecoins to change it with 5 bitcoins from a user B, the user B will have to produce a number that he alone knows in order to generate the cryptographic proof of payment and receive the 100 Litecoins. On the other hand, you would need to produce a number known to you alone to generate the proof of payment and receive the 5 bitcoins.

It is great for making conditional payments.

With HTLC, the default timelocks on cryptocurrency payment channels can be “extended” with hashlocks such that it is possible to send bitcoins to more than one payment channels.  

As a requirement for the transactions to occur though, the payment channels -- which are hosted on different blockchains -- must be linked together. That is made possible using what is called a lightning network that has to be implemented on both blockchains doing the connection.

Drivechain has proposed that these types of transactions can be done by using sidechains -- which are one way of solving scaling issues on Bitcoin.

Once Lightning Network is activated on the Bitcoin network, every altcoin that is forked from Bitcoin codebase will be able to implement atomic swaps. Other types of cryptocurrencies would need extensive scripting capabilities to be able to realize atomic swaps on their networks.

Another requirement for the transaction to occur is that the two blockchains must be sharing the same cryptographic hash function, such as SHA-256. This allows for the hash-time locked contract to function well when the users are providing the secret numbers generated through the hash function. 

Realization of atomic swaps

Atomic swaps are a developing technology.

It was recently reported that the creator of Litecoin, Charlie Lee, successfully made atomic swaps to exchange Litecoin for Bitcoin, Vertcoin and Decred. Litecoin might be the first to implement atomic swaps.

However, one challenge with some methods is that the user would need to download blockchains of either currency, which proves to be impractical for many users.

It has also been reported that the Komodo team that owns the own decentralized exchange called BarterDEX, have completed an atomic swap using an Electrum server. Electrum server allows the user to interact with a cryptocurrency without having to download the whole blockchain. This could be a more practical way of using atomic swaps. 

Blocknet also wants to create internet of blockchains using atomic swaps. With Lykke, users will pay a 0% commission on atomic swap trades.It works as a open inter-blockchain framework and a peer-to-peer protocol between nodes on different blockchains.

Benefits of atomic swaps

Whether atomic swaps could replace cryptocurrency exchanges is a topic for another day because it is still a young technology. But with it, users would be able to not only swap different cryptocurrencies on different networks, but each user can individually set payment channels on their blockchain network and then create a transaction processor to facilitate the immediate swap of cryptocurrencies with the other user on the other network.

David Kariuki

David Kariuki likes to regard himself as a freelance tech journalist who has written and writes widely about a variety of tech issues that affect our society daily, including cryptocurrencies (see cryptomorrow.com and coinpedia.org); climate change (cleanleap.com), OpenSim and virtual reality (see hypergridbusiness.com). He is currently pursuing a MSc in Environmental Management at Open University. He does write here not to offer any investment advise but with the intention of informing audience, and articles in here are of his own opinion. Anyone willing to use any opinion here as advise to invest in crypto should obviously take own responsibility and accountability of their losses (or benefits) thereof. You can reach me at eqariu@gmail.com or david@cryptomorrow.com

Cryptomorrow - Cryptocurrency, Bitcoin, Ethereum