Oracle (Blockchain Oracle)
What is an Oracle?
An oracle is a third-party service that enables a smart contract to access data from an external source.
The service acts as a bridge between a blockchain and information in the real world. Without this middleware layer, smart contracts would only be able to access data that is already on the blockchain. This will limit the usefulness of smart contracts in decentralized finance (DeFI), supply chain management (SCM), games and entertainment.
Here are some examples of the type of information an oracle might be asked to find and return:
- Price data such as the current price of a particular cryptocurrency, stock or commodity. A smart contract can use this type of information to perform a financial transaction such as trading, lending or borrowing.
- Weather data such as current temperature, rainfall, humidity level and wind speed for a specific location. A smart contract can use this type of information to trigger an event, such as an insurance payout.
- Sports data such as team schedules, match results and player statistics. This information can be used by smart contracts for gaming and gambling applications, as well as for fantasy sports and other games.
- Transport data such as airport codes, train schedules and freight updates. This information can be used by smart contracts to trigger certain events, such as payments or insurance claims.
- Health data such as test results, HIPAA authorizations and patient histories. This information can be used by smart contracts for various applications, including insurance claims and clinical trials.
How they work
When a smart contract requires external data, it will send a request to the oracle using a communication protocol such as HTTPS.
When the oracle receives the request for external data, it retrieves the requested data from one or more external sources. It then performs verification checks to ensure that the data is accurate and timely. Typically, these checks involve validating the authenticity of the data source and verifying that the data meets defined quality standards and has not been tampered with.
Once the data is validated and verified, the oracle sends the requested data to the smart contract in a format compatible with the smart contract’s code. (For example, the oracle can encode the data in a standardized format like JSON before transmitting it using HTTPS.) Finally, the smart contract uses the data provided by the oracle to perform its logic and functions.
Depending on the contract, an oracle may be compensated for its services with tokens or cryptocurrency coins.
Centralized vs. decentralized
Oracles can be centralized or decentralized. Centralized oracles rely on a single entity to collect and validate external data. In contrast, decentralized uses a network of independent nodes to perform the same functions.
Centralized oracles: A single entity (which may be an organization) is responsible for collecting and validating external data. This type of oracle typically collects data from multiple sources and uses machine learning (ML) algorithms to identify which source provided the most accurate and reliable data.
Decentralized oracles: A network of independent nodes is responsible for collecting and validating external data. Decentralized oracles use consensus mechanisms to validate the accuracy and timeliness of external data before sending it to the smart contract.
In general, decentralized oracles are considered more secure than centralized oracles because they reduce the risk of a single point of failure. Even if one node provides inaccurate data, the other nodes in the network will still provide accurate data. However, it is worth noting that decentralized oracles can be more difficult to implement and can cost more to use than centralized oracles.
Choosing the right Oracle
The choice of oracle can be a critical factor in the success or failure of a smart contract, because the reliability, transparency and security of the oracle can have a significant impact on the contract’s performance.
Some smart contract platforms such as MakerDAO and Compound have their own oracles, but many platforms partner with a few well-known oracle services. For example, Aave and Uniswap use Chainlink while Wanchain and Kava use Band Protocol as their default oracle.
Ultimately, it is up to the smart contract developer to choose which oracle to use when integrating external data into the contract. When choosing this type of third-party service, developers should consider the following:
Reputation: It is important for developers to know if the provider is trusted in the DeFi community and if they have experienced (and disclosed) security incidents or data breaches in the past.
Scalability: Third-party vendors have many customers, so it is important to know how well the oracle can handle high traffic and large volumes of requests.
Safety: Developers should know their vendor’s encryption and data privacy policies, as well as their business continuity plans if they become the victim of a malicious attack.
Cost: This includes fees for accessing data in addition to any transaction fees associated with using the oracle.
Integration: Developers should look for third-party services that are compatible with their smart contract platform and research the oracle enough to get a feel for how easy it will be to integrate the oracle with the contract’s code.
Data quality: The quality of the external data this type of service provides is critical. Developers should evaluate the timeliness and accuracy of the data the oracle provides, and understand what steps the service provider takes to validate and verify external data.
Reliable examples
Although some platforms, such as Ethereum, have built-in mechanisms for retrieving data from outside the blockchain, these mechanisms are usually limited in their capabilities and are not as robust as third-party services. Here are some examples of oracles that are considered reliable:
Chainlink: Chainlink is a decentralized oracle network that provides secure and reliable access to real-world data for smart contracts. Chainlink is known for its extensive network of nodes and its ability to provide verified data from multiple sources.
Band Protocol: Band Protocol is a cross-chain data oracle platform that provides smart contracts with decentralized access to trusted external data sources. Band Protocol is known for being scalable and easy to integrate with different blockchains.
Tellor: Tellor is a decentralized oracle network that provides smart contracts with access to high-quality data. Tellor is known for using proof-of-work (PoW) consensus mechanisms to ensure the accuracy and integrity of the data it provides.
DIA: DIA is a decentralized oracle platform that provides transparent access to trusted data for decentralized software applications (DApps). DIA is known for its open source data streams and its ability to provide verifiable and auditable data from trusted sources.
UMA: UMA is a decentralized financial contract platform that gives Dapps access to price feeds. UMA is known for its ability to offer customizable financial contracts that can be tailored to specific needs.
API3: API3 is a decentralized oracle that provides access to real-world price data for blockchain-based applications. API3 is known for transparency and provides just-in-time data updates for individual smart contracts