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 already on the blockchain. This would limit the usefulness of smart contracts in decentralized finance (DeFI), supply chain management (SCM), gaming and entertainment.
Here are some examples of the types of information that an oracle might be requested to find and return:
- Price data such as the current price of a specific cryptocurrency, stock or commodity. A smart contract might use this type of information to execute a financial transaction such as trading, lending or borrowing.
- Weather data such as the current temperature, precipitation, humidity level and wind speed for a specific location. A smart contract might use this type of information to trigger an event such as an insurance payout.
- Sports data such as team schedules, game scores and player statistics. This information can be used by smart contracts for betting and gambling applications, as well as for fantasy sports and other games.
- Transportation data such as airport codes, train schedules and shipping 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 by using a communication protocol like HTTPS.
Once 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 that’s compatible with the smart contract’s code. (For example, the oracle may encode the data in a standardized format like JSON before transmitting it using HTTPS.) Finally, the smart contract uses the data the oracle provided to execute its logic and functions.
Depending upon 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 ones use a network of independent nodes to perform the same functions.
Centralized oracles: A single entity (which could 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 it’s sent to the smart contract.
In general, decentralized oracles are considered to be 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. It’s worth noting, however, that decentralized oracles can be more difficult to implement and can cost more to use than centralized oracles.
Picking the Right Oracle
The choice of oracle can be a critical factor in the success or failure of a smart contract, because the oracle’s reliability, transparency and security can have a significant impact on the performance of the contract.
Some smart contract platforms like MakerDAO and Compound have their own oracles, but many platforms partner with a few well-known oracle services. Aave and Uniswap, for example, 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 their contract. When selecting this type of third-party service, developers should evaluate the following:
Reputation: It’s important for developers to know whether the provider is trusted within the DeFi community and whether they have experienced (and disclosed) security incidents or data breaches in the past.
Scalability: Third-party providers have lots of customers, so it’s important to know how well the oracle can handle high traffic and large volumes of requests.
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 have a sense of how easy it will be to integrate the oracle with 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.
Although some platforms, like Ethereum, have built-in mechanisms for retrieving data from outside the blockchain, these mechanisms are typically limited in their capabilities and are not as robust as third-party services. Here are some examples of oracles that are regarded to be trustworthy:
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 trustworthy 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 reliable data for decentralized software applications (DApps). DIA is known for its open-source data feeds and its ability to provide verifiable and auditable data from trusted sources.
UMA: UMA is a decentralized financial contract platform that provides Dapps with access to price feeds. UMA is known for its ability to provide customizable financial contracts that can be tailored for 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 providing just-in-time data updates for individual smart contracts