Reading this article requires the following knowledge reserves
1. Understanding the fundamentals of blockchain
2. Understanding the concept of smart contracts and consensus mechanisms
I am curious to learn how to exchange data with the outside world (traditional Internet systems) under the Blockchain network system, in short, how the intelligent contracts within the blockchain system share and exchange data with traditional Internet systems.
Suppose in the blockchain system of the rental app, the tenant and the landlord reached a lease agreement, which has a smart contract, in the check-out, if the tenant broke the living room Millet 9A TV, you need to check out the official price of millet on the day of the original compensation. In the blink of an eye to check out that day, the tenant in the app click on a button to check out, the app automatically issued instructions let the living room millet 9A TV self-test (confirm damage), because the tenant in the course of use, did break the millet TV, resulting in the self-test results triggered the compensation clauses in the smart contract, unfortunately, The day of Millet Tmall flagship store is doing activities, than Xiaomi Mall to be cheaper 300 yuan, at this time the Intelligent contract compensation amount to whichever price.
In our traditional way of thinking, a smart contract initiates an external request to a third-party Xiaomi (assuming Xiaomi provides an external query interface) and then executes the smart contract based on the price returned by the interface, but doing so will encounter the following issues:
1, because the blockchain is a consensus-based system, assuming that there are 10,000 miners, the miners must agree on the amount of compensation (Xiaomi TV 9 a price) to be effective, and each miner's intelligent contract is executed independently, so that 10,000 miners will be sent to Xiaomi system Price inquiry request, Not only inefficient, but also create a huge waste of resources.
2, if the miners network conditions are different, causing delays, once the official price of millet fluctuations, it will lead to the miners to obtain a different price, can not form a consensus.
Prophecy Machine
In the above example, there are some problems, such as the third-party millet to provide reliable data. Whether it will be tampered with maliciously. In order to solve these problems, the concept of prophecy (Oracle, not the Oracle database) was born. A prophecy is a trustworthy entity that introduces information about the state of the outside world by signing, allowing the identified smart contracts to respond to an uncertain external world. The prediction machine has the characteristics of non-tamper, stable service and auditing, and it has economic incentive mechanism to guarantee the running power. This is really a burning brain, but it's easy to understand the combination of the above examples.
Suppose there is now a third-party system (prophecy) that provides authoritative, accurate, non-tamper, stable, and auditable price-querying interfaces, including querying the price of Xiaomi 9A TV, which automatically triggers the Oracle when the compensation smart contract is executed, sending a transaction to the blockchain, The data block of the transaction carries the price of Xiaomi TV 9 A, which, along with the synchronization of each miner's node block, ensures that the price is exactly the same.
In other explanation, the entire work flow of the prophecy machine is like this, first the prophecy machine from Xiaomi to obtain Xiaomi 9 a TV price, and then to the address of the specific blockchain to transfer money, and the price information written to the transaction notes, so that the smart contract only need to view the specific address of the transaction, you can get the price of Xiaomi 9 A. Because the blockchain automatically stores the chunks that contain the transaction, the smart contract requires almost only local access to get the price information. It ensures the efficiency of access and the consistency of prices.
In general, the Oracle (third party) pushes data to the blockchain without the need for smart contracts to proactively pull data to third parties.
Network of Prophecy Machines
In the vast majority of cases, a prophecy machine is sufficient, but in dealing with significant assets, often a prophecy machine is not guaranteed to be completely reliable, some people put forward a number of prediction machine solutions, such as the setting of 5 prophecy machine, if there are 3 or more than 3 of the price of the same, Initiates a transaction that carries the price memo to the blockchain. This multiple model, which consists of multiple single Oracle machines, is also known as the Network of prophecy machines.
And these two different forms of the model of the prophecy are also known as a single model and multiple models (prediction Machine Network).
Forecast market
If the Oracle and Oracle networks are data movers, predicting the market can provide future-accurate data for smart contracts.
Assuming that the World Cup finals are held at Tianhe Sports Center tonight, all live and tournament data are from CCTV5, but no one can guarantee that CCTV5 's website will not be attacked, or there are unforeseen circumstances such as inaccessible, and in such cases, if these accidents would cause serious consequences, We can use technology that predicts the market.
Where does the final data from the forecast market come from? The data comes from people, not machines, such as betting, betting, guessing and so on, all related to the outcome of the game, and bundled with their own interests, can become the provider of predictive data, because they bundle their own interests, they do not sacrifice their own interests to provide false data, so as to effectively ensure the reliability and authenticity of the data.
Predicting the function and purpose of the market and the Oracle is exactly the same, in order to provide reliable external data for the intelligent contract, their core value is to solve the trust, promote consensus, and ultimately ensure the blockchain and the external world connection. They provide a bridge that allows the blockchain to achieve the "world-wide, I want to see" desire.
Reprinted from HTTPS://WWW.JIANSHU.COM/P/4CE703C29DB3