An atomic swap is a mechanism that allows for the direct exchange of tokens or assets between two different blockchains without the need for intermediaries. It enables peer-to-peer token transfers across disparate blockchain networks in a [[trustless]] and secure way. In an atomic swap, participants agree to trade their tokens on separate chains using smart contracts. The process typically involves creating hash timelock contracts (HTLCs) on each blockchain, revealing secret hashes, verifying them, and executing token transfers based on predetermined conditions. >[!example] >Here is how the process would play out: >1. **Initiation**: Two parties (Alice and Bob) agree to perform an atomic swap. Alice wants to exchange Token A on Blockchain X with Bob's Token B on Blockchain Y. >2. **HTLCs:** Both Alice and Bob create HTLCs on their respective blockchains. These smart contracts ensure that either both transactions occur as agreed upon within a specified time frame or none of them happen at all. >3. **Reveal Hashes**: Alice reveals a secret hash known only to her related to her transaction details in order to initiate the swap process. >4. **Verification**: Bob verifies the revealed hash matches his expectations before proceeding further >5. **Token Transfer**: Once verification is complete, Bob creates a transaction on Blockchain Y by locking his Token B into the HTLC contract while specifying its release condition based on Alice's revealed secret hash from step 3. >6. **Redemption**: After confirming that his locked funds are secured in the HTLC contract, Bob shares another secret with Alice required for redeeming her funds from Blockchain X. >7. **Claiming Tokens**: Using this second secret shared by Bob, Alice can now claim her locked funds from Blockchain X by providing it as proof within the specified time frame set by the HTLC contract conditions.