What is Atomic Swap and Why Does it Matter?

On September 20, 2017 Decred announced via Twitter that they had successfully completed an 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 swap had successfully been completed between Bitcoin and Litecoin. This caused a wave of excitement for the crypto community; many consider this an important milestone for bringing cryptocurrencies into the mainstream and predict that it will change the world of cryptocurrency forever.

But that leaves many of us thinking, what exactly is atomic swap, and more importantly why do we need it?

Put simply, an atomic swap (also sometimes referred to as a cross-chain swap or trade) is a nearly instantaneous exchange of one cryptocurrency to another which does not require a middleman or third party to oversee the transaction.

In computer programming, atomic denotes a unitary action or object that is indivisible, unchangeable, whole, and irreducible. What this means is that either the trade will be completed in full or it will be canceled and both parties will get their coins back.

The idea of the swap isn’t exactly new. It was first suggested in May of 2013 by community member TierNolan, as seen in this thread. But now with the increased popularity of blockchain technologies, the need for this type of technology is greater than ever.

There has also been a lot of talk of implementing atomic swaps with the lightning network, which is a different topic altogether but in short would greatly speed up the Bitcoin network and lower network fees.

Why Do We Need It?

Cryptocurrency transactions are not reversible. This means that right now the only way to safely transfer one coin to another is by using a trusted third party of some sort to ensure that both parties get the desired coin.

That’s why currently we rely on centralized exchanges such as Bittrex or Bitfinex to exchange our coins. This produces a few problems. For one, these exchanges make money off of… well, exchanging. Depending on the exchange, the fees can be quite small (or none), but some of the larger, well-known exchanges, such as Coinbase, charge exorbitant fees, 4% for a credit card on top of a poor price on the coin to begin with. These add up over time, and can really eat into your gains. Just take a look at this quick two-minute video which explains how the difference between a 1% and a 3% fee will take away half of your money!!

Also, exchanges are centralized. Now, I know that there are a lot of decentralized exchanges gaining popularity, but for now they haven’t reached the “mainstream”. These centralized exchanges go against the very thing cryptocurrencies set out to fix! Anything that is centralized is vulnerable to attack. Probably the most famous exchange hack of all time was the Mt Gox attack, when over $473 million worth of Bitcoin was stolen, about 7% of the total world’s supply. But even today hacks happen on a regular basis, such as Bithumb’s July of 2017.

Centralized Exchanges Will Always Be Vulnerable to Attack

How It Works (Very Simply)

So Charlie Lee hasn’t gone out and said explicitly how he made it work, but we know how it is theoretically possible. Pretty much, it works by generating a hash time-locked-contract, which uses multi-signature address and time locks to safely lock in the transaction at an agreed upon price.

Let’s say in theory Charlie wants to trade Litecoin with Vitalik for Ethereum. Both people would submit a trade, let’s say 5 Litecoin for 1 Ethereum, on both respective blockchains. But Charlie would only be able to receive the Ethereum after he provided a secret code, which only he knows. Once Charlie uses the number to receive the Ethereum, Vitalik will be able to 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 go through once the same code has been entered and the correct number of respective coins have been submitted.

If one party does not send the correct amount of currency or does not enter the code, the transaction will not go through, and each party will be returned their coins. This will in effect truly remove the need for a third party.

For a more in-depth discussion of atomic swaps, see Bitcoin Magazine’s article.

What’s the Current Status?

Since Charlie Lee’s announcement, there have been a few other coins which have announced that they too have completed successful atomic swaps between Vertcoin and Komodo and Decred to Bitcoin. Litecoin seems to be pushing the hardest out of all of the coins to adopt atomic swaps, but for now the technology is still in its infancy.

Right now one of the major drawbacks to the “average” user being able to complete atomic swaps currently requires the users to have both networks completely synced. In the case of larger blockchains such as Bitcoin, this is a big problem (Bitcoin’s blockchain is currently around 150 gigs, and growing daily).  The Komodo team has been attempting to solve this problem with the use of the Electrum server. This is could potentially allow users to interact with the blockchain without having to have download the entire chain.

That being said, most projects have been very closed-mouthed about when they actually foresee atomic swaps becoming commonplace. We’re just going to have to be patient for now.

But the future is bright for this technology with many exciting things to come. It is definitively something to keep your eyes on.

For further reading, see: “Is Blockchain Ready For Primetime”.