Home / Crypto 101 / What Are Atomic Swaps? A comprehensive Review

What Are Atomic Swaps? A comprehensive Review

Atomic Swaps have the capacity to utterly revolutionize the money transfer system in the cryptocurrency space. Simply put, atomic swaps will capacitate people and businesses to directly trade with one another, wallet to wallet.

As from 2012, the idea of a trustless, p2p cryptocurrency has been a significantly hot topic. In July 2012, a developer going by the name of Sergio Demian Lerner came up the first draft of a trustless exchange protocol. The idea was rather appealing, nonetheless, it wasn’t really fleshed out.

The breakthrough in atomic swap research occurred around May 2013, when Tier Nolan provided the first full account of a procedure for atomic swaps. Tier Nolan is widely renowned as the inventor of atomic swaps.

As far as this guide goes, we’re going to look into how atomic swaps work and the benefits that they could afford for the ecosystem.

Issues with Centralized Exchanges

Suppose Bruno has Bitcoin and is looking to trade them for Litecoin. Also, we have Tevin who has Litecoin yet wants some Bitcoin instead. Conventionally, what ought to have happened is that both of these crypto coin holders would have had to go a centralized exchange, sell their crypto coins and buy newer crypto coins. Be that as it may, there are quite a number of problems with these centralized exchanges, as discussed below:

  • Vulnerability to Hacks

Centralized exchanges are always exposed the risk of getting hacked. Possibly, the most infamous example of this is Coincheck which got hacked for $550 million worth of NEM. The worst part is that this hack intensely reduced crypto sentiment in Japan, a country that was traditionally known to be very crypto friendly.

  • Subject to Mismanagement

The infamous Mt. Gox hack where Bitcoins worth $500 million USD were robbed took place directly as a result of CEO Max Karpeles’s inept management. As Andreas Anatopoulos puts it:

“Magic The Gathering Online Exchange (Mt. Gox) is a systemic risk to Bitcoin, a death trap for traders and a business run by the clueless.” 

  • Volume Demands

Exchanges can barely deal with changes in demand, particularly in cases where there is a sudden upsurge in demand. Do you know why BCH’s value almost dropped by half on the 12th of November?

Turns out, there was a sudden rise in demand and most exchanges were unable to cope. Bithumb, in particular, suffered 90 minutes of downtime and lost 60,000 BTC in volume.

  • Subject to Regulation by the Government

Owing to the fact that centralized exchanges are registered in certain countries, they are subject to the whims of the government,

Because of the reasons stated above, centralized exchanges are not the ideal way to go forward for mainstream adoption.

What Are Atomic Swaps?

An Atomic swap is a p2p (peer-to-peer) exchange of cryptocurrencies from one party to another, without the involvement of a third party service such as a crypto exchange. Amid this entire process, the users have utter control and ownership of their private keys.

On September 20, 2017, Decred and Litecoin did the first known successful implementation of the atomic swap.

Another interesting thing worth noting as regards atomic swaps is that:

  • They can either be directly executed between separate blockchains with different native coins
  • Or, they can alternatively be executed through off-chain channels that serve as offshoots of the main blockchain.

Atomic swap is as well referred to as cross-chain trading.

How Atomic Swaps Work

Simply put, 2 parties who are going to engage in atomic swaps decide on a shared secret. The 2 parties will then share their crypto coins if and only if their secrets have a match. This way, in the even any other person barges into this exchange, they will not be in a position to get their hands on any of the crypto coins, owing to the fact that they will not be able to know this secret.

Ok, so thus far you know the concept, nonetheless, the question that still lingers is, how does it really work?

In a bid to realize the latter, an innovation referred to as Hashed Time Lock Contracts or HTLCs is implemented. If you are familiar with the lightning network then you ought to have a better understanding as regards the manner in which Hashed Timelock Contracts (HTLCs) work. As far as this review as entails Hashed Time Lock Contracts goes, we will basically give you a brief description of what Hashed Time Lock Contracts are.

