changelogUpdate
Citeşte mai mult

What is an Atomic Swap?

08 Feb 2023
4 Minutul de citit

An Atomic Swap, also known as a cross-chain swap, is a decentralized way of exchanging cryptocurrencies or digital assets from one blockchain to another, without the need for a centralized exchange or intermediary. An atomic swap is a smart contract-based exchange process that enables users to swap assets directly with one another, in a trustless and secure manner.

In an atomic swap, the assets are locked in a smart contract and the swap is executed automatically when both parties fulfill their respective obligations. The trade is considered "atomic" because it is either completed in its entirety or not at all. This eliminates the risk of one party not following through on their end of the deal and protects both parties assets.

Atomic swaps can be performed between two parties without the need for a third-party intermediary, such as a centralized exchange. This not only increases the security of the exchange, as it eliminates the risk of a centralized exchange being hacked or going bankrupt, but it also helps to reduce the costs associated with using centralized exchanges.

Atomic swaps can be performed between different blockchains that use different consensus algorithms, such as from Bitcoin to Ethereum, or from Litecoin to Decred. This increases the flexibility and interoperability of cryptocurrencies and digital assets, as users are no longer restricted to trading only within a single blockchain ecosystem.

Simplified Example

An Atomic Swap can be compared to a trade between two people. Imagine two people, one has a car and the other has a boat. They both want each other's vehicles, but they don't trust each other to make the trade fair.

An Atomic Swap acts like a trusted third party, making sure that both people get what they want at the same time. They give their vehicles to the Atomic Swap, and the swap makes sure that each person gets the item they wanted before the trade is finalized. This way, neither person has to worry about the other running off with their vehicle without giving them the trade item in return.

Who Invented the Atomic Swap?

The term "atomic swap" was first introduced in 2013 by Tier Nolan, a software engineer and cryptocurrency enthusiast. In his paper titled "Atomic Swaps: Peer-to-Peer Crypto-Currency Exchange without Third Parties," Nolan outlined the concept of atomic swaps as a decentralized and trustless method for exchanging cryptocurrencies directly between parties without the need for intermediaries.

Examples

Cross-chain Atomic Swap between Bitcoin and Ethereum: A user wants to exchange their Bitcoin (BTC) for Ethereum (ETH) without using a centralized exchange. Both parties agree on the terms of the trade and use hash time-locked contracts (HTLCs) to ensure a trustless transaction. The user first sends their BTC to a multi-sig address and generates a secret key. This secret key is then hashed and included in the ETH transaction as a HTLC. The ETH is sent to the Bitcoin user, who then has a set amount of time to provide the secret key to claim the ETH. If the secret key is not provided within the agreed time, the ETH is returned to the sender.

Decentralized Exchange (DEX) Atomic Swap: A DEX platform implements an Atomic Swap mechanism for trading cryptocurrency assets directly between two users, without the need for a centralized exchange. The trade is executed through HTLCs, where both parties agree on the terms and deposit their assets into the DEX smart contract. Once the trade is executed, the assets are automatically swapped between the two parties, and the trade is settled on the blockchain. The HTLC ensures that the assets are returned to the original owners if one of the parties fails to meet the agreed terms.

Lightning Network Atomic Swap: A user wants to exchange their Bitcoin (BTC) for Litecoin (LTC) without relying on a centralized exchange. They connect to the Lightning Network and find a counterparty who agrees to the trade. Both parties deposit their respective assets into a Lightning channel and create a HTLC that locks the assets until the terms of the trade are met. The secret key is generated and hashed, and the LTC is sent to the Bitcoin user, who then has a set amount of time to provide the secret key to claim the LTC. If the secret key is not provided within the agreed time, the LTC is returned to the sender. The trade is settled on the blockchain once the Lightning channel is closed.

  • Location Swap: An innovative technology that makes it possible to easily switch between different locations while using a digital device.

  • Centralized Exchange: Cryptocurrency marketplaces where trading is facilitated between users by an order book maintained by aggregated order systems where the custody of deposited funds on the exchange is taken over by the company.

Distribuie acest articol