A succinct walkthrough of a cross-chain atomic swap.
Imagine that Alice and Bob meet in a crypto trading chat room and agree to a trade: Alice will give Bob 1 BTC in exchange for 100 DCR. Typically they would then seek out a trusted member of the chat room to escrow the transaction - that user may or may not charge a fee for the service, and the trade's success is entirely dependent on the third party. Far from ideal.
Enter the Cross-chain Atomic Swap. This fancy new technology allows Alice and Bob to make trades directly with no counterparty risk. It goes like this:
- Alice gives Bob her BTC wallet address, and Bob gives Alice his DCR wallet address.
- Alice generates a secret, K, and a cryptographic hash of the secret, K*.
- Using the cryptographic hash K*, Alice pays into a BTC contract transaction that Bob can redeem within 48 hours if he knows K. Otherwise, it is refunded to Alice's wallet address.
- Alice shares the contract with Bob (off-chain). Bob audits the contract and extracts K*.
- Using the cryptographic hash K*, Bob pays into a DCR contract transaction that can be redeemed with the secret, K, within 24 hours.
- Bob shares the contract with Alice (off-chain). Alice audits the contract.
- Alice uses the secret, K, to redeem the DCR contract transaction.
- Bob extracts K from the previous transaction where Alice redeemed the DCR sent to her by Bob.
- Bob now has at least 24 hours to redeem the BTC contract transaction using K.
Two takeaways:
- A cross-chain atomic swap does not take place entirely on-chain - a communication channel is necessary to share wallet addresses and contracts. This channel can take the form of an email or a secure messaging client (Lightning Network will make this easier.)
- The advent of cross-chain atomic swaps does not mean exchanges are going out of business; there is still a need for infrastructure to maintain an orderbook, match counterparties, etc.
Congratulations @ldcicconi! You received a personal award!
You can view your badges on your Steem Board and compare to others on the Steem Ranking
Do not miss the last post from @steemitboard:
Vote for @Steemitboard as a witness to get one more award and increased upvotes!