How atomic swaps work
The “atomic” in “atomic swap” comes from the software world. In a database system, atomicity is when a transaction is all or nothing -- it either executes in full or not at all. The term “atomic swap” describes an exchange of two cryptocurrencies that is automatically executed in full (or not at all) when certain conditions are met.
This idea of swapping two cryptocurrencies from different blockchains was first envisioned early in the crypto industry’s history. It was first described in 2012, just a few years after Bitcoin (BTC +3.30%), the first cryptocurrency, made its debut. The first atomic swap took place in 2017 when Decred (DCR +1.78%) and Litecoin (LTC +1.16%) were exchanged without using a fiat currency as part of the conversion. A few days later, Litecoin and Bitcoin were exchanged.
But how is a trustless transaction between two parties who don’t know each other carried out, especially without an intermediary (a bank, an exchange, a payments network, etc.) making sure everyone plays fair? Cryptography and smart contracts are the answer.
In an atomic swap, smart contacts are used to create a virtual vault that can be used to perform an agreed-upon swap of cryptos. To use it, the first person sends their money to a specific contract address, where it is locked. The second person is notified and can confirm the first deposit, and then they lock their money into a second vault address. After the contract verifies that both parties have locked their money as promised, then they can each retrieve their swapped funds. If either party fails to perform, the swap times out and both get their money back.
Sound complicated? You don’t need to be a blockchain software developer to execute an atomic swap. Decentralized crypto exchanges such as Uniswap (UNI +2.56%) and PancakeSwap (CAKE +2.78%) can facilitate atomic swaps. All users need to do is connect a crypto wallet to get started.
Pros and cons of atomic swaps
Atomic swaps are an important development for the crypto space as they attempt to create a more frictionless economy. There are benefits to technology-powered peer-to-peer transactions, but atomic swaps aren’t always the best method of exchange.
Pros of atomic swaps
- A centralized exchange is removed from the equation, which can lower fees.
- Eliminating intermediaries can speed up transaction time.
- The need for making exchanges using fiat currency is removed.
- Atomic swaps make it possible for different blockchain networks to be more interoperable.
Cons of atomic swaps
- Not all cryptos can be traded with atomic swaps; two cryptos have to be based on blockchain networks that utilize the same cryptographic hashing algorithm.
- There are a few more steps involved with atomic swaps versus using a centralized exchange, although the process is getting easier.
- Atomic swaps don’t facilitate exchanges between crypto and fiat currency.
- As with most things in digital currency, privacy and security risks are a potential factor; current atomic swap implementations do not offer strong transaction privacy, but there are proposals in the works for privacy enhancements.
Related Investing Topics