An atomic swap is a technology that lets two people exchange cryptocurrencies directly with each other, no exchange, no middleman, and no third party holding anyone’s funds. A transaction will always take place for either party in its entirety or not at all. The guarantee of all-or-nothing, which gives the word “atomic” its name, derives from the fact that an atom is said to refer to the smallest indivisible unit in chemistry, as is an atomic swap in crypto.

At the back end of atomic swaps is a cryptographic tool called a Hash Time-Locked Contract (HTLC). It can also be viewed as a safety deposit box having two keys and a timer. When two parties want to exchange bitcoin for litecoin in their possession, a smart contract locks bitcoin in this box. The other person can only open it by revealing a secret code, but the moment they use that code to claim your Bitcoin, the same code automatically unlocks your Litecoin on their end. In case the counter-party decides to walk away or the timer runs out, the funds will be returned to both counter-parties. The parties involved can’t run off with each other’s money because the contract automatically enforces the rules.

To understand the implications of this scenario, picture attending a venue in person where you want to exchange 0.01 BTC for some Litecoin with a random person on the internet. Typically, you both deposit funds on a centralized exchange, say, Binance, trust the platform to do the swap, and then withdraw. In such cases, the trader’s and counterparty’s funds are held in an escrow account by the exchange, which exposes you to risks, delays, and fees from the exchange. An atomic swap does away with all of that. You and the counterpart make a trade directly, from wallet to wallet, across two distinct blockchains. Your funds are never touched by Binance.

The concept, first documented by developer Tier Nolan on the Bitcointalk forum, dates all the way back to 2013 with the HTLC mechanism. In September 2017, the Litecoin Foundation carried out a swap of Bitcoin and Litecoin, which was the first-ever atomic swap. This single transaction is enough to show that two independent blockchains can communicate and settle a trade without the need for a central coordinator.

Join our newsletter

Today, atomic swaps remain a foundation of decentralized exchange design, even though most everyday users interact with them indirectly through DEX aggregators and cross-chain bridges. For the crypto ecosystem, they represent something important: the ability to trade without trust. You do not need to trust the other person, the platform, or any intermediary. The math does the trusting for you.

Disclaimer: Coin Medium is not responsible for any losses or damages resulting from reliance on any content, products, or services mentioned in our articles or content belonging to the Coin Medium brand, including but not limited to its social media, newsletters, or posts related to Coin Medium team members.

Related Terms

Gas Optimization

Gas optimization in crypto is basically making sure your blockchain transactions and smart contracts are as “cheap” as possible. When you use any blockchain, you have to pay a fee, which is called gas. The more complex the transaction and the time required for it, the more expensive the fee gets. On networks like Ethereum (and any chain that works like it), every little action costs a certain amount of “gas units,” whether it’s sending tokens, swapping on a DEX,

Transaction

A crypto transaction refers to the transfer of any data or value on a blockchain. Sending Bitcoin to a friend? Swapping one token for another on a decentralized exchange? Or interacting with a smart contract, a piece of code on the blockchain that automatically runs, are all called transactions. Every single one of these actions gets logged on the blockchain forever, where it cannot be changed or erased. Imagine a blockchain transaction similar to a bank wire transfer. Except in

Governance Attack

A governance attack happens when a bad actor accumulates enough voting power in a decentralized protocol to push through a proposal that benefits themselves, usually at the expense of everyone else. Most DeFi protocols give their users the ability to vote on decisions like fee changes, treasury spending, or upgrades to the code. That voting power is typically tied to how many governance tokens a person holds. When someone buys or borrows a massive amount of those tokens specifically to