What is an Atomic Swap?

Atomic swaps are a system of trustless automatic exchanges facilitated by smart contracts. They allow two parties to trade tokens across different blockchains while preserving their autonomy and eliminating the need for centralized third parties while remaining void of counter-party risks without needing the identity of the parties involved. If you are new to the crypto world then this might sound like an over complicated way to describe “trading.”

However, once we compare the process of facilitating these trades using a centralized exchange versus the possibilities of atomic swaps on decentralized exchanges, you will quickly see that both of these options have their benefits and tradeoffs. 

If you want to use a centralized exchange like Coinbase to trade a cryptocurrency you currently own for a different coin it involves a bit of a process to get started. First, you have to sign up and provide Coinbase with all of your KYC information which will probably include your name, birth date, social security number, and more potentially.

Then once your account is all set up you need to send your cryptocurrency, for example Bitcoin, from the place you are currently storing it to the Coinbase exchange and pay a network fee in the process. Then in order to exchange your Bitcoin for another coin like Litecoin you essentially have to sell your Bitcoin for cash on their exchange and pay a seller’s fee.

Next you would turn around and use that cash to buy the Litecoin and most likely pay yet another buyer’s fee to Coinbase. Finally, if you then want to send your new Litecoin holdings off the exchange to a more secure custody option such as a hardware wallet, you will then have to pay yet another network fee. This process can be long, expensive and forces you to trust a centralized exchange to keep your coins safe which is not always 100% secure as evidenced by the recent Crypto.com hack which saw $30 Million+ in funds stolen off their exchange by malicious actors. 

Now let’s compare this to the process of executing an atomic swap through a decentralized exchange. In this same scenario where you wanted to exchange some Bitcoin for Litecoin you could connect your wallet and send your coins to a smart contract.

Someone else would send their Litecoin to the same smart contract. You and the other party are essentially locking your coins inside a metaphoric virtual safe that is facilitated by this smart contract. Then you exchange “virtual safe’s” and along with this comes a “key” to unlock the safe and access the funds you were trying to trade for. You have swapped tokens with another user out there without introducing the possibility for human error as this has all been facilitated by code.

On top of this the trade was executed without you paying any fee to a centralized exchange (only network fees), your wait time to execute the trade is shorter, and there was no KYC requirements that forced you to give up your personal information. 

So what does the “atomic” part of atomic swap mean? Basically it boils down to meaning “exactly as planned or it won’t happen at all.” An atomic swap will only be facilitated if both parties involved do exactly what they said they were going to do, which is send the exact specified number of coins to the intermediary smart contract. This contract comes with functionalities programmed in that ensure both sides of the trade fulfill all predefined conditions before it is completed.

This “smart contract” that we have been referring to is actually a Hashed Time Lock Contract (HTLC). This means that the funds deposited aren’t made available or accessible until both users have submitted their funds. This specialized type of smart contract also introduces a time constraint so that if one of the parties fails to uphold their end of the agreement by not submitting their funds then the other user will get their transaction reversed and their funds returned to them after a predefined time frame.

This HTLC process requires two cryptographic or encrypted keys. They are the Hashlock key and the Timelock key. The Hashlock key is the part that ensures trades are only finalized when both parties submit cryptographic proofs that they have fulfilled their side of the agreed upon transaction. The Timelock key is the part that is designed as a safety mechanism and sets a deadline for atomic swaps to ensure that deposited coins are returned to traders when the swap is not able to be successfully completed or the time deadline elapses. 

Now atomic swaps might sound great, but they don’t come without their limitations. They are still a relatively new technology and both cryptocurrencies involved in a swap need to have the same hashing algorithm and be able to interact with and support similar smart contracts.

This limits the coins and tokens that can be swapped using this method (for now). However, the atomic swap still remains a very powerful tool for the instances it can be used to help facilitate faster, cheaper and trustless transactions between users while promoting a more interoperable crypto ecosystem in an ever growing decentralized financial sector.

Despite this fact, I don’t expect to see atomic swaps actually replace centralized exchanges but rather just gradually gain more and more market share over time. Both centralized and decentralized exchanges play important roles in this fast growing ecosystem and come with their own trade offs to be weighed on a case by case basis.

Previous
Previous

Daily Digest 1/25

Next
Next

ETH Tests Resistance