Blockchain oracles: What are they?
Blockchain oracles are organizations that link blockchains to other systems, enabling smart contracts to run based on inputs and outputs from the real world. The Web 3.0 ecosystem now has a way to connect to legacy systems, data sources, and sophisticated computations.
When off-chain infrastructure and on-chain code are combined to create complex decentralized applications (DApps), decentralized oracle networks (DONs) make it possible to implement hybrid smart contracts that respond to real-world events and communicate with legacy systems.
Imagine that Alice and Bob want to wager on the result of a horse race. A smart contract is used to keep the $80 sum in escrow. Alice bets $50 on team X, while Bob wagers $30 on team Y. When the game is over, how does the smart contract decide whether to give the money to Alice or Bob?
The answer is that an oracle mechanism is necessary to obtain accurate match results off-chain and deliver them to the blockchain in a secure and trustworthy manner.
Each node in the network must produce the same output from the same input due to the distributed ledger feature of the blockchain. For instance, a node will receive a different outcome if it attempts to validate the transaction of another node. The deterministic design was incorporated into this architecture.
Blockchain relies on consensus as a method for reaching an agreement on data values, and determinism is necessary for nodes to reach consensus. Some of them might be familiar to you, like proof-of-work (PoW) with Nakamoto consensus and proof-of-stake (PoS) with Byzantine consensus. Consensus is one of the key elements that make blockchain function in the first place.
The blockchain community must nevertheless interact with the real world. We must enter the price of Ether (ETH) and other cryptocurrencies into a contract in order to have DeFi. In order to provide decentralized, trustless insurance, we need meteorological data. We need data to use blockchain for smart contracts, one of its most important applications. How then do we connect the worlds under this restriction?
The purpose of this guide is to introduce various blockchain oracle projects, discuss the blockchain oracle problem, and describe what blockchain oracles do.
Blockchain oracle issue
The problem with the blockchain oracle brings to light a crucial limitation of smart contracts: they are completely cut off from data and systems outside of the blockchain context in which they were created. Data currently stored on the blockchain is referred to as “on-chain,” whereas external resources are referred to as “off-chain.”
By being purposefully cut off from external systems, blockchains are able to achieve their most advantageous characteristics, including the prevention of double-spending attacks, broad agreement on the veracity of user transactions, and a decrease in network downtime.
You’ll need an additional infrastructure known as an “oracle” to securely communicate with off-chain systems from a blockchain and span two environments.
Solving the oracle problem is crucial because the vast majority of smart contract use cases, including DeFi, demand knowledge of real-world data and off-chain events.
By offering a universal gateway to off-chain resources while upholding the blockchain’s fundamental security features, oracles thus expand the types of digital contracts that blockchains may enable.
A few of the sectors that benefit from the integration of oracles with smart contracts include asset prices in finance, identity verification in government, randomness in gaming, and weather data in insurance.
The purpose of blockchain oracles
Blockchain oracles are any devices or entities that link deterministic blockchains to off-chain data. In these oracles, each data input is passed through an external transaction.
However, we can be sure that the blockchain has all the data required for this kind of self-authentication. As a bridge between the two worlds, oracles are regarded as blockchain middleware.
Chainlink has become the industry standard for decentralized oracles because it solves the issues of centralizing smart contracts and gaining access to external data. What exactly are Chainlink Oracles, then?
Chainlink is a decentralized oracle network that provides blockchain smart contracts with real-world data. Digital asset tokens called LINK tokens are used to pay for network services.
A single point of failure, on the other hand, is the specific issue that a decentralized, blockchain-secured smart contract is meant to address.
So, if the oracle is broken or compromised, how would you know if your data is accurate? What use is a blockchain-based smart contract that is trustworthy and safe if the data it is based on is questionable?
Chainlink, a decentralized network of nodes, offers a solution to this issue by utilizing oracles to deliver data and information from off-blockchain sources to on-blockchain smart contracts. This method eliminates the reliability issues that might develop if only a single centralized source is used, along with other secure technology.
Chainlink connects all significant public and private blockchain environments using a single framework, providing a typical abstraction level for cross-network communication, making it blockchain agnostic.
Decentralized data that has already been extracted from the real world and gathered using services like Chainlink, which is like a public library but for decentralized data, can therefore be found on-chain.
To get the precise information you need, you can even design your own modular oracle networks. You can also send data outside of the blockchain and perform off-chain calculations.
Witnet, Paralink, Provable, and Dos.Network are additional prominent blockchain oracles. These services offer oracles that can query application user interfaces (APIs) and then send transactions to update the data in the smart contract periodically. These oracles are made up of a smart contract and some off-chain components.
Types of blockchain oracles
A blockchain or smart contract can communicate with external data using oracles. Instead, they act as a gateway to the outside world for the blockchain.
In many cases, especially when smart contracts are connected to real-world events, external data must be transmitted to the closed blockchain system.
Crypto oracles query, validate, and authenticate external data before relaying it to the closed system. Following that, a smart contract would be validated using the verified data.
Hardware and software oracles
Most crypto oracles analyze digital data, though this isn’t always the case. While software oracles deliver data from digital sources like websites, servers, or databases, hardware oracles deliver data from the real world.
Additionally, hardware oracles can deliver and relay data from RFID and camera motion sensors. Software oracles can deliver real-time data, such as exchange rates, price changes, and travel-related information.
Inbound and outbound oracles
With blockchains, Oracles create a two-way communication channel through which they send and receive data. Inbound oracles are more likely to bring off-chain or real-world data to the blockchain than outbound oracles, which can deliver blockchain data to the outside world. The imported data can also represent a wide range of things, including changes in asset prices, weather patterns, and the confirmation of successfully completed payments.
A typical programmable scenario for inbound oracles might be: If an asset reaches a certain price, place a buy order. Outbound oracles, on the other hand, inform the outside world of an event that took place on-chain.
Centralized and decentralized oracles
The only data source used by a smart contract is a centralized oracle, which is controlled by a single entity. It can be risky to rely solely on one source of information because the oracle’s owner determines whether the contract is effective.
The smart contract will also be directly impacted by an adversarial intervention by a bad actor. Centralized oracles have a single point of failure, which is the main problem because it leaves contracts more open to attacks and flaws.
Decentralized oracles share some objectives with open blockchains, such as reducing counterparty risk. By avoiding reliance on a single source of truth, they increase the reliability of the data delivered to smart contracts, for instance.
Decentralized oracles are also referred to as consensus oracles because the smart contract consults multiple oracles to evaluate the veracity and accuracy of the data. Some blockchain oracle projects offer decentralized oracle services that can be utilized by other blockchains.
Human oracles
Sometimes oracles can be people who have specialized knowledge in a certain field. They could collect data from various sources, validate it, and then turn it into smart contracts.
The likelihood of a fraudster impersonating a human oracle and providing tampered data is low because they can use cryptography to confirm their identity.
Contract-specific oracles
These oracles are designed to function with single-use smart contracts. It will be necessary to construct numerous contract-specific oracles if the developer plans to deploy numerous smart contracts.
Oracles that are only applicable to contracts are not worth the time and effort required to maintain them. Instead, they are inconvenient and ought to be used only in certain circumstances.
Oracles for computation
So far, we have only discussed oracles in terms of their use in gathering and providing data (also known as data carrier oracles or automated oracles). But given Ethereum’s built-in block gas constraint and extremely high computation cost, oracles can be used to conduct any arbitrary “off-chain” compute solution.
Instead of merely relaying the results of a query, computation oracles can be used to compute on a set of inputs and return a calculated result that would be impossible to compute on-chain otherwise. For instance, a computation oracle could be used to carry out a computationally challenging regression calculation to estimate the yield of a bond contract.
Design patterns for Oracle
By definition, all of the oracles under discussion play a few crucial roles. Among these abilities is the capacity to:
- Gather information from non-blockchain sources.
- Sending the data on-chain requires using a signed message.
- Make the data accessible by keeping it in a smart contract’s storage.
Once the information has been saved in a smart contract’s storage, other automated agreements can access it by sending message calls that use the “retrieve” feature of oracle’s smart contract. By “looking into” the oracle’s storage, it can also be “called” directly by Ethereum nodes or clients that support the network.
Following are the three primary ways to set up an oracle:
Immediate-read
Instantaneous-read oracles offer facts only necessary for making a snap judgment, like “is this student over 25?” This type of data is typically searched for “just in time,” which means the search is only conducted when the information is required.
Dial codes, academic credentials, institutional affiliations, airport identification, and other oracles are a few examples.
Publish-subscribe
Either a smart contract on-chain polls an oracle, which effectively provides a broadcast service for data that is likely to change (possibly both regularly and frequently), or an off-chain daemon keeps an eye out for updates. Examples of the publish-subscribe setup include weather information, price feeds, economic and social statistics, and traffic data.
Request-response
Request-response is the most challenging category to implement because users are only expected to use a small portion of the entire data space at a time, and the data space is too large to be stored in a smart contract. Additionally, it is a successful business plan for data providers.
A system of on-chain smart contracts and off-chain infrastructure for monitoring requests, retrieving data, and returning it could be used to implement an oracle similar to this in practice. A decentralized application’s data request is frequently an asynchronous process with the following multiple steps:
Oracle applications in DApps
Oracle serves as a means of bridging the gap between the off-chain environment and the smart contracts that are used by many of the DApps available today. Examples of data that oracles may provide include the following:
- Event triggers based on precise time measurements use time and interval data.
- Information obtained from the capital markets, such as the cost of bundles of securities and tokenized assets.
- Including benchmark reference data in intelligent financial derivatives, such as interest rates.
- One application of weather data is the calculation of insurance premiums based on forecasts of the weather.
- Geolocation information like that is gleaned from supply chain tracking.
The necessity of damage verification in insurance contracts
- Fantasy sports contracts and prediction markets are settled using sporting events.
- Flight data, such as that which organizations and clubs use to pool tickets.
Be on the lookout for security issues.
By incorporating outside data into the equation, oracles play a crucial part in the execution of smart contracts. On the other hand, oracles present a serious risk because, if they are regarded as reliable sources and are vulnerable to hacking, they could endanger the execution of the smart contracts they support.
In general, the trust model must be carefully considered when considering using an oracle. If we assume the oracle can be trusted, then you may be sacrificing the security of the smart contract by exposing it to potentially incorrect inputs. Oracles can be helpful, though, if the security assumptions are carefully considered.
Decentralized oracles, which provide Ethereum smart contracts with unreliable external data, can help alleviate some of these issues. Before exploring the oracles’ link between Ethereum and the outside world, you must carefully choose it.