What is a blockchain oracle?
This is where blockchain oracles come into play, as they provide a link between off-chain and on-chain data. Oracles are vital within the blockchain ecosystem because they broaden the scope in which smart contracts can operate. Without blockchain oracles, smart contracts would have very limited use as they would only have access to data from within their networks.
It’s important to note that a blockchain oracle is not the data source itself, but rather the layer that queries, verifies, and authenticates external data sources and then relays that information. The data transmitted by oracles comes in many forms – price information, the successful completion of a payment, or the temperature measured by a sensor.
To call data from the outside world, the smart contract has to be invoked, and network resources have to be spent. Some oracles also have the ability to not only relay information to smart contracts but to send it back to external sources.
Many different types of oracles exist – how a blockchain oracle operates is entirely dependent on what it is designed for. This article will go through some of those designs.
Example of a blockchain oracle
Suppose that Alice and Bob place a bet on who the winner of the US presidential election will be. Alice believes that the Republican candidate will win, while Bob believes that the Democrat will be the winner. They agree on the terms of the bet and lock their funds in a smart contract, which will release all the funds to the winner based on the results of the election.
Without the oracle relaying the data, there would have been no way to settle this bet in a way that couldn’t be gamed by one of the participants.
What are the different types of blockchain oracles?
Blockchain oracles can be classified depending on a number of different qualities:
- Source – does the data originate from software or hardware?
- Direction of information – is it inbound or outbound?
- Trust – is it centralized or decentralized?
A single oracle can fall into multiple categories. For example, an oracle that sources information from a company website is a centralized inbound software oracle.
Software oracles interact with online sources of information and transmit it to the blockchain. This information can come from online databases, servers, websites – essentially, any data source on the Web.
The fact that software oracles are connected to the Internet not only allows them to supply information to smart contracts but also to transmit that information in real-time. This makes them one of the most common types of blockchain oracles.
Some smart contracts need to interface with the real world. Hardware oracles are designed to get information from the physical world and make it available to smart contracts. Such information could be relayed from electronic sensors, barcode scanners, and other information reading devices.
A hardware oracle essentially “translates” real-world events into digital values that can be understood by smart contracts.
An example of this could be a sensor that checks if a truck transporting goods has arrived at a loading bay. If it does, it relays the information to a smart contract that can then execute decisions based on it.
Inbound and outbound oracles
Inbound oracles transmit information from external sources to smart contracts, while outbound oracles send information from smart contracts to the external world.
Centralized and decentralized oracles
A centralized oracle is controlled by a single entity and is the sole provider of information for the smart contract. Using only one source of information can be risky – the effectiveness of the contract depends entirely on the entity controlling the oracle. Also, any malicious interference from a bad actor will have a direct impact on the smart contract. The main problem with centralized oracles is the existence of a single point of failure, which makes the contracts less resilient to vulnerabilities and attacks.
Decentralized oracles share some of the same objectives as public blockchains – avoiding counterparty risk. They increase the reliability of the information provided to smart contracts by not relying on a single source of truth. The smart contract queries multiple oracles to determine the validity and accuracy of the data – this is why decentralized oracles can also be referred to as consensus oracles.
Some blockchain projects provide decentralized oracle services to other blockchains. Decentralized oracles can also be useful in prediction markets, where the validity of a certain outcome can be verified by social consensus.
A contract-specific oracle is one that is designed to be used by a single smart contract. This means that if one wants to deploy several smart contracts, a proportionate number of contract-specific oracles have to be developed.
This type of oracle is considered very time-consuming and expensive to maintain. Companies that want to extract data from a variety of sources may find this approach very impractical. On the other hand, since contract-specific oracles can be designed from scratch to serve a specific use case, developers have high flexibility to tailor them to specific requirements.
The Oracle Problem
Since smart contracts execute decisions based on data provided by oracles, they are key to a healthy blockchain ecosystem. The main challenge with designing oracles is that if the oracle is compromised, the smart contract relying on it is also compromised. This is often referred to as The Oracle Problem.
Since oracles are not part of the main blockchain consensus, they are unfortunately not part of the security mechanisms that public blockchains can provide. The trust conflict between third-party oracles and the trustless execution of smart contracts remains a mostly unsolved issue.
Man-in-the-middle attacks can also be a threat, where a malicious actor gains access to the data flow between the oracles and the contract and modifies or falsifies the data.
A reliable mechanism that facilitates communication between smart contracts and the external world is vital to the global adoption of blockchains. Without blockchain oracles, smart contracts would have to rely only on information already within their networks, which would considerably limit their capabilities.