What Is an Atomic Swap?
An atomic swap is an exchange of cryptocurrencies from separate blockchains. The idea is to remove centralized intermediaries like exchanges and reduce the steps needed to trade tokens, but many exchanges and businesses have created swap solutions to make the process easier.
The term atomic derives from the term "atomic state" in which a state has no substates. This refers to a cryptocurrency transaction between two people using different blockchains that either happens or it doesn'tthere are no alternatives.
Most atomic swap-enabled wallets and blockchains use smart contracts. Smart contracts are programs within blockchains that execute when certain conditions are met. In this case, the conditions are that each party agrees to the transaction before a timer runs out. Using a smart contract in the trade prevents either party from stealing a cryptocurrency from the other.
Atomic swaps are also called cross-chain atomic swaps.
Each cryptocurrency is supported by a blockchain, designed only to accept transactions in specific tokens. For example, the Bitcoin and Ethereum blockchains each have a native token that cannot be transferred to the other. You first need to convert them to fiat currency and then buy the other using other cryptocurrencies and exchanges to get the one you want. Depending on the cryptocurrency, this can take several trades. Atomic swaps allow you to exchange tokens from different blockchains in one trade.
Some decentralized exchanges can conduct atomic swaps for you. A decentralized exchange (DEX) has no central authority regulating it; it is a platform you can trade on without third parties. You can also choose from cross-chain swap providers, where you transfer your digital assets into another wallet, conduct the swap, and transfer them back out.
Atomic swaps rely on each party to provide proof through key encryption and acceptance of both parties through the encrypted key.
The concept was conceived shortly after altcoinscryptocurrencies other than Bitcoinmaterialized. The creation of altcoins meant some cryptocurrency owners became interested in moving capital between coins. This type of token swap first appeared in September 2017, when an atomic swap between Decred and Litecoin was conducted.
Since then, startups and decentralized exchanges have created ways to facilitate swaps and given users the same ability. For example, Lightning Labs, a startup that created the Lightning Network for Bitcoin transactions, has conducted off-chain swaps utilizing the technology.
Special cryptocurrency wallets have also been developed that are capable of cross-chain atomic swapsLiquality has developed a wallet that will swap Bitcoin, ETH, and more by connecting to swap providers like 1inch, Jupiter, and Sovryn.
In an atomic swap, two token owners agree to exchange their tokens. A smart contract is programmed to lock the tokens of both owners, and redeem them in the tokens desired. For instance, if Alice wanted to trade one bitcoin (BTC) for an equal amount of Bob's monero (XMR), the smart contract would lock both amounts on their respective blockchains. Once Alice and Bob agree on the trade, the smart contract would redeem Bob's BTC on the Bitcoin network and Alice's XMR on the Monero network.
Atomic swaps use Hash Timelock Contracts (HTLC) to automate the exchange of tokens. As its name denotes, HTLC is a time-bound smart contract between parties that involves generating one cryptographic hash on each end.
A cryptographic hash function is an algorithm that converts data of variable length, such as a person's wallet address and transaction information. It converts it to a hexadecimal number with a fixed length. In general, the number that is generated is called the hash.
HTLC requires both parties to acknowledge receipt of funds within a specified timeframe. If one party fails to confirm the transaction within the timeframe, the entire transaction is voided, and funds are not transferred. This eliminates counterparty risk, or the risk that one party will accept the offered coins and decline the transfer of their coins.
Atomic swaps sound complicated, but for most users, they can be very simple. Atomic swap-enabled wallets or decentralized exchanges like Atomic Swap or Uniswap let you choose from your cryptocurrency to swap for another token. The swap might be labeled "Exchange" or "Swap" in the wallet's interface.
Once you've selected the appropriate action, you choose the tokens you want to swap; you'll see the amount you'll receive in the token you're swapping. The interface should tell you the swap rate and network fees, let you double-check the transaction, and give you a button to press to initiate the trade.
Depending on the network, whether you're using an exchange or trading with another user, the swap can take several minutes to complete. For example, Atomic Wallet's instructions state that a swap should take about 20 minutes, but other wallets or decentralized exchanges might take less or more time.
Atomic swaps are generally initiated by users and executed by a smart contract. The smart contract can be programmed in many ways, but most tend to lock up the tokens being swapped or burn them, then issue the new tokens to the transferees.
When two entities want to trade tokens, they can use an atomic swap to ensure no third parties are involved. This technique is faster and generally cheaper than going through exchanges or other token swap service providers.
In most cases, the only publicly available information is the token amounts and the users' public addresses. However, if other information has been made available, these addresses can be traced back to their owners, so they are realistically pseudonymous.
The term atomic swap is used to refer to two users trading tokens from incompatible blockchains. The swaps are generally executed by smart contracts, which lock or burn the original tokens and issue new ones on the corresponding blockchains.
The comments, opinions, and analyses expressed on Investopedia are for informational purposes only. Read ourwarranty and liability disclaimerfor more info.
See the article here:
Atomic Swap: Definition, How It Works With Cryptocurrency Trade - Investopedia