Introduction to Blockchain Technology | Atomic Exchange
One type of transaction in the blockchain is atomic exchange. It is a transaction that involves both extensibility and interoperability.
If you want to swap one cryptocurrency for another cryptocurrency, you are likely to switch to the exchange. If you trust a third-party exchange, you can transfer funds to the exchange's address. Once you deposit funds, if there is a trading pair you are interested in. Most exchanges offer BTC and ETH pairs. To exchange two completely different cryptocurrencies or tokens, you must first convert them to bitcoin and convert them to the required encryption.
Atomic exchange is a technology that allows you to complete a peer-to-peer transaction without a third party. They also arrange for you to trade with unknown users without trust. Others must first send their funds because they may decide not to fulfill their transactions. Atomic exchange enables parties to exchange different currencies without trust, based on their pre-agreed conditions, without fear of losing money.
- How to build a distributed exchange based on atomic interchange technology using Oraclize
- Bai Shuo: From the technical point of view, DeFi feasibility, 3 major challenges, 8 big mistakes, how to crack | 2019 Global Blockchain (Hangzhou) Summit Forum
- Technical Guide | Polkadot Wave Card Chain: Building Pre-POC-3 on Substrate
The technology behind atomic exchange
Hash Time Locking Contract (HTLC) supports atomic switching. To understand HTLC, we have to go back and look at the status channel.
The state channel is a two-way communication channel that allows the usual chain transactions to occur outside the chain and interact with the off-chain assets.
One particular type of status channel is the payment channel. As the name implies, the payment channel is the channel for processing payments. You may have heard of payment channels in Lightning Networks or other so-called Layer 2 solutions. HTLC (Hash Time Lock Protocol) is a specific type of payment channel that can exchange two different cryptographic assets.
The "Hashed" part of HTLC means that the hash can be used as a contract lock to protect it from third parties. The "time lock" section refers to the expiration time of the contract. After outlining how to exchange atoms, we will explain to the user what this means.
You must meet two conditions to perform an atomic exchange between two assets: the asset and its underlying blockchain need to support the same hash algorithm, such as bitcoin's SHA-256, and both blockchains need to be supported. Some kind of programmability, this is to allow deployment of HTLC.
process
Once these two conditions are met, you can create an HTLC. The process of atomic exchange is as follows. We assume that Alice has some BTCs and Bob has some ZENs. Both agree to exchange a certain amount of assets
1. Alice generates an address with an HTLC on the Bitcoin blockchain. Smart contracts usually have an address and hash time lock so you can interact with them.
2. Alice generates a key (random number) and derives a hash lock from its key by a hash random number (key). This key can be locked. This step is similar to generating a private key and exporting an address from it, as we described in Public Key Encryption (TI 2.3) .
3. She now deposits the agreed BTC amount into HTLC.
4. Alice locks her funds with the hash lock she created and sends her locked copy to Bob.
5. Bob uses Alice's hash lock to create an address with the HTLC on the Horizen blockchain.
6. Bob deposits the agreed ZEN amount into the contract address and locks it.
At this point, both participants locked in the funds they agreed to exchange. Since both blockchains are public, each blockchain can verify the amount deposited. Now only Alice has the key to unlocking the funds for the two blockchains. If she does not continue to unlock the funds, the time lock will return the funds to the original owner after a period of time. In this way, she can't unlock them by locking them and not getting the keys. So I can't deceive Bob and I can't let Bob lose their money. If she continues the next two steps, this also happens at the same time.
7. Alice uses the key to unlock Bob's ZEN and transfer it to the address she controls. When Alice unlocks funds by monitoring his HTLC, Bob learns about Alice's key.
8. Bob uses the key he just received to unlock Alice's bitcoin and transfer it to the bitcoin address he controls.
9. The two sides have now successfully exchanged funds without mutual trust.
Since this is an automated process, steps 7 and 8 occur simultaneously, and neither party needs trust. Either the two get funding, or no one gets the other's funds.
Today's atomic exchange
Few wallets or decentralized exchanges enable users to exchange atoms. So far, there are only a few atomic exchanges, and the history here is short:
The first chain of atomic exchanges was completed between Septembercoin and Decred on September 20, 2017.
In November 2017, the first offline atomic exchange took place between Litecoin and Bitcoin on the lightning network.
A detailed description of the Ethereum – Bitcoin atomic exchange can be found here
Recently on December 7, 2018, TenX used their open source software COMIT to demonstrate ERC20 to bitcoin lightning network for atomic exchange.
The technology is very promising, but for both the wallet and the exchange to be atomically exchanged, a user-friendly interface must be built to use atomic switching.
to sum up
Atomic exchange is an alternative to centralized exchanges. Under no circumstances are there any third parties involved in accessing user funds. The exchange process has no trust at all, almost instantaneous. A hash time lock contract is the core of atomic exchange. I think: If Atomic Swap compatibility is not solved, there will be no large-scale use, and there is still a long way to go.
This is the last article on trading in the advanced section. To find out how the deal works, what types of deals, or more details, you can visit our high-level articles. In the high-level section, we will continue to introduce privacy protection techniques on the blockchain.
About Horizen , a platform for money, information, and media, a secure and private platform.
We will continue to update Blocking; if you have any questions or suggestions, please contact us!
Was this article helpful?
93 out of 132 found this helpful
Related articles
- Polkadot wave card chain: verify node security and usability aspects
- Popular Science | Read the Bitcoin Schnorr signature in one article
- Plasma: Ethereum chain scalability framework combat part 1
- Technical Guide | Web3.js is based on the Ethereum Javascript API
- Some science about Ethereum 2.0
- How is practical programmability implemented in the securities pass?
- Decred technical white paper Chinese version