Cryptocurrencies are the emblem of innovation in the financial world. With the force of a high-speed locomotive, they drive change into the markets and revolutionize the economic space. External transformation is, however, the result of an ongoing mutation of its very core and of the principles that forge it. Atomic swaps are the perfect example […]
Cryptocurrencies are the emblem of innovation in the financial world. With the force of a high-speed locomotive, they drive change into the markets and revolutionize the economic space. External transformation is, however, the result of an ongoing mutation of its very core and of the principles that forge it.
Atomic swaps are the perfect example of the diversification that cryptocurrencies go through. It is a mechanism that takes decentralization to the next level and empowers the users even more. The concept has been around for several years, but it has never been more relevant than today when the crypto world is developing at an astonishing speed.
What are Atomic Swaps?
Also known as cross-chain trading, an atomic swap is a peer-to-peer interchange of cryptocurrencies outside the supervision of a centralized crypto exchange. It is a mechanism that is based on nothing else than complete mutual trust between the parties in the transaction.
Atomic swaps provide cutting edge benefits, such as:
- They can take place between separate blockchains with different native coins
- They can initiate from off-chain channels, which are offshoots of the main blockchain
- Users can make the exchange directly from their wallets
The concept is based on smart contracts, which become “atomic” for the swap. The term signifies that if one of the parties fails to keep their side of the bargain, the interchange collapses, and the other party gets the funds back into their wallet.
Atomic swaps are not all milk and honey. They have downsides that nearly match their benefits, and they have attracted their share of criticism. Still, they make for an interesting, and highly promising concept.
Before we go any further and discover how atomic swaps work, we should take a look back and see what fueled their conception, and why so many find them necessary.
A Brief History of the Atomic Swaps
The possibility of a cryptocurrency exchange between two parties as part of a fully decentralized, trustless mechanism has been around for almost a decade.
In 2012, a developer by the name of Sergio Demien Lerner developed the first draft of a trustless exchange protocol. Unfortunately, the project did not get enough community backing to proceed to the next stage.
Fortunately, Lerner’s efforts did not go unnoticed. In the upcoming years, other developers and creators tinkered with the concept and managed to get more publicity for it. One of them was Tier Nolan, who in 2013 delivered the first comprehensive account of the process of the atomic swap. Some consider him to be the “Father of Atomic Swaps.”
Why Atomic Swaps Became Necessary
The main motivation behind the invention of atomic swaps was the distrust that many users had in centralized exchanges. These platforms host and enable global transactions of gargantuan proportions and at lightning speed. Still, they are not without flaws, which some have identified as:
Exposure to hacks
Centralized exchanges are constantly fighting hackers off. Despite their high-security protocols, these portals have regularly fallen to malicious attacks, which have reduced crypto sentiment and trust in cryptos across the world.
Susceptible to poor management
Crypto exchanges are behemoth-sized companies. However, they are still under the control of a handful of people. And, people are prone to making mistakes or incompetence. One example of it is the infamous Mt.Gox hack, which lost more than $500 million worth of Bitcoin mainly due to poor management.
Exchanges can move around humongous sums of money and digital assets. However, they can’t cope with drastic changes in demand, and due to their limited capacity, the values of cryptos can severely, and almost instantly change for the worse.
Limited to Government Regulation and Jurisdictions
Centralized exchanges are registered in specific countries, and they are at the hands of the governments of those countries. Sudden regulations or jurisdiction-imposed limitations can damage user operations and delay mainstream adoption.
These are just a few of the reasons that increased the distrust that many users already had for centralized exchanges. The hype around atomic swaps grew even larger as traders realized that the mechanism would result in lower fees, increased privacy, and even faster transactions.
How do Atomic Swaps work?
The best way to understand how atomic swaps work is to imagine a situation where two persons decide on a shared secret. Before taking the cryptos out of their wallets, they confront their version of the secret. If the versions match, the exchange takes place instantly. Third parties cannot intervene and steal the money because they do not know that specific secret.
It is that simple!
When you lift the hood to observe how the mechanism works, you will notice that it uses a particular tool called Hashed Timelock Contract (HTLC) to execute the exchange.
What is a Hashed Time Contract?
A Hashed Time Contract is a type of payment channel that operates off-chain, and which deals with direct payments.
A state channel is a two-way framework that helps users conduct an operation that would usually take place on the blockchain, outside of it. Since they do not depend on a third party to validate the transaction, the users benefit from faster transfer times.
Both users have to meet a certain set of conditions to build a payment channel, including:
- Agree on locking a part of the blockchain through a smart contract
- Agree on signing transactions among each other without notifying the miners
- Agree to add the transaction to the blockchain
- Agree to close the state channel at a predetermined time
The state channel can close for mainly two reasons:
- The time set for transactions expires
- The total amount of preset transactions is met
An HTLC is a convenient payment channel that uses both timelocks and hashlocks to enable a safe off-chain transaction between two parties.
Through an HTLC, the funds can transfer between the parties before the pre-agreed deadline. The confirmation of the payments occurs through cryptographic proofs. Additionally, it enables one of the parties to forfeit the payment given to them and return it to the payer. It is a mechanism that increases user accountability through the use of multi-signature deals.
A Simple Example of an Atomic Swap
Here’s a hypothetical example of how an atomic swap would work:
- Let’s imagine Kelly wants to trade her Bitcoin for Jeff’s Ethereum coins of the same value.
- Kelly initiates the payment channel by creating a contract address
- She deposits her Bitcoin at the contract address, which acts as a multi-signature safe accessible only by her and Jeff
- Upon creating the address, Kelly receives an automatically-generated value, which acts as a key to the safe
- Kelly takes the hash of the key and shares it with Jeff
- Jeff uses the hash to generate another contract address, which acts as the second key for the safe that he shares with Kelly
- Jeff sends the corresponding Ethereum to the contract address that he created
- Kelly verifies Jeff’s address with the only code that would validate it, and which is the hash that she initially sent
- Now, she can see if the sum that Jeff sent is correct, confirm it and claiming it
- Upon claiming Jeff’s Ethereum, Jeff also gets a look at her Bitcoin, which if he agrees with, it instantly travels to his wallet, and the swap is complete
On-Chain vs. Off-Chain Atomic Swaps
Users can engage in atomic swaps both on-chain and off-chain. The main difference between the two operations is that on-chain atomic swaps take place on one of the blockchains that correspond to either of the currencies while off-chain atomic swaps take place outside both blockchains.
An off-chain blockchain does not occur in no man’s land. The users conduct this operation on a layer-2 mechanism, such as the Lightning Network.
An on-chain atomic swap can be complete only if both currencies support HTLC, and if they have the same hashtag algorithm.
Different Approaches to Atomic Swaps
Each cryptocurrency exchange has a specific approach to atomic swaps, their execution, and any potential fees. Let’s look at a few cases of companies dealing with atomic swaps!
Komodo is a decentralized exchange and one of the first companies to embrace atomic swaps. Komodo’s lead developer known as jl777 is the author of a code that enabled some of the first atomic swaps in the industry.
Initially, the code only supported atomic swaps between NXT assets. In time, it evolved to allow swaps between NXT and Bitcoin-protocol tokens.
In 2017, Komodo developed BarterDex – the first GUI for the support of a fully atomic-swap-powered crypto trading marketplace. Soon after that, the company came up with a way of enabling atomic swaps with Ethereum servers.
At the moment, Komodo and BarterDex support trades between 95% of all coins and tokens in existence. Komodo even has its native coins called Komodo tokens (KMD).
How an Atomic Swap takes place on Komodo
- Imagine Kelly has BTC and would like some KMD in exchange. At the same time, Jeff wants to trade his KMD for some BTC
- Kelly initiates the transaction by posting a trade order on Komodo’s DEX platform
- Jeff sees the offer and accepts it by paying 0.15% of the total trade amount as an atomic swap fee
- Kelly now sends her deposit to secure the address. The deposit must be 112% of the amount of the order that was originally posted
- Jeff sends his KMD to another secure address. Nobody has access to the two addresses
- If the trade falls apart, then the swap will be timed out and canceled. When this event happens, both Kelly and Jeff get their respective funds back
- Otherwise, Kelly sends her BTC payment to Alice and finishes her part of the deal
- After Jeff claims Kelly’ payment, Kelly gains the ability to get Jeff’s KMD payment
- The atomic swap is now complete.
Blockchain.io aims to mix centralized and decentralized elements in a unique model of atomic swaps.
The plan is to have a centralized order book that backs up high liquidity, and which offers all users equal chances to use atomic swaps for decentralized trade settlement.
During a swap on Blockchain.io, the coins that make the subject of the transaction are locked in a smart contract that acts as an escrow fund. The trade takes place on the exchange’s platform, and when it is complete, the parties involved in it receive their respective funds.
Advantages of Atomic Swaps
With every passing year, atomic swaps increase their list of advantages for the cryptocurrency world. Here are the most important ones, so far:
- Atomic swaps will enable owners of different coins to team up on projects or simply to interact with each other in a way that the current environment does not allow it.
- Crypto investors will be more open to diversifying their investments and holdings, instead of having everyone aiming for Bitcoin
- This mechanism will help fee-free decentralized exchanges develop and gain their share of the market
- The security of crypto-to-crypto trades increases considerably
- Atomic swaps give users full control over their wallets with zero interference from centralized exchanges
- Cryptocurrency transfers require fewer steps to complete, thus the transaction speed also increases
- Atomic swaps may spell the end of intermediary tokens.
- The absence of centralized exchanges will result in low or no transaction fees
Why the Implementation of Atomic Swaps is so Slow
If atomic swaps are so great, then why does the industry delay its global implementation?
The answer is not simple. Despite their revolutionary influence, atomic swaps still have plenty of limitations and downsides, such as:
At the current stage of their development, atomic swaps cannot exist without these three conditions:
- The cryptocurrencies that are subject to the transaction must have an inherent hash algorithm each
- Both cryptos must be capable of initiating hashed timelock contracts
- Both cryptos have specialized programming functionalities
The problem is that there aren’t many cryptos that meet these conditions, and subsequently, there are very few companies and investors that find it viable to experiment with atomic swaps at the moment.
Atomic swaps sound great in definition and hypothetical transactions. However, if they were to be implemented on a large scale, they could not handle large volumes of data, mainly due to their current stage of development.
For atomic swaps to gain overall adoption, many more exchanges and wallets have to support them. Unfortunately, at the moment, there is a limited number of both that has decided to back this mechanism.
The Bottom Line – What are Atomic Swaps?
Atomic swaps can turn the dream of direct, wallet-to-wallet trading into reality. They represent the epitome of decentralization, and the goal towards the entire crypto world should aim.
For now, we can only cheer from the sides as the development carries on, and all that we can hope is that more research and developers get behind it.
Atomic swaps may be the future of transactions in the crypto space, and a viable solution to the blockchain-interoperability issue.