Despite the fact that cryptocurrencies are revolutionising conventional finance, they are being held up by a number of concerns. They, for example, have a complicated addressing scheme. Furthermore, virtual currency trading is primarily dependent on centralised exchanges (CEX). The value of the assets kept on CEXs is in the billions of dollars, offering hackers an opportunity to compromise their security and steal funds.
DEXs have removed the need for users to entrust the security of their virtual assets to a central authority, but they lack adequate liquidity. Atomic Swaps were the next hidden weapon in the fight for liquidity and stability.
What is an Atomic Swap?
An atomic swap is a mechanism for exchanging two different virtual currencies peer-to-peer (P2P) without the use of a third party. The mechanism is driven by a smart contract that links directly to the participants' cryptocurrency wallets.
Tier Nolan gave the first concrete description of atomic swaps in 2013, while Daniel Larimer had developed an atomic swap-like platform a year before. But, without an intermediary, how can atomic swaps reduce threats like dishonesty? It's straightforward.
To further explain this, think of this scenario.
Consider the following scenario: John wants to atomically swap her Litecoin (LTC) for Bitcoins owned by Peter (BTC).
John must give her LTC share to a smart contract. John receives the contract's key. He shares a cryptographic representation of the key with Peter in order to communicate with him. Here's where encryption comes into play: without the actual key, Peter won't be able to open the safe and withdraw John's LTC.
Peter generates a smart contract and deposits his BTC using the cryptographic representation. John can open Peter's BTC safe with her key and take the coins. Peter, how are you? John's key has a hash lock feature that allows the contents of both safes to be claimed at the same time. This removes the risk of cheating.
The swap will be complete once John and Peter have claimed their individual shares. It's worth noting that funds used in an atomic swap are fully asserted. So, the swap is either completed or cancelled. There can never be a swap that is just half-done.
On a layer two platform, an atomic swap may take place on or off-chain.
Important feature of Atomic Swaps
Hash lock - The hash lock function takes care of the keys and guarantees that the funds locked in a smart contract can only be claimed after appropriate key centric data has been given.
Time lock - This links the swap to a fixed timeline. The swap is cancelled after this time span has elapsed, and the funds are returned to their respective owners.
Benefits and Drawbacks of Atomic Swaps
An atomic swap is beneficial because it allows for cross-chain trading without the use of a third party. It is also stable and trustless since it does not rely on liquidity from an exchange.
Regrettably, it can only be done between decentralised networks that use the same hashing algorithm. Furthermore, smart contracts with time and hash lock features must be enabled by blockchains.
Since a swap on one blockchain can easily be linked to its corresponding swap on another decentralised system, an atomic swap falls short of ensuring users' privacy.
Final Thoughts
An atomic swap saves participants money on transaction fees paid by cryptocurrency exchanges while also growing fund protection. It is also unaffected by a lack of liquidity or trading platform overstretching as a result of high trading activity.