The list of cryptocurrencies is constantly growing, despite their volatile rates. Today, according to CoinMarketCap, there are more than 2,000 crypto coins, which are present in the investment portfolios of crypto holders in different amounts. Due to the abundant supply on the market, users need to exchange one coin for another. Digital assets are converted by third-party exchanges. But the blockchain industry, which in its principle denies the presence of intermediaries, cannot exchange, for example, Litecoin to Ether with the help of third-party companies. On January 9, the Qtum blockchain project presented atomic swaps for the direct exchange of cryptocurrencies. DeCenter reviewed the structure of this technology and found out its potential for further development.

The Essence of Atomic Swaps

Bold statement: atomic swaps can completely change the system of monetary transactions in the world of cryptocurrencies. In simple terms, the technology of transfer and conversion of cryptocurrencies will allow people to directly trade and exchange digital coins of different blockchains without the participation of third parties.

The ideas for the implementation of the exchange of cryptocurrencies for “their own kind” appeared at the time of the creation of altcoins. In July 2012, developer Sergio Demian Lerner presented the first draft (its theoretical component) of a trustless exchange protocol. The idea was quite attractive but was not realized at the time. A breakthrough in atomic swap research occurred in May 2013 when Tier Nolan presented the first full report on the atomic swap procedure.

Let us recall the heroes Alice and Bob, who constantly make transactions in all the examples used to explain the functioning of the cryptocurrency industry. Suppose Alice has Bitcoins, and she wants to sell them for Litecoins. Luckily, Bob has LTC, which he does not mind changing to BTC. To do this, the users need to transfer their coins to cryptocurrency exchanges and with the help of third parties—in this case, the intermediary being the exchanger—sell their existing assets and buy others.

Alice trades her coins with Bob. Source.

Centralized exchanges, however, have many problems: the threat of hacking, mismanagement (for example, the situation around Mt.Gox), volume requirements, and inability to cope with changes in demand, especially when there is a sharp increase in demand for assets. Besides, legal crypto exchangers are subject to state regulation because they are registered in some country, so user data is transmitted to third parties.

For these reasons, the crypto industry, which considers itself truly advanced, cannot rely on third parties that are more connected with society than the technology. In addition, blockchain implies an open industry with no less open innovation, including that in digital assets.

The ability of individual blockchains to interact with each other—for example, between Bitcoin and Ethereum—is extremely limited. After all, networks use various protocols, algorithms, and security procedures for conducting transactions. And most digital exchanges, before transferring one coin to another, require the user to convert to base currency, and often this is Bitcoin since it is the most liquid and easily accessible. Because of the high crypto volatility, in the end, users can pay a large amount for the completed exchange transactions as the exchanges charge trading fees to complete all transactions.

Of course, to avoid the risks and problems that are present on the centralized platforms, a user can exchange coins on a decentralized one. Atomic swaps, however, are different from the DEX in that they create an encrypted escrow account using a crypto protocol that guarantees an instant refund to users if the transaction is not completed for any reason or interrupted by any party. Due to this, the default risk is reduced to zero. In addition, if a user trades on centralized exchanges, then the sense of using decentralized platforms is lost since a commission will have to be paid for transferring assets from one platform to another.

Implementation of Atomic Swaps

On September 20, 2017, the Decred and Litecoin blockchains with the DCR and LTC internal cryptocurrencies, respectively, made the first successful conversion of coins thanks to the implementation of an atomic swap. Then the two projects used hash time-locked contracts (HTLC). For Decred to be swapped for Litecoin, and LTC for DCR, the teams took turns to reveal the secret number in the blockchain, which was previously known only to the coin owners. In addition, to make the transaction go through, users need to download blockchains which will participate in the conversion of cryptocurrencies.

HTLCs are a special form of non-conceptual payment channels. Due to this, the main network is not clogged or overloaded, and the transaction processing time is reduced. Therefore, HTLC is referred to as a special type of smart contract that allows for time-specific transactions between two parties, which was done in the case of Decred and Litecoin.

Graphical representation of swapping the DCR and LTC coins. Source.

Do not forget that atomic swaps require the existence of interconnected payment channels between the blockchains of the traded cryptocurrencies. Communication is carried out through the Lightning Network. Initially, it was needed to address the issues of scaling in Bitcoin, but now its capabilities have been used for other purposes. The Lightning Network links payment channels that use the same hashing algorithm. Therefore, Bitcoin can only be associated with altcoins on the SHA-256 algorithm, and these include Litecoin and Zcash.

Projects that Deal with Atomic Swaps

Litecoin founder Charlie Lee, who can rightly be considered one of the main adherents of atomic swaps, in September 2017 successfully exchanged LTC for BTC, which he reported on his Twitter account. Most users thanked Lee for the great work done, the essence of which was to improve the process of converting some digital coins to others.

A few days later, inspired by the activities of the founder of Litecoin, the Komodo developers managed to complete an atomic swap between the BTC and the internal KMD coin of the project using only the Electrum server. This important event pleased crypto enthusiasts even more because there was evidence that atomic swaps can be used without uploading both blockchains for exchange in a pair of cryptocurrencies.

Then, in October 2017, the Bitcoin-Ethereum Atomic Swap Code development team introduced the open-access technology to exchange Bitcoin and Ethereum. This code on GitHub has already been used to launch the Altcoin Exchange, which was meant to enable “atomic swaps” between cryptocurrencies at market value.

The transfer of BTC and ETH through atomic swaps can be accomplished using the open OFGP protocol, which was jointly developed by the decentralized exchange DEx.top and the crypto wallet iBitcome. In addition to transferring, the protocol allows users to monitor the flow of digital assets of a particular user and all transactions on the network at any time.

Another solution using an internal token for blockchain transactions between Bitcoin, Ethereum, and the tokens of ERC-20 standard was introduced by Wanchain. An intermediate digital coin WBTC was used to smoothly carry out transactions. The project plans to increase volumes and ensure liquidity through a partner, the decentralized exchange Kyber DEX.

On January 9, 2019, the Qtum blockchain platform introduced its atomic swaps based on HTLC. In fact, their proposal does not differ from the projects described above and is implemented using the internal token QTUM.

Nothing Good so Far

Like all emerging technologies, atomic swaps have drawbacks. We have already mentioned above that it is often necessary to upload both blockchains of the currency pairs to make a transaction. Also, the involved networks must be able to initiate HTLC as atomic swaps do not work with digital assets that do not support smart contracts. After the transfer is completed, not all crypto wallets can accept the coins. The exchange with the use of the described technology is slower if large sums are converted, so the scalability problem remains to be solved.

In general, these shortcomings are not difficult in terms of technology and implementation of the exchange network. Most likely, as suggested by the researchers, the flaws will be corrected soon, because, for example, the Komodo project proved that it is not necessary to have two blockchains for currency conversion. This means that ordinary users will be able to freely exchange and transfer digital assets without intermediaries. The blockchain industry will get rid of third parties in the process of converting coins and will be even more consistent with its ideological principles.