Sending assets from one blockchain to another directly is normally impossible. At least, it’s not possible in a trustless way. As a result, the cryptocurrency market is fragmented — centralized intermediaries are required to move funds from one network to the other. And that’s now what we want.
Atomic Swaps use Hash Timelock Contracts (HTLC) — a type of time-bound smart contract that requires both users participating in a transaction to acknowledge the receipt of funds. If both parties don’t confirm that the transaction is successful, the operation is reverted and funds return to original senders.
Atomic Swaps enable a cross-chain exchange of assets without intermediaries. In other words, without a centralized exchange. Thus, Atomic Swaps deliver on the true promise of cryptocurrency, making the market decentralized.
For example, imagine that two traders, Alice and Bob, want to exchange a token, based on NEO with a token, based on EOS.
Alice initiates his transaction on the NEO blockchain and generates a secret string. The created string is then used to generate a unique hash that is included in the transaction. On the other end, Bob sees Alice’s hash, initiates a transaction in the EOS blockchain with the same hash.
Alice and Bob then need to confirm the transaction by unlocking their respective funds using Alice’s secret. Unless they do it within a specified time-frame, the transactions will be deemed failed and funds will return to senders.
First, Alice sees the transaction from Bob and unlocks Bob’s funds using the secret that was generated earlier. Bob sees that Alice successfully unlocked his funds and unlocks Alice’s funds using the same secret, which Alice made public by unlocking Bob’s funds.
The image below shows how Atomic Swaps function:
Learn more about Nimera Blockchain 2.0 on the website.