What are Hashed Time-Locked Contracts?

Hashed Time-Locked Contracts (HTLCs) are a special form of payment channels. Payment channels are basically off-chain state channels that deal with payments.

A state channel refers to a 2-way channel of communication between participants and capacitates them to interact, which would conventionally take place on the blockchain, off the blockchain. Significantly, Hashed Timelock Contracts decrease the transaction period exponentially, owing to the fact that with it, users on the platform are no longer dependent on a 3rd party such as a miner to validate their transactions.

Highlighted below are the requirements to do an off-chain state channel:

  • A segment of the blockchain state is locked through multi-signature or some kind of smart contract, which is agreed upon by a set of participants.
  • The participants interact with each other by signing transactions among each other without submitting anything to the miners.
  • The whole transaction set is then added to the blockchain.

The state channels can be closed at a point as pre-established by the participants. Consequently, listed below are the reasons as to why closing state channels can take place:

  • Time lapsed, for instance, the participants can come to an agreement to open a state channel and close it after say 2 hours.
  • It could be on the basis of the total amount of transactions done, for example, close the chain after say $200 USD worth of transactions have taken place.

Hashed timelock contracts or “HTLCs” are one of the most befitting applications as regards payment channels.

So, what is a Hashed Time-Locked Contract?

Earlier iterations of payment channels used “timelocks”. An HTLC advances the latter by bringing about “Hashlocks” along with the timelocks.

The HTLC capacitates opening up of payment channels where funds can get transferred between parties ahead of a pre-agreed deadline. These payments get acknowledged through the submission of cryptographic proofs. In addition to this, another yet brilliant element of the HTLCs is that it enables a party to forfeit the payment given to them and give it back to the payer. The idea behind this elementally entails using a multi-sign transaction system that holds both traders accountable for a swap to go through flawlessly.

Figure1: Atomic Swaps – Underneath the Hood

Check out the image above which has been taken from Coin Central. Here’s what is going on here:

  • Annette has some BTC and Bobby has some LTC. They want to swap the coins with each other.
  • The 2 of them as such open up a payment channel. The instigator of this swap, for instance Annette, consequently creates a contract address.
  • Her contract address is much like a multi-lock safe that takes care of both of their funds.
  • By creating the address, Alice deposits her BTC and produces a value as well.
  • Whereas the value poses as the key, the hash generated from it will pretty much serve as a lock for the safe.
  • Upon so doing, Annette then sends the hash to Bobby.
  • Bobby generates a contract address using the hash that has been given to him by Annette.
  • Bobby sends his LTC to this contract address.
  • Only Annette is in the position to unlock the Litecoin (LTC) in this address given that only she has the value that generates that specific hash.
  • Annette can get her LTC by signing a transaction for Bobby’s contract address and Bob can retrieve the BTC by signing a transaction for Annette’s contract address.
  • Nevertheless, thus far, Bobby does not know the value that generates the hash. Therefore, the question is, how exactly is Bobby going to unlock the address?
  • For Annette, upon signing Bobby’s contract address with the value, she unlocks the address and as such discloses the value to Bobby as well.
  • Bobby, given that he now knows the value, signs off the transaction for Annette’s address and retrieves his Bitcoin (BTC).

So, to summarize the swap process;

Annette creates the value and generates its hash which is implemented to generate the contract address and deposits her BTC there. She then sends the hash to Bobby, who as such generates the contract address through the hash and sends his LTC to the contract. In a bid to to acquire the LTC, Annette will be required to unlock the address by using her value. Upon unlocking and getting hold of her coins, the value of the key is given to Bobby, who then uses the value to get his crypto coins.

On-Chain and Off-Chain Atomic Swaps

Atomic swaps, as we have mentioned previously, can either be carried out on-chain or off-chain.

  • On-Chain Atomic Swaps

