Atomic swaps are a peer-to-peer, trustless method of exchanging coins on different blockchains. In essence, atomic swaps allow you to exchange, for example, bitcoin with litecoin, while avoiding the need to trust an exchange or any other third party.
Further Reading: What Is Bitcoin?
Atomic swaps can be performed in one of two ways: Firstly, atomic cross-chain trading can be done directly between two blockchains with different native coins — known as an on-chain atomic swap. Secondly, you can use off-chain channels that are offshoots of the main blockchains involved — known as off-chain atomic swaps.
On-chain atomic swaps provide more security since the mechanism is embedded into the blockchain itself and the transaction will either finalize or be cancelled. On the other hand, off-chain atomic swaps are faster and provide more throughput than on-chain atomic swaps but are more complex to perform and still a few years away from practical implementation.
Further Reading: What Is a Blockchain?
A Brief History of Atomic Swaps
Also known as atomic cross-chain trading, the idea of atomic swaps has been around since July 2012, with Sergio Demian Lerner’s initial attempt at creating a trustless exchange protocol called P2PTradeX. The idea was further refined and formalized by Tier Nolan in May 2013.
Nolan’s algorithm was refined even further by former Bitcoin developer Mike Hearn and others. Their improved approach allowed the direct exchange of coins on Bitcoin-derived blockchains, without specific support from the protocol.
A successful mechanism to carry out Nolan’s formal description of an atomic swap did not occur until 2014, when the developer jl777 carried out a test for swapping litecoin with dogecoin. Decred later simplified the code to make atomic swaps more widely available, successfully executing an atomic swap with litecoin in September 2017.
The first bitcoin-to-litecoin off-chain atomic swap using the Lightning Network was conducted in November 2017. These off-chain atomic swaps are largely just demonstrations at the moment and have only been exhibited with two coins that support the same Lightning specification, namely BOLT.
Further Reading: What Is an Altcoin?
How Do Atomic Swaps Work?
Let’s say Alice and Bob want to exchange one bitcoin for 100 litecoin. Alice has one bitcoin and prefers 100 litecoin; Bob has 100 litecoin and prefers one bitcoin.
To make the exchange, Bob first creates a secret number, a “value.” He then also generates a hash from this value, and he shares this hash with Alice. (But he doesn’t share the value itself!)
Now Bob creates a bitcoin transaction, “locking up” one bitcoin. This bitcoin can be claimed in a follow-up transaction in two ways. Either, it can be claimed by Alice, with her signature, in combination with the secret value. The Bitcoin network will recognize the secret value if it matches the hash, which is included in this transaction. Or, it can be claimed by Bob, with his signature, but only after two weeks have passed.
Right now, Alice can’t claim the bitcoin, because she doesn’t know the secret value, and Bob can’t claim the bitcoin, because two weeks haven’t passed.
Next, Alice creates a litecoin transaction, “locking up” 100 litecoin. The 100 litecoin locked up in this transaction can be unlocked in a follow-up transaction in two ways as well:
Either, it can be claimed by Bob, with his signature, in combination with the secret value. Or, it can be claimed by Alice, with her signature, but only after a week has passed.
This means that Bob can now claim the 100 litecoin: He does know the secret value. He just needs to do it within a week, because after that week Alice can claim her 100 litecoin back.
Now, if Bob does claim the 100 litecoin with a follow-up transaction, he broadcasts the secret value: it is now included in the Litecoin blockchain. So, if Alice keeps an eye on the Litecoin blockchain, she can just take the secret value, and, in turn, use it to claim the bitcoin on the Bitcoin blockchain. (She just needs to do it within two weeks, before Bob can claim his bitcoin back.)
Indeed, Bob can only claim the 100 litecoin if he lets Alice claim her bitcoin: a trustless trade.
The Future of Atomic Swaps
As the technology of atomic swaps matures, we should see increased adoption among decentralized exchanges and wallets. At this point, we are already starting to see some uptake of atomic swaps, such as with Altcoin.io, Atomic wallet and Liquid wallet.
Further Reading: What Are Bitcoin Wallets?
If atomic swaps become widely used, they could play a part in eventually making centralized cryptocurrency exchanges obsolete.
But first, atomic swaps need to be integrated across existing wallets and services. There also needs to be an improvement in the user experience to make cross-chain trading easy for the average person.
Bitcoin Magazine reviewed the Ledger Nano X, the latest cryptocurrency hardware wallet offered by the company Ledger. Watch the video above and read the accompanying article below to learn more about the product’s specs and how to set it up. The Ledger Nano X supports over 1,000 different coins, including all ERC-20 tokens. Some of…
Piggy banks have long served as a symbol of financial prudence and savings, a place to deposit pocket change and hold it for a rainy day. But what if fiat coins aren’t the best stores of value after all? For Jim, the creator of Opendime-powered company BitPiggys, these novelty banks clearly needed an introduction to…
On Tuesday, NFL Tackle Russel Okung and Strike announced a partnership that will pay a sizable portion of Okung’s $13MM NFL in bitcoin. Last May, Okung lobbied his former and current NFL teams to pay him in bitcoin. After reaching out to Strike founder Jack Mallers and working with the Carolina Panthers front office, this is…
What can Bitcoiners learn about agriculture, compassionate care of the soil and the food supply?A little boy digs in the dirt for the “Source of the Seed.”I was young, probably around four years old when Grandpa Jones held my hand and led me down the steps of the farmhouse porch. It was covered, had comfortable…
As the first financial advisory platform focused purely on Bitcoin, Swan Advisor Services lets advisors monitor, manage and custody their clients’ BTC.Swan Bitcoin releases the first financial advisory platform focused purely on bitcoin. Swan Advisor Services can integrate with a financial advisor’s existing portfolio management activities. Advisors will be able to manage, view and custody…
Bitcoin is not a bubble. It’s the monetary escape hatch we need now that the COVID-19 cat is out of the bag.I trained as a financial historian. My academic work focused on banks and financial markets in the past, and I was always fascinated by iconic bubbles of financial history — the tulip mania, the…
After a week in El Salvador, it’s clear that state-run Bitcoin adoption is a slow but critical foundation for revitalizing the country.This is an opinion editorial by Shinobi, a self-taught educator in the Bitcoin space and tech-oriented Bitcoin podcast host.I recently spent a week in El Salvador to attend Adopting Bitcoin and decided it might…
KenGen, Kenya’s largest energy producer, plans to deliver excess geothermal energy to bitcoin miners in the region.Kenya’s largest producer of electricity intends to deliver excess geothermal energy to bitcoin miners. Geothermal energy in the region is estimated to be above 14,000 MW with 10,000 MW located along the Rift Valley circuit.Over 80% of KenGen’s power…
In this episode of Bitcoin Magazine’s “Meet The Taco Plebs,” I was joined by my good friend, “a man of the people,” Vake. He has been on the Bitcoin scene for a lot longer than many and provided some quality insight into what was going on around BTC in 2013 and 2014. Vake is a…