Chapter 0 Introduction
Cross-chain is the most popular technology in this year's blockchain. There are many projects with cross-chain technology. The main battlefields of superstar cosmos and polkadot are cross-chain.
But what does it mean to cross the chain?
- Popular science | Five differences between Cosmos and Polkadot
- In-depth interpretation of the power struggle within the Cosmos team
- The founder runs away, Cosmos strife
- Video|"8" He Bin: I want to copy myself in the digital world
- Cosmos director broke: Jae Kwon stepped down as CEO to avoid responsibility
- Ethereum co-founder Joseph Lubin: EOS is too central, only Ethereum can be used as a global settlement
Chapter 1 Asset Cross-Chain
Cross-chain technology has emerged very early, and in 2013 there was a lot of technology discussing the cross-chain of Bitcoin. There are three major cross-chain technologies, lightning network, side chain and relay.
Before the emergence of Ethereum, the blockchain rarely talked about “contracts”. At that time, it only talked about “coins”. At that time, cross-chain technology refers to “cross-chain of assets (coins)”. Assets cross-chain, perhaps should be called currency cross-chain.
The asset cross-chain is simply that the two chains of coins are sent to each other. But how is this done? There are many cross-chain technologies for coins, such as two-way-peg, hash time lock, atomic exchange, asset pledge transfer, gateway, federal signature, and so on.
Two-way anchoring is a very important concept in Bitcoin sidechain technology to achieve cross-chaining between Bitcoin main chain coins and sidechain coins. Two-way anchoring allows the sidechain to "know" whether a particular coin on the main chain is locked, and thereby lock the state to unlock or destroy the corresponding number of sidechain coins. It is as if the BTC "crosses" into the side chain, or vice versa, the side chain coins "cross" back to the main chain.
Bitcoin is a decentralized exchange where Bitcoin can be traded. Hey, how does bitcoin appear here? The gateway technology is used. The principle is simple, that is, the user sends the bitcoin to a place called "gateway", and then the "gateway" will generate a bitcoin stable currency in the bit stock circulation. When the user wants to mention bitcoin, the gateway will destroy the bitcoin stable currency and then send the same amount of bitcoin to the user.
The cross-chain of coins has a very important concept called "atomic exchange." The so-called atomic exchange refers to: a transaction on the A chain, and a transaction on the B chain, either simultaneously or not.
For example, BTC and LTC, two people, Zhang San is willing to take 1BTC for Li Si's 100 LTC. In order to prevent the breach of contract, the two sides use atomic exchange technology to complete the currency exchange.
Zhang San gave Li an LTC address; Li Si gave Zhang a BTC address.
Zhang San used the atomic exchange protocol to construct a BTC transaction, and sent 1BTC to the BTC address of Li Si. The condition for the establishment of the deal was that Zhang San’s LTC address received 100 LTC from Li Sifa.
Li Si built an LTC transaction using the atomic exchange protocol and sent the 100LTC to Zhang's LTC address. The condition for the establishment of this LTC transaction was that Li Si’s BTC address received 1BTC from Zhang Sanfa.
The above two transactions are either established at the same time, or they are not established at the same time. No party can do it without receiving the currency of the other party. This is the cross-chain of coins. In essence, the cross-chain of coins does not have real coins running from one chain to another, but the state in which the coins are locked and unlocked in the respective chains.
Chapter 2 Contract Cross-chain
After the birth of Ethereum, the blockchain began to discuss a lot of smart contracts. Smart contracts are essentially code that can be triggered by specific data on the blockchain.
Smart Contracts We can simplify understanding as a function, enter specific parameters, the code will automatically trigger execution, you can get specific results, and give a stable output.
f() is the contract code
x is the condition of the activated code
y is the result of the contract execution. For smart contracts that don't cross the chain, f(), x, and y are all on one chain and don't appear on multiple chains.
Give an example.
EOS crowdfunding is a smart contract, this contract has a contract address.
The user can transfer ETH to this contract address from the Ethereum address of the private key that he controls.
The EOS crowdfunding contract calculates the total number of ETHs received at the contract address every 23 hours and calculates how many EOS tokens each user's address will receive.
After 23 hours, the user can initiate a call to the contract address and ask the contract to return the calculated EOS token.
This EOS crowdfunding contract will send the corresponding EOS token to the user's Ethereum address. But the smart contract on Ethereum, the code is in the Ethereum blockchain, to activate the contract also need to send a specific transaction on the Ethereum blockchain.
After the birth of Ethereum, the entire blockchain community has created a very large number of chains, many of which have the function of smart contracts. Then someone came up, can we post a smart contract on a chain, and then trigger the smart contract to perform a specific operation based on the specific information of another chain?
This is the contract (call) cross-chain.
For example, if someone makes an ICO, the target is the crowdfunding stable USDT (for example, we only consider this is the Omni version of the USDT), the stable currency can avoid the risk of volatility. The project will announce the BTC address of the receipt of the currency to the outside world.
And because it is not convenient to build tokens on Bitcoin. The project party built the ERC20 token in Ethereum. The project side distributes these ERC20 tokens by building a smart contract that supports cross-chaining.
The user transfers the USDT to the BTC address published by the project party using the BTC address of the private key.
The smart contract can read the status of the receipt of the BTC address published by the project party, the contract can read the user's payment address, and calculate the corresponding token amount.
The user initiates a call to the contract via the Ethereum wallet and its own bitcoin address specific signature.
The contract pays the user ERC20 tokens based on the calling function and the calculation result. You see, this kind of contract involves two chains, which is the contract cross-chain. A smart contract on a chain that reads specific information from another chain to execute the contract code and gives deterministic results.
Chapter 3 Cross-chain application examples
What is the use of cross-chain?
The first scenario is a decentralized exchange. Dependent coins can be cross-chained, support users to place orders, provide cross-chain contracts to provide a match, and synthesize cross-chains of used coins to complete the transfer of coins. In theory, it can be done without relying on a specific server.
The current decentralized exchanges, Ethereum and EOS exchanges are not strictly cross-chain decentralized exchanges. Both are transactions between ETH and ERC20, and transactions with tokens on EOS and EOS. The BitShares is a decentralized exchange that transfers BTCs and the like to the BTS intranet for trading through the way the gateway issues stable currencies.
The second scenario is asset collateral. Whether the coins on one chain are unlocked depends on the specific information on the other chain.
The third scenario is a smart contract that reads out-of-chain data (prophecy). For example, gambling, there is a special extra-chain data, that is, a prophecy machine, providing the results of the game. Then the user gambles through the contract on the Ethereum, the two parties push the coin into the contract, and the contract collects the specific data of the predictor to decide who the gambling money belongs to.
Chapter 4 Implementing a Cross-Chain Ecology
There are two situations in which the concept of cross-chaining is proposed. The first case is to cross each other between existing chains. For example, let Ethereum and Bitcoin cross each other. The second case is that I create a standard, and then everyone will design new chains according to this standard. All these new chains can be very convenient.
In the early days of the cross-chain concept, everyone thought about the first situation. The most famous are the lightning network, relay and side chain three technologies. In the ecology where the existing chains cross each other, it is not possible to issue a coin called “cross-chain coins”. Cross-chain technology Bunsen is not going to issue coins. For example, lightning network is not a kind of currency, just a technology.
But the existing chains cross each other, because the design of the respective chains has not considered the situation that you want to cross me and my cross, so the cross-chain is still very difficult. You have seen the side chain, relay, lightning network, etc. have developed for so many years, have you actually done cross-chain? No.
Because of the early chain, many are basically copying bitcoin technology. For example, LTC basically copies BTC. The code is copied, so there is a theoretical basis for each other.
After the first situation has developed for so many years, everyone invented, oh, this stuff can't be done. Then said, forget it, it seems that we still have to find a way to do something else. This gave birth to this year's cross-chain hot.
Today's cross-chain hotspots actually include chain-building technology. I designed a blockchain myself, such as cosmos, polkadot, vsystem. These blockchains contain a set of chaining protocols that design a new chain according to specific criteria. As long as the chain is designed under this standard, it is very easy to cross each other. These standard protocols are cross-chain infrastructure.
Of course, in the second case, not only the newly created chains can cross each other, but they also find ways to make existing chains join the cross-chain ecosystem. That is to say, in the second case, the first case is often included. Both cosmos and polkadot are implemented using a relay-like technique and an existing chain span.
Polkadot will call the relay chain across the existing chain. The principle is to lock the assets in the original chain by multiple signatures, and then issue the corresponding stable currency on the relay chain.
Chapter 5 Conclusion
The future is a chain of cross-straits? Or is the chain all the same?
[Lightning & OKEx Research joint release]
Author: Huang Shiliang
Welcome to WeChat public number: Lightning HSL
Welcome to BTM: bm1qefc720au672awrgazgw5c3kx7etr5kejju02p7