- Advanced Blockchain Development
- Imran Bashir Narayan Prusty
- 801字
- 2021-06-24 14:04:48
Oracles
Oracles are an important component of the smart contract ecosystem. The limitation with smart contracts is that they cannot access external data, which might be required to control the execution of the business logic; for example, the stock price of a security product that is required by the contract to release the dividend payments. Oracles can be used to provide external data to smart contracts. An Oracle is an interface that delivers data from an external source to smart contracts.
Depending on the industry and requirements, Oracles can deliver different types of data ranging from weather reports, real-world news, and corporate actions to data coming from Internet of Things (IoT) devices. Oracles are trusted entities that use a secure channel to transfer data to a smart contract.
Oracles are also capable of digitally signing the data proving that the source of the data is authentic. Smart contracts can then subscribe to the Oracles, and the smart contracts can either pull the data or Oracles can push the data to the smart contracts. It is also necessary that Oracles should not be able to manipulate the data they provide and must be able to provide authentic data. Even though Oracles are trusted, it may still be possible in some cases that the data is incorrect due to manipulation. Therefore, it is necessary that Oracles are unable to change the data. This validation can be provided by using various notary schemes, discussed later in the chapter.
In this approach, an issue can already be seen which perhaps is not desirable in some cases, and that is the issue of trust. How do you trust a third party about the quality and authenticity of data they provide? This is especially true in the financial world, where market data must be accurate and reliable. It might be acceptable for a smart contract designer to accept data for an Oracle that is provided by a large, reputable, trusted third party, but the issue of centralization remains. These types of Oracles can be called standard or simple Oracles. For example, the source of the data can be from a reputable weather reporting agency or airport information system relaying the flight delays.
Another concept that can be used to ensure the credibility of data provided by third-party sources for Oracles is that data is sourced from multiple sources; even users or members of the public that have access and knowledge about some data can provide the required data. This data can then be aggregated and if a high number of same information is fed from multiple sources, then there is a high chance that the data is correct and can be trusted.
Another type of Oracle, which essentially emerged due to the decentralization requirements, is called decentralized Oracles. These types of Oracles can be built based on some distributed mechanism. It can also be envisaged that the Oracles can find themselves source data from another blockchain, which is driven by distributed consensus, thus ensuring the authenticity of data. For example, one institution running their private blockchain can publish their data feed via an Oracle that can then be consumed by other blockchains.
Another concept of hardware Oracles is also introduced by researchers where real-world data from physical devices is required. For example, this can be used in telemetry and IoT. However, this approach requires a mechanism in which hardware devices are tamperproof. This can be achieved by providing cryptographic evidence (non-repudiation and integrity) of IoT device's data and anti-tampering mechanism on the IoT device, which renders the device useless in case of tampering attempts.
The following diagram shows a generic model of an Oracle and smart contract ecosystem:
![](https://epubservercos.yuewen.com/B6C39C/19470378701490006/epubprivate/OEBPS/Images/c3dcbb82-d077-4677-b8d9-fd6cb3a0dedf.png?sign=1738988703-jw1rLWgKLwJo75vRcQwoz0J2wbi4rAn7-0-ffd43a7a4825f54c0bbdf200465a7a90)
There are platforms available now to enable a smart contract to get external data using an Oracle. There are different methods used by an Oracle to write data into the blockchain depending on the type of blockchain used. For example, in Bitcoin blockchain, an Oracle can write data to a specific transaction and a smart contract can monitor that transaction in the blockchain and read the data.
Various online services such as http://www.oraclize.it/ and https://www.realitykeys.com/ are available that provide Oracle services. Another service at https://smartcontract.com/ is also available, which provides external data and the ability to make payments using smart contracts.
All these services aim to enable the smart contract to get the data it needs to execute and make decisions. To prove the authenticity of the data retrieved by the Oracles from external sources, mechanisms like TLSnotary can be used which produce proof of communication between the data source and the Oracle. This ensures that the data fed back to the smart contract is retrieved from the source.