A blockchain oracle conveys information to and from smart contracts to enable them to perform their self-executing functions.
after reading this, you'll understand:
A blockchain oracle provides information to a smart contract so it can carry out the terms of the contract.
The "oracle problem" describes the concerns that arise from having a decentralized platform rely on a centralized source of data.
Many different types of oracles have been developed to handle the communication needs of smart contracts and decentralized finance.
Blockchain oracles are an essential component of decentralized finance. Although smart contracts are self-executing, they typically need information from outside the chain. Blockchain oracles supply that information.
As computer code living on the blockchain, smart contracts are designed to be immutable in a trustless environment. Once they go live, the terms of the contract, which is the same as saying the coding of the contract, cannot be changed. That makes sense. If you signed a contract to buy a car, you wouldn't want the dealership calling the next day to say they updated the contract and the car now costs $10,000 more. The terms of a smart contract must be immutable for the contract to have any meaning.
Smart contracts also are self-executing through automated processes. Once certain conditions have been met, they trigger the next step in the contract. It's often referred to as "If ... then" logic. But how does the smart contract know if conditions have been met? A blockchain oracle tells it. And how does the smart contract tell another party to, for example, send payment on a peer-to-peer network to a contract holder. It uses an oracle.
Let’s take the example of a smart contract used for betting on soccer. Without access to a real-time data source for soccer scores, this smart contract cannot function. Furthermore, if the smart contract receives incorrect data, the wrong people might receive payouts. Because the blockchain is immutable, those trustless transfers of assets could not be reversed.
A "blockchain oracle" is a method of feeding information into a smart contract. (The term "oracle" has its roots in ancient Greece, where certain individuals, usually women, were given that title. They were believed to have the power to channel messages from the gods to mortals.) Now, oracle providers channel messages from data sources to smart contracts. Smart contract developers leverage oracles to bring a contract to life.
However, an oracle must maintain accuracy through robust data validation processes. Oracles sometimes need to reconcile different sources of information and feed them into a smart contract. With only one chance to get things right on an immutable distributed ledger, users must have confidence in the data integrity.
Let’s go back to our example of a smart contract for betting on soccer. An application programming interface, or API, is software that enables one computer or program to communicate with another computer or program. Sound familiar? Dozens of APIs might be used to supply soccer scores for different applications. An oracle, which itself is an API, would take these data feeds and compare the scores from each source. That oracle-API calls the smart contract to give it the correct score so the right bettors can be paid off.
The blockchain agrees upon data values through consensus and cryptographic proofs. Determinism enables individual nodes to reach a consensus. A blockchain oracle can connect a deterministic blockchain with off-chain data. In other words, an off-chain oracle will gather information and report it on-chain for secure transactions. This is why oracles are often referred to as middleware in the cryptocurrency world.
However, there is something called the oracle problem. The whole point of smart contracts and tokenization in decentralized finance is that they are decentralized. They don't require third parties to slow things down, exert undue influence, and inflate costs. But the use of oracles — centralized sources of information — can be a point of failure.
However, oracle solutions like Chainlink can prevent oracles from nullifying the advantages of decentralization while addressing the security risks associated with external data. Chainlink has become the standard for decentralized oracles. It is an open-source effort to provide tamper-proof inputs and outputs to support smart contracts on blockchain networks.
By looking at the most common types of oracles, we can better understand how they work with smart contracts in a trustless environment.
Hardware oracles are physical sensors with API capability. Take the example of hurricane insurance on a smart contract. The insurance provider might use physical sensors to measure wind speed. If the sensors record speed of a certain intensity, the hardware oracle notifies the smart contract. The smart contract executes the terms and notifies another oracle to send the policyholder a check.
Software oracles collect data from third-party sources, including public APIs and financial markets. For example, for flight delay insurance, the data source could feed information on flight status to the smart contract. If the policyholder’s flight is delayed, the computer code on the smart contract will execute a compensation transaction.
Consensus oracles use aggregated data from various oracles with proprietary methods to verify data accuracy and legitimacy. These act as decentralized oracles, or at least represent a move toward decentralization through consensus. They compile and analyze multiple data sources, like price feeds from financial markets, to reach one validated data point.
Cross-chain oracles enable tokenization and allow for interoperability between data and assets moving between blockchain networks. For instance, you could use data on one blockchain to trigger specific automated processes on another blockchain. Also, cross-chain oracles allow you to bridge assets for use outside their native blockchain.
Inbound oracles transmit data from external sources to smart contracts. These work when a smart contract needs external data — like weather data, supply chain tracking updates, and other reports of real-world events — to trigger the correct response.
Outbound oracles allow smart contracts to send information to off-chain sources. For instance, if funds need to be deposited to an address, a smart contract could send data through an outbound oracle to a mechanism that will make it happen.
Oracle computation uses decentralized oracle networks (known as DONs) to execute off-chain computation for smart contracts. It is much less expensive to crunch data off the blockchain than on it, so computation oracles increase the scalability of smart contracts. This type of oracle can help to create trust-minimization guarantees as they remain anchored to blockchain technology.
The three main ways to set up an oracle solution are usually categorized as immediate-read, publish-subscribe, and request-response.
Immediate-read oracles provide data that is usually desirable for a fast, prompt decision. This type of information is often required on a last-minute, just-in-time basis.
Publish-subscribe oracles offer a broadcast service to provide information that may frequently vary. Much like an RSS feed, the oracle updates with new information and “flag signals” indicating new information is available to those who are “subscribed.”
Request-response oracles are used for all-encompassing and expansive datasets that are too large to store on a smart contract. These are often used when only a small part of the overall dataset is used at any given time.
Hedera is uniquely positioned to lead the way on oracle development and utilization. Its Ethereum Virtual Machine (EVM) smart contracts, easy-to-use native tokenization and consensus service APIs enable developers to create real-time web3 applications and ecosystems that will drive the future of the internet.
The HBAR Foundation, an organization that supports the development of Hedera’s ecosystem, partnered with the Pyth Network to integrate Pyth Price Feeds into the Hedera network. This enables DeFi builders to easily access more than 400 real-time price feeds across crypto, equities, commodities, foreign exchange, and exchange-traded funds (ETFs). Developers can use the price feeds to help them build secure and efficient DeFi apps. In addition, developers and Hedera users can leverage Pyth Price Feeds’ Pull Oracle design and its continuous, low-latency access to the most up-to-date prices.
Chainlink, the dominant oracle network and a member of Hedera's Governing Council, grants HBAR foundation developers access to Chainlink (LINK) data feeds and the Chainlink Contractor-Controlled Insurance Program (CCIP). Thus, HBAR developers can launch the oracle’s data feeds immediately on Hedera’s testnet as they create dApps (decentralized applications) on Hedera’s native platform.
Chainlink also has launched an effort to blend oracles, blockchain technology, and artificial intelligence to provide real-time, standardized data on corporate activity.
Learn more about getting started building applications and ecosystems for the next generation of the web.