Back to Glossary

Atomic Swap

Atomic Swap Definition: An atomic swap is a peer-to-peer exchange of cryptocurrencies between two parties across different blockchains without using a centralized intermediary like an exchange. Atomic swaps use cryptographic hash functions and time-locked contracts to ensure both parties fulfill their obligations simultaneously — if one party fails to deliver, both transactions automatically cancel. For example, Alice can swap Bitcoin directly for Monero with Bob without trusting an exchange with their funds. Atomic swaps eliminate counterparty risk and are powered by Hash Time Locked Contracts (HTLCs) on blockchains supporting smart contracts.

What Is an Atomic Swap?

An atomic swap is a direct peer-to-peer trade where two parties exchange cryptocurrencies without an intermediary. Instead of using an exchange (which holds both parties’ funds and charges fees), the swap is executed directly between wallets using smart contracts or protocol-level features.

The key word is “atomic” — meaning indivisible. Either the entire swap completes (both parties get their coins) or the entire swap cancels (both parties get their original coins back). There’s no middle state where one party gets coins and the other doesn’t.

How Atomic Swaps Work

Atomic swaps use Hash Time Locked Contracts (HTLCs) to guarantee fairness:

  1. Alice proposes: Alice creates a contract: “If someone provides the preimage to hash X by timestamp T, they receive my Bitcoin. If no one does, my Bitcoin returns to me.”
  2. Bob accepts: Bob sees Alice’s contract and creates a mirrored contract: “If someone provides the preimage to hash X by timestamp T-48 hours, they receive my Monero. If no one does, my Monero returns to me.”
  3. Alice reveals preimage: To claim Bob’s Monero, Alice must reveal the preimage to hash X. She submits it to Bob’s contract.
  4. Alice gets Monero: Alice’s preimage is now public on the blockchain. Bob’s contract executes, sending Monero to Alice.
  5. Bob claims Bitcoin: Bob sees the preimage on the blockchain and uses it to claim Alice’s Bitcoin. Alice’s contract executes, sending Bitcoin to Bob.
  6. Atomic completion: Both swaps have occurred. Neither party can cheat.

Worked example: Alice holds Bitcoin and wants Monero. Bob holds Monero and wants Bitcoin. They agree to swap 1 BTC for 5 XMR. Alice creates an HTLC contract with a hash (hash of secret “abc123”). Bob creates a mirrored contract. Alice reveals “abc123” to claim Bob’s Monero. The preimage becomes public. Bob uses the same preimage to claim Alice’s Bitcoin. Done — 1 BTC traded for 5 XMR, peer-to-peer, no exchange, no fees beyond normal blockchain transaction costs.

Atomic Swaps vs. Centralized Exchanges

Aspect Atomic Swaps Centralized Exchange
Counterparty risk None — code enforces fairness High — exchange could be hacked or shut down
Custody Self-custody — you control keys Exchange custody — exchange controls keys
Fees Only blockchain fees (~$0.01–$50) Trading fees (0.1%–1%)
Speed Slow — depends on blockchain confirmation times Fast — instant settlement
Liquidity Low — requires finding trading partner High — many buyers/sellers available
Complexity Complex — requires understanding contracts Simple — one-click trading

Why Are Atomic Swaps Important for Traders?

Atomic swaps represent the ideal of decentralized trading — no middleman, no fees, no counterparty risk. However, in practice, they have limitations. Blockchains must support smart contracts or HTLCs for atomic swaps to work. Bitcoin and Monero support HTLCs, but older chains don’t.

Atomic swaps are most useful for privacy-focused traders who want to avoid exchanges tracking their activity. Swapping Bitcoin to Monero via atomic swap leaves no exchange record, preserving privacy.

On PrimeXBT, you trade CFDs, not spot crypto, so atomic swaps don’t directly apply. However, understanding atomic swaps helps you appreciate the complexity of decentralized trading and why centralized exchanges, despite their custodial risks, are still the dominant model for crypto trading.

Key Takeaways

  • An atomic swap is a peer-to-peer cryptocurrency exchange across different blockchains without a centralized intermediary — both parties’ transactions execute simultaneously or both cancel.
  • Atomic swaps use Hash Time Locked Contracts (HTLCs) to enforce fairness cryptographically — neither party can cheat because the contract code guarantees simultaneous execution.
  • Atomic swaps eliminate counterparty risk (no exchange to hack) and reduce fees (only blockchain costs), but require finding a trading partner and suffer from low liquidity compared to exchanges.
  • Blockchains must support smart contracts or HTLCs for atomic swaps — Bitcoin and Monero support them, making cross-chain swaps possible.
  • Atomic swaps appeal to privacy-focused traders seeking to avoid exchange records — trading Bitcoin to Monero via atomic swap leaves no centralized exchange record.
FAQ section

Are atomic swaps faster than exchanges?

No, they're slower. An exchange trade settles in seconds. An atomic swap requires blockchain confirmations (10 minutes for Bitcoin, 2 minutes for Ethereum, etc.), plus time for both parties to act. Atomic swaps trade speed for decentralization.

What if the other party disappears after I reveal my preimage?

The HTLC contract handles this. Your preimage becomes public, but if the other party doesn't claim their coins within the time limit, their contract expires and their coins return to them. You'd need to recover through other means — atomic swaps don't prevent counterparty disappearance after both transactions confirm.

Do atomic swaps work between all blockchains?

Only between blockchains that support HTLCs (Bitcoin, Litecoin, Monero, Ethereum, Dash). Blockchains without script-like capabilities (older coins) don't support atomic swaps. Ethereum and other smart-contract chains can use more flexible atomic swap protocols.

Forced Liquidation
Forced Liquidation Definition: Forced liquidation is the aut...
Isolated Margin
Isolated Margin Definition: Isolated margin is a position ma...
Checkable Deposits
Checkable Deposits Definition: Checkable deposits are bank a...
BSC (Binance Smart Chain)
BSC Definition: Binance Smart Chain (BSC), now officially re...

Live Chat

Contact our support team via live chat.

Help Center

Questions about our services?
Check out our Help Center.

Risk Warning:
Trading in leveraged products carries a high level of risk and may not be suitable for all investors.