In the cryptocurrency space, there is a strong focus on how different ecosystems apparently compete with each other. It always seems to be Bitcoin against the rest of the markets. When the atomic swaps are introduced, this situation could change quite quickly.
It is safe to say that there is a growing need for ways to convert Bitcoin into altcoins and vice versa. At this time, this process can only be done through centralized services, such as exchanges. Fortunately, it seems that a technological solution is waiting around the corner.
This technological characteristic in question is known as an atomic exchange (or atomic swap). In some circles, it is also known as atomic exchange of crossed chains, but it means exactly the same.
Atomic Swaps: What are they?
On September 19, 2017 the Decred project announced through its official Twitter account that it had successfully completed an atomic exchange (Atomic Swap) between Decred and Litecoin. A few days later, Charlie Lee , CEO and founder of Litecoin, also announced via Twitter that the world’s first atomic exchange had been successfully completed between Bitcoin and Litecoin. Both operations occurred almost instantaneously.
— Decred (@decredproject) September 19, 2017
This has enormous implications for the future of crypto currencies, since the ability to exchange currencies between different block chains opens up a new world of potential uses. Atomic swaps could make traditional exchanges obsolete, since this new technology can give users full control over their money if they are looking to trade between different currencies.
But what exactly are the atomic exchanges, and more importantly, how do they work?
Atomic swaps are a new technology still in development that allows the exchange between pairs between different types of digital assets without the need for third parties. Transactions occur instantaneously, so there is no possibility that one of the parties does not comply with its part of the deal. And in a scenario in which one of the parties retires halfway, the funds are returned to both parties after a specific time.
AN ATOMIC SWAP IS THE EXCHANGE OF ONE CRYPTOCURRENCY TO ANOTHER WITHOUT THE NEED TO TRUST A THIRD PARTY.
Simply put, an atomic exchange (sometimes also called a cross-chain swap ) is an almost instantaneous exchange from one crypto currency to another, which does not require an intermediary or third party to oversee the transaction.
Atomic swaps are designed with two different currencies in mind. They are a method by which you can exchange currencies directly in crossed chains without having to go through an exchange. In addition, the atomic exchanges can be done inside ( on-chain ) or off the chain ( off-chain ), as we will see later.
The idea of this type of exchange is not exactly new. It was suggested for the first time in May 2013 in the Bitcointalk forum by the TierNolan user, as seen in this thread . But now, with the growing popularity of blockchain technologies, the need for this type of technology is greater than ever.
There has also been a lot of talk about implementing atomic exchanges on the Lightning network, which is a totally different issue, but in short, it would greatly accelerate the Bitcoin network and reduce network fees.
How do Atomic Swaps work?
Charlie Lee has not explicitly stated how he made it work, but we know how it is theoretically possible. Atomic swaps use an ingenious trick known as a hash-time-locked contract , which in turn exploits the potential of addresses with multiple signatures and temporary locks. All this is enabled by the basic scripting language found in Bitcoin and most altcoins, including Litecoin.
As in some Lightning Network transactions, an atomic swap employs a temporary halt contract (“hashed timelock contract”, HTLC) to ensure that both parties comply with their side of the deal. These contracts make use of a multi-signature transaction system that holds both merchants responsible for the success of a swap. For this to be possible, a hashlock uses a cryptographic algorithm that only allows users to access the funds once both parties have signed their respective transactions, and a timelock is like an insurance policy that ensures that both users will receive the refund of your funds if the operation does not succeed in a specific term.
During an atomic exchange, each user will accept the terms before the transaction. Next, both use private keys to sign a copy of the transaction itself. The exchange is done instantaneously, without transaction fees and eliminates the need for a centralized part or exchange service to complete the transfer on behalf of the buyer / seller. This allows a user who owns Bitcoin to exchange it with another user for NEO, for example.
Let’s say that in theory Charlie Lee wants to exchange Litecoin with Vitalik Buterin in exchange for Ethereum. Both people would present an exchange, let’s say 5 Litecoin for 1 Ethereum, in the two respective block chains. But Charlie could only receive the Ethereum after having provided a secret code, which only he knows. Once Charlie uses the code to receive the Ethereum, Vitalik can use the same code to instantly receive the appropriate amount of Litecoin.
The link between the two transactions would be this secret code. The transaction will only be made once the same code has been entered and the correct number of the respective coins has been sent.
If one of the parties does not send the correct amount of coins, or does not enter the code within the established time, the transaction will not be made and each party will be refunded their coins. This will really eliminate the need for a third party.
Atomic exchanges: On-chain vs. Off-chain
It is important to keep in mind that atomic swaps can be executed as functions inside or outside the chain.
Atomic chain swaps, as the name suggests, take place in any of the chains of blocks of a coin. Currently, for these swaps to work, both currencies must use the same hash algorithm, and they must also be compatible with HTLC (hash time-locked contract). As we saw earlier, as early as September 2017, Litecoin and Decred carried out a successful atomic chain exchange, the first of its kind.
On the other hand, atomic exchanges outside the chain (Off-chain atomic swaps) allow the exchange outside the chain of blocks of the coins in question. This takes place in a secondary layer of nodes, and at this point, atomic exchanges outside the chain are an extension of the Bitcoin Lightning network. Bitcoin and Litecoin executed the first atomic exchange out of the chain using Lightning Network in November 2017.
Why are they necessary?
Cryptocurrency transactions are not reversible. This means that right now the only way to transfer one currency to another, safely, is by using a trusted third party of some kind, to ensure that both parties obtain the desired currency.
That’s why we currently depend on centralized exchanges like Bittrex or Bitfinex to exchange our currencies. This produces some problems. To begin with, these exchanges make money from the exchange itself. Depending on the exchange, the fees can be quite small (or none), but some of the largest and most popular exchanges charge exorbitant fees, in addition to allocating unfavorable prices to the currencies that you wish to exchange. This can really hurt your earnings.
In addition, the exchanges are centralized. Although there are many decentralized exchanges gaining more and more popularity, for now they have not become the dominant trend. These centralized exchanges go against what the cryptocurrencies proposed to correct. On the other hand, any centralized platform is vulnerable to attacks by cybercriminals. Probably the most famous steal of all time was the attack on Mt Gox, in which more than 473 million dollars were stolen in Bitcoin, which represented at that time about 7% of the total world supply. Even today, cybercriminal attacks occur regularly, such as Bithumb in July of 2017.
What is the current status?
Since the announcement of Charlie Lee, a few more cryptocurrencies have announced that they have successfully completed atomic exchanges. Of all the currencies, Litecoin seems to be the most pressured to adopt the atomic exchanges, but for now the technology is still in its infancy.
There are some projects that seek to turn this dream into a decentralized reality. Altcoin.io , for example, is building a decentralized exchange and a portfolio with built-in atomic exchange characteristics. Komodo is also building its own decentralized exchange with enabled atomic exchanges.
At this moment, one of the biggest inconveniences for the “average” user to complete atomic exchanges is that users are required to have both networks fully synchronized. In the case of larger block chains, such as Bitcoin, this is a big problem (the Bitcoin blockchain is currently around 150 gigas, and it grows daily). The Komodo team has been trying to solve this problem with the use of the Electrum server. This could potentially allow users to interact with the blockchain without having to download the entire chain.
That said, most projects have been very closed, about when they really foresee that atomic exchanges become commonplace. We will have to be patient for now.
But the future is bright for this technology that has many interesting things to bring. It is definitely something to keep your eyes on.