Blockchain oracles, also called blockchain middleware, are services that connect blockchains to external (off-chain) third-party clients and services.
Oracles act as intermediaries between blockchains and external data sources by providing avenues for exchange between blockchains and third-party services and vice-versa.
On smart contract blockchains, hybrid smart contracts (smart contracts that use oracles) use decentralized oracle networks (DONs) which examine, verify, and validate resources from external services for use on blockchains.
Blockchains, by design, do not have data, as they are mere data structures and often need data from external sources to function — the data from the external source must be accurate and trustworthy.
Decentralized Oracle Networks (DONs) — using various oracle decision models — compute, manipulate, and analyze data from numerous sources to ensure a high degree of data accuracy and no single point of failure.
Oracles can also be used as interoperability solutions, since oracles like Chainlink and Band Protocol serve multiple blockchains.
- How blockchain oracles work
- Types of blockchain oracles
- Oracles on popular blockchains
- Use cases of blockchain oracles
- The oracle problem
- Comparing blockchain oracles
How blockchain oracles work
Oracles use various tools to collate data. The tools could be APIs, SDKs, IoT sensors, or other sources; this data is sent as a signed message on the blockchain.
Smart contracts access the data via the oracle, which stores the data in smart contract storage for accessibility.
Types of blockchain oracles
There are many types of oracles that are used today. Here’s a look at each one:
Software oracles are oracles connected to the Internet. These software oracles use databases, web scrapers, APIs, and more to fetch data.
They are the most widely used form of oracle because of their versatility. An example of a software oracle would be an oracle feeding the Ethereum blockchain with data from YouTube using YouTube’s API.
Hardware oracles connect to hardware and computer peripherals to retrieve data for use. They are trustworthy when compared to software oracles because they are harder to compromise. Hardware oracles use IoT sensors and RFID tags to fetch data from sources.
Hardware oracles are helpful for supply chain, weather, and other physical, real-world scenarios. An example of a hardware oracle would be the geolocation of package delivery.
Inbound oracles perform the task of supplying data from external sources into the blockchain.
These inbound oracles would use hardware oracles, software oracles, or both to fetch external data used in the blockchain.
An oracle that scrapes Web 2.0 websites for data is an example of an inbound oracle.
Outbound oracles disburse data from a blockchain to an external party. The party could be another blockchain for interoperability purposes or an external database. A smart contract on the blockchain would serve as the oracle.
Software, like Web3Py and Web3Js, uses oracles to query the blockchain and relay data to Web 2.0 services. An example of outbound oracles would be smart contracts that check the circulating supply of a cryptocurrency token.
More great articles from LogRocket:
- Don't miss a moment with The Replay, a curated newsletter from LogRocket
- Learn how LogRocket's Galileo cuts through the noise to proactively resolve issues in your app
- Use React's useEffect to optimize your application's performance
- Switch between multiple versions of Node
- Discover how to use the React children prop with TypeScript
- Explore creating a custom mouse cursor with CSS
- Advisory boards aren’t just for executives. Join LogRocket’s Content Advisory Board. You’ll help inform the type of content we create and get access to exclusive meetups, social accreditation, and swag.
Consensus-based oracles use multiple oracles and a consensus algorithm to derive factual data for smart contracts — they help ensure that data passed onto the blockchain is accurate and trustworthy.
A consensus-based oracle would, for example, scrape up to five news websites to verify that a piece of information is true before passing it onto the blockchain.
Compute-enabled oracles are used for computations that cannot be carried out on-chain due to various reasons like block constraints and cost of computation. These compute-enabled oracles verify that the data is accurate before the computation.
Compute-enabled oracles are mostly used by Layer2 solutions like ZK Rollups (zero- knowledge rollups) to gather data off-chain (before submitting on-chain) and are one of the features that distinguish ZK Rollups from Optimistic rollups.
Cross-chain oracles bridge data across various blockchains, thereby enabling interoperability between blockchains. These could be agnostic (blockchain-independent) protocols like the Band Protocol, which allow for data and value transfers across blockchains.
A cross-chain oracle like Chainlink can be used to bridge data from Ethereum to Cardano.
Deterministic oracles are oracles built on trusted data sources. These oracles use algorithms that consider variables like reputation scores to derive data. If a source is 98% correct, for example, there’s a high probability that it is accurate and can be trusted.
An oracle that collates data feeds from government agencies, for example, can be trusted and used as a deterministic oracle.
Oracles on popular blockchains
- Ethereum: Chainlink, Band Protocol, iExec, UMA, Orai
- Solana: Chainlink, DIA, Pyth, Switchboard, Gravity
- Cardano: Charlie3, API3, Orcfax, PIGY Oracle, Chainlink
- Terra: Chainlink,
- Tron: Wink, Bridge Oracle
- Cosmos: Band Protocol
Use cases of blockchain oracles
Decentralized finance applications (DeFi apps) can use inbound oracles to obtain prices of assets and tangible public goods for their application use-cases.
Third-party applications like centralized cryptocurrency exchanges can also use outbound oracles to fetch and track cryptocurrency data.
Digital identity solutions can use oracles to authenticate a user’s provided identity data, such as certificates and documents, from an issuer.
Digital identity solutions can also use oracles to collate and update a user’s data to keep their identity in sync with their actions.
Since a supply chain on a blockchain needs to interact with real-world data, they need oracles. Supply chain smart contracts can use hardware and software oracles to track the state of package delivery in logistics operations.
Oracles are important to almost all applications of smart contracts, as these contracts eventually have to interact with trusted and verified real-world data.
The oracle problem
Blockchains are used to improve trust and transparency between interacting parties. As we noted earlier, blockchains do not have access to real-world data; so whatever data an oracle provides has to be accurate and trustworthy.
The oracle problem concerns the trustworthiness, safety, reliability, and degree of decentralization of oracle networks.
Why is this a problem? For blockchains to be adopted, they have to be able to work with existing historical data, which has to be without error, since any data on the blockchain cannot be deleted or changed.
This problem can be solved by ensuring the data sources are accurate, reliable, and that various data sources are used, eliminating a single point of failure.
Comparing blockchain oracles
Chainlink is a decentralized oracle network, notably used on EVM chains to interact with real-world data. It is considered the industry standard for oracles.
Chains supported: EVM Chains, Solana, Terra
API3 allows developers to use Web3 APIs from their smart contracts using first-party oracles (the API provider is the oracle), which reduces the cost.
Chains supported: Ethereum
Band Protocol is an agnostic (blockchain-independent), decentralized oracle network fostering interoperability across blockchains, built using the Cosmos IBC protocol SDK.
Chains supported: Cosmos, Ethereum, BNB Chain, Terra, Celo, Oasis
DIA is an open-source cross-chain oracle optimized for DeFi that pulls data from multiple exchange APIs and smart contracts and can serve as an on-chain and off-chain oracle.
Chains supported: EVM Chains, Solana, Polkadot
Chainlink, Band Protocol, API3, and DIA are the most popular oracles used by Web3 applications to interact with external data and make on-chain data accessible to Web2 applications.
Oracles are essential to the development of blockchain and Web3, since can serve as the infrastructure that can aid blockchain and other distributed ledger technologies in accessing data to be used in many daily operations across virtually all industries.
LogRocket is like a DVR for web and mobile apps, recording everything that happens in your web app or site. Instead of guessing why problems happen, you can aggregate and report on key frontend performance metrics, replay user sessions along with application state, log network requests, and automatically surface all errors.
Modernize how you debug web and mobile apps — Start monitoring for free.