Atomic Swap

An atomic swap is a smart contract technology that enables the exchange of one cryptocurrency for another without a third-party intermediary.

Contenido pendiente de traducción. Se muestra la versión en inglés.

Atomic Swap Phases: 1. Setup: Hashing a secret. 2. Lock: Creating HTLCs on both chains. 3. Reveal: Initiator claims funds, revealing secret. 4. Complete: Respondent claims funds using the revealed secret. Key benefits: No exchange fees, no custodial risk, total privacy.

        graph LR
  Center["Atomic Swap"]:::main
  Pre_blockchain_interoperability["blockchain-interoperability"]:::pre --> Center
  click Pre_blockchain_interoperability "/terms/blockchain-interoperability"
  Pre_proof_of_stake["proof-of-stake"]:::pre --> Center
  click Pre_proof_of_stake "/terms/proof-of-stake"
  Rel_staking["staking"]:::related -.-> Center
  click Rel_staking "/terms/staking"
  classDef main fill:#7c3aed,stroke:#8b5cf6,stroke-width:2px,color:white,font-weight:bold,rx:5,ry:5;
  classDef pre fill:#0f172a,stroke:#3b82f6,color:#94a3b8,rx:5,ry:5;
  classDef child fill:#0f172a,stroke:#10b981,color:#94a3b8,rx:5,ry:5;
  classDef related fill:#0f172a,stroke:#8b5cf6,stroke-dasharray: 5 5,color:#94a3b8,rx:5,ry:5;
  linkStyle default stroke:#4b5563,stroke-width:2px;

      

🧒 Explícalo como si tuviera 5 años

Think of an [atomic swap](/es/terms/atomic-swap) like a safe with two keys. You put your money in and set a timer. The other person puts their money in another safe and sets the same timer. If you both swap keys before the time runs out, you both get the money. If one of you disappears, the safes automatically open after the timer ends and give the money back to the original owners. No middleman needed!

🤓 Expert Deep Dive

Technically, the process involves User A generating a secret s and its hash H(s). User A creates an HTLC on Chain 1 that can be spent by User B only if they provide s. User B then creates an identical HTLC on Chain 2 using the same H(s). Once User A redeems the funds on Chain 2 by revealing s, User B sees s on the public ledger and uses it to redeem the funds on Chain 1. The 'Time-Locked' aspect is crucial: Chain 1's lock must be significantly longer than Chain 2's to prevent a 'Race Condition' where User A redeems and then User B's lock expires before they can react.

🔗 Términos relacionados

📚 Fuentes