Atomic Swap Protocol
The technique allows direct peer-to-peer exchanges between users across different chains
Atomic swaps allow two parties to exchange assets across different blockchains without trusting a third party, and transactions are either completed in their entirety or not at all.. This can be achieved using hashed time-locked contracts (HTLCs).
How It Works:
Initiate Swap:
User A on Chain A wants to swap Token 1 for Token 2 with User B on Chain B.
User A locks Token 1 in an HTLC on Chain A.
User B locks Token 2 in an HTLC on Chain B.
Hash Preimage:
Both HTLCs are created with the same hash lock and time lock.
User A generates a secret (preimage) and hashes it. The hash is shared with User B.
Redeem Tokens:
User B can unlock Token 1 on Chain A using the preimage.
Once User B reveals the preimage, User A can use it to unlock Token 2 on Chain B.
Fallback Mechanism:
If the swap is not completed within a specified time, both HTLCs expire, and the tokens are returned to their original owners.
This mechanism ensures that tokens are directly swapped atomically between private pools without needing shared pools.
Last updated