Since on-chain atomic swaps were first proposed back in 2013 it's been an incredibly tough journey to get to the first real world transaction. Let's talk a bit more about what atomic swaps are, how they work, and what it means for cryptocurrency traders.
What does on-chain atomic swap mean?
Atomic swaps are a protocol that allows two parties who don't trust each other to exchange ownership of assets on two different blockchains without a third party such as a cryptocurrency exchange. The word atomic means that the exchange either fully happens, or it is fully reverted, meaning that there is no such situation when one party claims the assets and then does not follow up with their part of the trade.
For example, let’s say Alice has 200 litecoins, but prefers 1 bitcoin. And Bob has 1 bitcoin, but prefers 200 litecoins. So Alice and Bob agree to trade. But neither Alice nor Bob trust each other, so neither wants to be the first to send over the coins. The other may not return the favor.
That’s why Alice and Bob set up an atomic swap.
Atomic swaps utilize a clever trick known as a hash time-locked contract, which in turn leverages the potential of multisignature addresses and time-locks. All this is enabled by the basic scripting language found in Bitcoin and most altcoins, including Litecoin and Decred.
In short, Alice and Bob submit transactions to both blockchains: one on Bitcoin and one on Litecoin. The Bitcoin transaction sends 1 bitcoin from Bob to Alice, but Alice can only claim this bitcoin if she reveals a secret number only she knows. The Litecoin transaction sends 200 litecoins from Alice to Bob, but requires the same secret number on both chains.
When Alice claims her bitcoin, she reveals her secret number on the Bitcoin blockchain. And with that same secret number, Bob can, in turn, claim his 200 litecoins.
Even though the transactions are on completely different blockchains, they are effectively linked. Bob just needs to monitor the Bitcoin blockchain to see if Alice claimed her bitcoin so that he can claim his litecoins.
Details of the first Decred <-> Litecoin swap
Announcement on Decred's blog:
Chain of transactions:
Decred contract created by Alice: fdd72f5841414a9c8b4a188a98a4d484df98f84e1c120e1ed59a66e51e8ae90c
Litecoin contract created by Bob: 550d1b2851f6f104e380aa3c2810ac272f8b6918140547c9717a78b1f4ff3469
Alice claims litecoins: 6c27cffab8a86f1b3be1ebe7acfbbbdcb82542c5cfe7880fcca60eab36747037
Bob claims decred tokens: 49245425967b7e39c1eb27d261c7fe972675cccacff19ae9cc21f434ccddd986
What does it mean for us traders?
Atomic swaps are a very important infrastructure building block for building trustless decentralized exchanges. As the technology matures expect to see more decentralized exchanges pop up, with lower trading fees. These exchanges will also be completely autonomous, and will operate under a trustless model, eliminating the possibility of something like Mt. Gox happening again.
However, at least at the present moment, it seems that we're ushering into an era of two distinct cryptocurrency realms: the Bitcoin universe (and all it's forks), and the Ethereum universe with all its tokens. Once both camps implement Lightning Networks and bitcoin stops hard forking every 4 months we might see some work on bridging the two universes.
Bridging the Bitcoin camp and the Ethereum camp will, in my opinion, spell the end of centralized exchanges as we know them today. All cryptocurrency trades are going to happen right on the blockchain through decentralized exchanges. The centralized exchanges of the future may simply become government-owned shops that only trade BTC/fiat and ETH/fiat.