What Decred and Litecoin realized was what is referred to as an on-chain atomic swap. On-Chain swaps occur on either cryptocurrency’s blockchain. In order to do this though, both currencies are required to:

  • Support Hashed Time-Locked Contracts
  • Have the same hashing algorithm
  • Off-Chain Atomic Swap

Off-chain swap, on the other hand, enables users to carry out atomic swaps off the blockchain. These swaps essentially take place on what is more commonly referred to as “layer 2”, Bitcoin and Litecoin engaged in the first ever off-chain atomic swap in November of 2017 by implementing the Bitcoin Lightning Network.

How Various Exchanges Realize Atomic Swaps

Various organizations as regards cryptocurrency exchanges have a variety of approaches in so far as executing the atomic swaps is concerned.

  1. Komodo:

Komodo is a decentralized cryptocurrency exchange platform and it is not possible to understate their contribution to the atomic swaps research. As a matter of fact, let’s take a tiny detour and travel back in time. Barely a year after Nolan presented the idea behind atomic swap protocols, Komodo’s Lead Developer jl777 came up with the code that capacitated a number of the very first atomic swaps.

Initially, this code only allowed atomic swaps between NXT assets. However, jl777 then upgraded the code to enable NXT assets to be exchanged with any Bitcoin-protocol coins.

During the summer of 2017, Komodo took the next step towards mainstream adoption of atomic swaps. They came up with BarterDEX, which was the first Graphical User Interface for an entirely atomic-swap-powered cryptocurrency trading marketplace. A moment later, Komodo started integrating dozens of Bitcoin-protocol coins and publicly carrying out tens of thousands of atomic swaps on BarterDEX.

Barely a month after the Litecoin-Decred atomic swap, Komodo came up with a method of carrying out atomic swap trading with the implementation Electrum servers.

After that, in February of 2018, Komodo was able to connect Ethereum and Bitcoin-protocol coins with a swap between ETH and DOGE. As such, Komodo was the first blockchain project to realize this feat.

By March 2018, Komodo’s atomic swap technology supported trades between 95 percent of all crypto coins and tokens in existence. As of the time of this writing, more than 110,000 atomic swaps have been carried out on BarterDEX, Komodo’s decentralized exchange (DEX).

How Komodo Works

Assuming Bobby has BTC and would like to exchange his BTC for KMD (Komodo tokens). Similarly, suppose Annette holds some KMD and is looking to acquire some BTC in return. Here is how this atomic swap is going to work out:

  • Bobby first posts a trade order on Komodo’s Decentralized Exchange (DEX) platform.
  • Annette sees the offer made by Bobby and as such accepts it.
  • Annette then commits to the trade by paying 0.15 percent of the entire trade amount as atomic swap fee. Most noteworthy, keep in mind that Bobby has not paid any transaction fees yet.
  • The moment Annette pays the transaction fee, the atomic swap commences.
  • Bobby then sends his deposit to secure the address. No one will have access to these funds until the time period of the trade has either elapsed or the trade is concluded. Worth noting, the deposit must be 112 percent of the amount of the order that was originally posted.
  • Annette sends her KMD tokens to another secure address. Just as is the case with Bobby, nobody is in the position to access it.
  • In the event the trade falls apart, then the swap will be timed out and canceled. When this event happens, Bobby gets his BTC back and Annette gets back her KMD tokens.
  • Otherwise, Bobby sends his BTC payment to Annette and concludes his part of the deal.
  • After Alice claims Bobby’s payment, Bob gains the ability to receive Annette’s KMD payment.
  • The atomic swap process is now complete.
  1. Blockchain.io

Blockchain.io is implementing atomic swaps by amalgamating both centralized and decentralized components. Their design is modeled to foster trade while entrusting trust.

The order book will be centralized to ascertain high liquidity and additionally provide the user with an option to use atomic swaps for decentralized trade settlement.

The crypto coins scheduled for trading are locked up in an escrow smart contract, which can be freely traded. Significantly, the trades take place in a centralized fashion on the exchange’s platform. In the event that the trade is concluded, they can now cash out.

