Latest news about Bitcoin and all cryptocurrencies. Your daily crypto news habit.
What exactly is an atomic swap?
Atomic swaps, or atomic cross-chain trading, is the exchange of one cryptocurrency for another cryptocurrency, without the need to trust a third-party.
A relatively new technology, atomic cross-chain trading aims to revolutionize the way in which users transact with each other. For example, let’s say Alice owns 1 Qtum but would like 1 Guppy instead. She’ll have to make an exchange, right? Well, with atomic swap, if Bob owned 1 Guppy but wanted 1 Qtum instead, he and Alice would be able to simply make a trade!
And in order to create trust and prevent all sorts of problems like one-way trades (Alice accepting Bob’s 1 Guppy but then failing to send over her 1 Qtum), atomic swap utilizes what is known as hash time-locked contracts (HTLCs) — genius really.
What’s this useful for?
Over the last few years we’ve seen a large number of decentralized exchanges (DEX). The main purpose of these exchanges was to exclude the third party from the trading (p2p trading without a broker), a purpose that wasn’t really achieved mainly because of the inability to quickly execute trades outside of the blockchain it was built upon.
The recent blockchain hype has led to a surge in currency prices. The overall market for cryptographic currencies this week surpassed $700 billion. Such an increase in market cap is always accompanied by the high volatility of the currencies, and such volatility requires traders to be able to execute cross-chain transactions immediately, which is not fully possible on DEX today.Those limitations have resulted in very poor adoption and limited trading volume on DEX platforms.
Atomic swaps are the future P2P exchanges field
The main advantage of the atomic swap in the P2P exchanges field is that from now on, traders in DEX can trade coins from other chains and actually “lock” the price of a currency traded on another network immediately, thereby being less exposed to the risk of coin volatility, making them a real P2P exchange. By providing P2P exchanges to users and traders, liquidity is guaranteed and never relies upon a central exchange . We remove the middleman and begin exchanging P2P, decentralized, just as it should be with cryptocurrencies.
The last few months have been very exciting for atomic swap and its impact on the blockchain community. Companies like Komodo, Litecoin, Vertcoin and Decred have all successfully implemented atomic swaps, and many of us can say that Charlie Lee’s announcement of the Litecoin/Bitcoin atomic swap is one of the most important developments in the cryptocurrency world.
Charlie Lee, Litecoin CEO announces successful atomic swap between Litecoin and Bitcoin
Matchpool has developed the implementation of GenericSwap, which will be the first contract to offer an exchange of Qtum, Ethereum and ERC20-based tokens across Ethereum and Qtum chains. This is a a groundbreaking step on the way to P2P exchange and this step may lead to another huge win if we can influence other companies to make an effort and develop open source solutions for the community.
Now for some Technicalities.
Atomic swaps involve each party paying into a contract transaction, one contract for each blockchain. The contracts contain an output that is spendable by either party, but the rules required for redemption are different for each party involved.
Before a cryptocurrency can successfully support atomic swaps it must meet the following fundamental requirements:
Hash time-locked contracts (HTLC)
Hash time-locked contracts (HTLC) ensure that the atomic swap process is completely trustworthy by ensuring both parties fulfill the requirements of the trade.
HTLCs require the recipient to acknowledge receiving the payment ahead of a predefined deadline by generating cryptographic proof of payment. By failing to do so, the recipient risks losing the right to claim the payment and the sender is entitled to receive back the funds.
To implement a HTLC on a transaction to occur between two different blockchains, it is necessary for both blockchains to share the same cryptographic hash function, such as SHA-256.
Now, let’s go back to Alice and Bob
Alice owns 1 Qtum and she just heard about Matchpool and Guppy so she wants to sell her 1 Qtum in exchange for 1 Guppy. We also have Bob who owns 1 Guppy and wants 1 Qtum instead.
After agreeing to the terms, Alice generates a secret key on the Qtum blockchain and pays the intended trade amount into a contract transaction.The contract output can be redeemed by Bob as long as he knows the secret key. If Bob does not redeem the contract transaction in the time allotted, the contract expires and the contract output can be refunded back to Alice’s wallet.
Bob (the counterparty) creates a similar contract transaction to Alice’s but on the Ethereum blockchain and pays the intended Guppy amount in the contract. In order for Bob to create his contract, Alice does not need to reveal her secret key, but she must send Bob the cryptographic hash of the secret key (which can be made public). However, for Alice to redeem the payment she must reveal the secret key, and therefore, once Alice redeems the payment, Bob will be able to as well.
In this example, Bob’s redemption period will be longer than Alice’s in order to eliminate Alice’s advantage of knowing the secret key. If the funds were not redeemed within the redemption periods and both periods ended, each contract creator can be refunded.
Once each side pays into a contract on each blockchain, and before the allotted time expires (during which neither side can refund), Alice redeems Bob’s Guppy contract, and thereby revealing the secret key to Bob. The secret key is then extracted from Alice’s transaction, thereby providing Bob with the ability to redeem Alice’s Qtum contract.
This procedure is atomic, meaning with a timeout, as it gives Alice and Bob a limited amount of time to redeem their coins on the other blockchain before a refund can be performed.
Download and try Atomic Swap via GitHub
Join our Community here Join our Announcements hereSend us Feedback here
Matchpool Adds Atomic Swap to its Arsenal was originally published in Matchpool on Medium, where people are continuing the conversation by highlighting and responding to this story.
Disclaimer
The views and opinions expressed in this article are solely those of the authors and do not reflect the views of Bitcoin Insider. Every investment and trading move involves risk - this is especially true for cryptocurrencies given their volatility. We strongly advise our readers to conduct their own research when making a decision.