News
Definition, how it works with cryptocurrency trading
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 required to exchange tokens, but many exchanges and companies have created swap solutions to simplify the process.
The term atomic comes from the term “atomic state” where a state has no substates. This refers to a cryptocurrency transaction between two people using different blockchains that either happens or it doesn’t happen, there is no choice.
Most atomic swaps 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 accepts the transaction before a timer expires. Using a smart contract in commerce prevents either party from stealing cryptocurrency from the other.
Atomic exchanges are also called Crossed chain atomic exchanges.
Key points
- An atomic swap is a cryptocurrency exchange between two parties who wish to exchange tokens from different blockchains.
- Atomic swaps are useful if you only have one cryptocurrency but need to use another in a transaction.
- To make an atomic swap, special wallets or exchange services are needed, because the technique is still being developed and perfected.
Understanding Atomic Swaps
Each cryptocurrency is backed by a blockchain, which is 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 must first convert them into fiat currency and then purchase the other using other cryptocurrencies and exchanges to get what you want. Depending on the cryptocurrency, this can take several transactions. Atomic swaps allow you to exchange tokens from different blockchains in one transaction.
Some decentralized exchanges can do atomic swaps for you. A decentralized exchange (DEX) has no central authority regulating it; it is a platform where you can trade without a third party. You can also choose from cross-chain swap providers, where you transfer your digital assets into another wallet, do the swap, and transfer them back out.
Atomic exchanges rely on each party providing proof via key cryptography and acceptance by both parties via the encrypted key.
History of Atomic Exchanges
The concept was conceived shortly after the materialization of altcoins, cryptocurrencies other than Bitcoin. The creation of altcoins caused some cryptocurrency holders to become interested in moving capital between coins. This type of token swap first appeared in September 2017, when an atomic swap was conducted between Decred and Litecoin.
Since then, startups and decentralized exchanges have created ways to facilitate swaps and have given users the same ability. For example, Lightning Labs, a startup that created the Lightning Network for Bitcoin transactions, has conducted off-chain swaps using the technology.
Special cryptocurrency wallets have also been developed that can perform cross-chain atomic swaps: Liquality has developed a wallet that allows you to trade Bitcoin, ETH and more, connecting to swap providers such as 1inch, Jupiter and Sovryn.
Atomic exchange process
In an atomic swap, two token holders agree to exchange their tokens. A smart contract is programmed to lock both token holders’ tokens and redeem them for the desired tokens. For example, if Alice wanted to exchange 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 to the exchange, the smart contract would redeem Bob’s BTC on the Bitcoin network and Alice’s XMR on the Monero network.
Atomic exchanges use Hash Timelock Contracts (HTLC) to automate the exchange of tokens. As the name suggests, HTLC is a time-limited smart contract between parties that involves generating a cryptographic hash on each end.
A cryptographic hash function is an algorithm that converts variable-length data, such as a person’s wallet address and transaction information. It converts them into a hexadecimal number with a fixed length. In general, the number that is generated is called a hash.
HTLC requires both parties to acknowledge receipt of funds within a specified time frame. If one party fails to confirm the transaction within the time frame, the entire transaction is canceled and the funds are not transferred. This eliminates Counterparty riskor the risk that one party will accept the offered coins and refuse the transfer of their own coins.
How to do an atomic swap
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 allow you to choose between your cryptocurrency to exchange for another token. The swap may be labeled “Exchange” or “Swap” in the wallet interface.
Once you have selected the appropriate action, choose the tokens you want to exchange; you will see the amount you will receive in the token you are exchanging. The interface should tell you the exchange rate and network fees, have you review the transaction, and give you a button to press to initiate the exchange.
Depending on the network, whether you are using an exchange or trading with another user, the swap may take several minutes to complete. For example, Atomic Wallet instructions state that a swap should take about 20 minutes, but other decentralized wallets or exchanges may take less or more time.
What is the atomic exchange mechanism?
Atomic swaps are typically 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 swapped tokens or burn them, then issue new tokens to the swappers.
What are the advantages of Atomic Swaps?
When two entities want to exchange tokens, they can use an atomic swap to ensure that no third parties are involved. This technique is faster and generally cheaper than going through exchanges or other token exchange service providers.
Is an atomic swap anonymous?
In most cases, the only information publicly available is token amounts and users’ public addresses. However, if other information is made available, these addresses can be traced back to their owners, so they are realistically pseudonymous.
The bottom line
The term atomic swap is used to refer to two users exchanging tokens from incompatible blockchains. Swaps are typically executed by smart contracts, which freeze 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 our warranty and disclaimer for more information.