Advantages of Atomic Swaps

  • Interoperability between the various assets is at the moment a big problem in the digital currencies space. Atomic swaps are going to bring users of all these various crypto coins together to help them flawlessly interact with each other.
  • Atomic swaps make the cryptocurrency ecosystem more “currency agnostic”. Owing to the fact that individuals with different holdings of cryptocurrencies will consequently be in a position to interact with each other, it is pretty likely that holders of cryptocurrencies will be more open to diversifying their holdings rather than just depending on a few crypto coins.
  • Atomic Swaps will in addition open the doors to trustless and fee-less decentralized exchanges.
  • Extant cryptocurrency exchanges are centralized and are as such susceptible to a host of attacks. Atomic swaps get rid of the need for third party involvements and make the trade as straightforward as possible.
  • Other than the susceptibility to external attacks, centralized exchanges are as well exposed to internal maintenance issues and corruption. Wallet maintenance and (or) disabled withdrawals are notably two major challenges faced by the current exchanges. Atomic swaps are intended to provide users with utter control over their digital assets.
  • Direct wallet-to-wallet trading embodies decentralization in its purest form. Exchanges are constantly targeted for regulation purposes, which makes the whole trading process increasingly centralized.
  • Given that an atomic swap directly connects 2 wallets to each other, it eliminates all the steps and gratifications necessitated by centralized exchanges. It is as such a speedier option.
  • One of the best features of cross swap regards the elimination of intermediary tokens. For instance, on the assumption that you have LTC and you wish to purchase Decred in a normal exchange, you will be required to sell your LTC for BTC in order to purchase your Decred tokens. By implementing atomic swaps, you can get this trade done in a go.
  • Exchanges normally levy hefty fees and charges particularly on the off chance you are trying to withdraw your coins back to your wallet. Some exchanges also have rather questionable fee-structures. Atomic swaps resolve this issue.

Some Drawbacks or Limitations of Atomic Swaps

#1.   Adoption

The 1st drawback that atomic swaps face in its present iteration is that 3 conditions have to be fulfilled for two digital currencies to indulge in atomic swaps, as highlighted below:

  • The cryptocurrencies are required to have a hash algorithm that is inherent to the both of them.
  • Both the crypto coins herein involved must be in a position to initiate hashed timelock contracts.
  • Both crypto coins are required to have specialized programming functionalities.

Thus far, the above mentioned conditions are bound to immensely limit the number of crypto coins that can actually take part in these swaps.

Be that as it may, the latter is barely the worst part as it will, unfortunately, as well limit the number of organizations and users that can experiment with them right now. This will as such lengthen the period of time it will take the general masses to get used to this new technology.

  • Speed:

Yes, as you may have noted, we have listed “speed” as one of the advantages of atomic swaps, yet there is more to it.

In its current iteration, atomic swap as yet requires a lot of refinement and enhancement prior to becoming fast enough to handle huge volumes of data. This is notably one of the areas where the lightning network can aid atomic swaps in a major way.

  • Lack of Compatibility:

It is a doubtless fact that more digital currency wallets which are going to adopt the atomic swap technology are springing out. Be that as it may, the lingering fact is that the total number of compatible cryptocurrency wallets and exchanges as yet lies in the minority. Additional support from more exchanges will inevitably lead to more broad scale use and research.

Conclusion

Lack of scalability and interoperability are 2 of the most salient issues that the crypto world is facing as of right now. With atomic swaps, we have a solution that can kill two birds with a single stone. This is an innovative technology with a lot of potential of taking us to the next evolution of cryptocurrency trading. We are hopeful that more research work and adoption takes place in the near future.

1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5.00 out of 5)
Loading...

About Sherwood Pham

Check Also

Best Dogecoin Wallets

Dogecoin is one of the commonly known decentralized and peer-to-peer digital currency that is evolving …

Leave a Reply

Your email address will not be published. Required fields are marked *