Atomic Swaps Defined

Atomic Swaps Defined

An atomic swap is a smart contract technology that enables the exchange of one cryptocurrency for another without using centralized intermediaries, such as exchanges. Atomic swaps require both parties to acknowledge receipt of funds within a specified timeframe using a cryptographic hash function. An atomic swap is a smart contract technology that enables the exchange of one cryptocurrency for another without using centralized intermediaries, such as exchanges. For example, Lightning Labs, a startup that uses bitcoin’s lightning network for transactions, has conducted off-chain swaps using the technology. If one of the involved parties fails to confirm the transaction within the timeframe, then the entire transaction is voided, and funds are not exchanged.

An atomic swap is a smart contract technology that enables the exchange of one cryptocurrency for another without using centralized intermediaries, such as exchanges.

Atomic swaps can take place directly between blockchains of different cryptocurrencies, or they can be conducted off-chain, away from the main blockchain. They first came into prominence in September 2017, when an atomic swap between Decred and Litecoin was conducted. 

Since then, other startups and decentralized exchanges have allowed users the same facility. For example, Lightning Labs, a startup that uses bitcoin’s lightning network for transactions, has conducted off-chain swaps using the technology.

Cryptocurrencies and decentralized exchanges, such as 0x and Altcoin.io, have also incorporated the technology. 

Breaking Down Atomic Swaps

As it occurs today, the process for exchanging cryptocurrencies is time-consuming and complex. This is due to several reasons. For example, the fragmented nature of today’s cryptocurrency ecosystem presents several challenges to average traders.

Not all cryptocurrency exchanges support all coins. As such, a trader wishing to exchange her coin for another one that is not supported on the current exchange may need to migrate accounts or make several conversions between intermediate coins to accomplish her goal. There is also an associated counterparty risk if the trader wishes to exchange her coins with another trader.  

Atomic swaps solve this problem through the use of Hash Timelock Contracts (HTLC). As its name denotes, HTLC is a time-bound smart contract between parties that involves the generation of a cryptographic hash function, which can be verified between them.

Atomic swaps require both parties to acknowledge receipt of funds within a specified timeframe using a cryptographic hash function. If one of the involved parties fails to confirm the transaction within the timeframe, then the entire transaction is voided, and funds are not exchanged. The latter action helps remove counterparty risk. 

An example of an atomic swap transaction is shown below:

Suppose Alice is a trader interested in converting 100 bitcoins to an equivalent litecoins with Bob. She submits her transaction to bitcoin’s blockchain. During this process, Alice generates a number for a cryptographic hash function to encrypt the transaction. Bob repeats the same process at his end by similarly submitting his transaction to litecoin’s blockchain.

Both Alice and Bob unlock their respective funds using their respective numbers. They have to do this within a specified timeframe or else the transfer will not take place. Atomic swaps can also be used in conjunction with a lightning network to conduct off-chain exchanges.

Related terms:

Blockchain : What You Need to Know

A guide to help you understand what blockchain is and how it can be used by industries. You've probably encountered a definition like this: “blockchain is a distributed, decentralized, public ledger." But blockchain is easier to understand than it sounds. read more

Consensus Mechanism (Cryptocurrency)

Amid the dynamically changing status of the blockchain, a consensus mechanism ensures that only the true state of the system is maintained. read more

Cryptocurrency : What Is Cryptocurrency?

A cryptocurrency is a digital or virtual currency that uses cryptography and is difficult to counterfeit because of this security feature. read more

Hashed Timelock Contract (HTLC)

A hashed timelock contract is a smart contract used in cryptocurrencies to configure time-bound contracts. read more

Lightning Network

Lightning Network is a second layer to bitcoin's blockchain that proposes to decongest its network by creating micropayment channels between two parties.  read more

Off-Chain Transactions (Cryptocurrency)

Off-chain transactions occur outside of the blockchain network and provide a low-cost, instant transaction medium for the cryptocurrency. read more

Peer-to-Peer (Virtual Currency)

Peer-to-peer virtual currency refers to the exchange or sharing of information, data, or assets between parties without the involvement of a central authority. read more

Smart Contracts

Smart contracts are self-executing contracts with the terms of the contract between buyer and seller directly written into lines of code. read more