Blockchain OraclesAn Oracle is a third-party service that provides smart contracts with external information, which allows blockchains to access the outside world.
What is a blockchain Oracle?Data off-chain (data outside of the blockchain) cannot be accessed by blockchains and smart contracts. It is, however, often essential to have relevant information from the outside world to execute many contractual agreements.
A decentralized Oracle network (DON) makes it possible to implement hybrid smart contracts using off-chain infrastructure and on-chain code to produce complex decentralized applications (DApps) that are reactive to real-world events and can interact with traditional systems.
Imagine Alice and Bob want to bet on the outcome of a horse race. They wager $50 each on team X and $30 each on team Y, so the total has been held in escrow by a smart contract. What mechanism does the smart contract use to decide whether to give the money to Alice or Bob when the bet is over? The solution is that rather than relying on the blockchain to retrieve match outcomes accurately, a mechanism called Oracle is needed to deliver them securely and reliably to the blockchain.
Considering the distributed ledger aspect of blockchain, every node in the network must produce the same output. In other words, if a node tries to validate another node’s transaction, the result will be different. This architecture was created to be deterministic.
As you might know, one of the main factors that make blockchain work in the first place is the underlying consensus mechanism. To reach a comprehensive consensus on a blockchain, nodes must be deterministic and agree on the data value. The Nakamoto consensus and Byzantine consensus are two examples of proof-of-work (PoW) technology that might sound more familiar to you.
Blockchain technology, however, must connect with the real world. DeFi requires us to incorporate the price of Ether (ETH) and other cryptocurrencies in a contract. Furthermore, any trustless and decentralized coverage needs meteorological data.
To use blockchain for one of its most essential use cases, e.g. smart contracts, we need to have access to real-world data. Given these constraints, how can we connect these two worlds?
In this case, blockchain Oracles are the new technologies that are being used as a link between off-chain and on-chain data. In the blockchain ecosystem, Oracles play a crucial role because they extend the capabilities of smart contracts. So, as smart contracts would only have access to data within their networks without blockchain Oracles, their use would be extremely limited.
It’s imperative to note that a blockchain Oracle is not the data source itself, but rather the layer that queries, verifies, and authenticates external sources. This layer then relays the data back to the blockchain. The data transmitted by Oracles then comes in many forms – price information, the successful completion of a payment, or the temperature measured by a sensor.
The smart contract must be invoked and network resources must be allocated in order to call data from the outside world. In addition to relaying information to smart contracts, some Oracles also have the capability of sending information back to outside sources.
There are many types of Oracles available, and how a blockchain Oracle operates is entirely dependent on its intended use cases.
What are blockchain Oracles’ use cases?Imagine that Alice and Bob are placing a bet on who will win the US presidential election. Alice believes the Republican candidate will arrive at victory, while Bob believes the Democrat will prevail. The bet is agreed upon and the funds are locked into a smart contract. This smart contract will release all the funds to the winner based on the outcome of the election.
Smart contracts cannot interact with external data, so they rely on an Oracle to feed them the necessary data – in this case, the results of the presidential election. As soon as the election is over, Oracle queries a trusted API to determine the winner and injects this data into the smart contract. Then, in either case, the contract transfers funds to Alice or Bob.
There would have been no way to settle this bet in a way that could not be manipulated by one of the players without having an Oracle relaying the data. Any device or entity that connects a deterministic blockchain to off-chain data is called a blockchain oracle. In these Oracles, each data input is routed through an external transaction.
The blockchain, on the other hand, contains all the information required for this form of authentication. As a bridge between the two worlds, Oracles are considered as blockchain’s middleware.
As opposed to this, a single centralized oracle causes the problem that a decentralized, blockchain-based smart contract is meant to solve: a single point of failure. So, if your Oracle is faulty or compromised, how would you know whether your data is accurate? And in a blockchain environment, what purpose does a smart contract serve if the data it relies on is non-reliable?
Different Oracle types
An Oracle allows a blockchain or smart contract to communicate with external data. Instead of communicating directly with the outside world, they serve as interfaces and in many situations, outside data must be conveyed to the closed blockchain system, particularly when smart contracts are tied to real-world events. Cryptographic Oracles query, verify and authenticate external data before relaying it to the closed system. A smart contract can then be verified then using the validated data.
Hardware and software Oracles
It is worth noting that, most crypto oracles can analyze digital data, though this is not always the case.
Delivering data from the physical world to the blockchain is mostly done by Hardware Oracles, while Software Oracles are the ones to inject data from digital sources such as websites, servers, or databases into the blockchain.
By interacting with online sources of information, software Oracles transmit data to the blockchain and any online database, server, website, or other data source on the Web can provide this information. Real-time flight information, digital asset prices, and exchange rates are some types of information that software Oracles typically provide.
Conversely, some smart contracts require real-world integration. Hardware Oracles are designed for injecting physical world information into the blockchain, making it available for smart contracts to use. Therefore, hardware Oracles can deliver and relay various types of information, such as the data provided by cameras or radio frequency identification sensors. On the other hand, it is with Software Oracles that real-time data, such as exchange rates, price fluctuations, and travel information can be delivered into the blockchain.
Inbound and Outbound Oracles
With blockchains, Oracle establishes a two-way communication channel, sending data in and out. While outbound Oracles can deliver blockchain data to the outside world, inbound Oracles, on the other hand, are set to provide off-chain (real-world) data for the blockchain. Additionally, the imported data can represent nearly any type of information, including asset price swings or meteorological conditions, to verify all completed payments.
A common programmable scenario for inbound Oracles is to adjust it so that if an asset reaches a specific price, it triggers a buy order. Meanwhile, outbound Oracles can notify the outside world of an event that has occurred on the blockchain.
For instance, when a sensor measures the temperature and informs the related smart contract about it, it is actually using an inbound Oracle. Meanwhile, if funds are hypothetically deposited in an address, the smart contract sends the related information to a mechanism that unlocks the smart lock as well and this process is done through an outbound Oracle.
Centralized and decentralized Oracles
The smart contract’s sole data source is a centralized Oracle managed by one entity. However, having only a single source of information can be dangerous, as the effectiveness of the contract depends solely on the entity that manages the Oracle.
Bad actors’ hostile interventions can also directly affect smart contracts. So, the fundamental problem with centralized Oracles is that they have a single point of failure, which can make a contract more vulnerable to hack attacks and flaws.
Some purposes of decentralized Oracles, such as minimizing third-party risks, are similar to those of public blockchains. For example, they make the information delivered to smart contracts more reliable by utilizing more than one source of accurate information.
Here, the smart contract makes use of several Oracles to determine the validity and accuracy of the data. Thus, decentralized Oracles are also referred to as consensus Oracles. Here, other blockchains can use decentralized Oracle services provided by some blockchain Oracle projects as well.
Even though decentralized oracles claim to be trustless, it is essential to note that, as with trustless blockchain networks, decentralized oracles don’t eliminate trust. On the contrary, they distribute it across many users.
It is sometimes possible for a person with specialized knowledge in a specific field to act as an Oracle. These individuals may gather information from various sources, verify its legitimacy, and convert it into smart contracts. Due to the fact that human oracles can verify their identities using cryptography, the chance of a fraudster faking their identity and supplying corrupted data is fairly low.
These types of Oracles are provided to work in tandem with single smart contracts. It will be necessary for the developer to create numerous contract-specific Oracles if he or she intends to deploy numerous smart contracts.
However, it takes too much time and effort to keep contract-specific Oracles up-to-date and also, they are inconvenient and should only be used in specific circumstances.
The term Oracle has been used to refer to a system that searches for and supplies data (also known as a data carrier Oracle or an automated Oracle). Despite this, Oracles can be used to perform any “off-chain” computation, which is especially useful given Ethereum’s high computational cost and block gas constraint.
Computation Oracles, rather than simply relaying query results, can be used to compute a result based on a set of inputs and return it as a calculated result that would otherwise be impossible to calculate on-chain. For example, to estimate the yield of a bond contract, a computation Oracle could be used to perform a computationally complex regression calculation.
Deploying Oracles in DApps
Oracle is a mechanism for bridging the gap between the off-chain world and smart contracts used by many DApps on the market. The following are some examples of what Oracles may provide:
- Event triggers based on time and interval measurements.
- Detailed information about the capital markets, such as the pricing of tokenized assets and securities.
- Benchmark reference data, such as interest rates, found in smart financial derivatives.
- Weather data used to calculate insurance premiums based on weather forecasts.
- Geolocation data used, for instance, to track supplies.
- Damage verification required for insurance contracts.
- Sports events used to settle prediction markets and fantasy sports contracts.
- Flight statistics, such as those related to groups and clubs that pool flight tickets.
By bringing external data into the equation, Oracles play a vital role in smart contract executions. However, Oracles also pose a large threat to users since although they are trusted sources they can also be hacked, compromising the execution of smart contracts they support.
Generally, the trust model should be carefully considered when planning the deployment of an Oracle system. Also, assuming the Oracle is trusted, we still might be jeopardizing the smart contract’s security by exposing it to potentially incorrect inputs. Despite this, Oracles can still be valuable if the security assumptions are taken into account.
Oracles, which provide Ethereum smart contracts with external data that cannot be trusted, can address some of these issues. Regardless, before deploying any Oracle bridges between Ethereum and the real world, you must carefully explore your choices and select the most appropriate one in accordance with your roadmap.