A blockchain oracle is designed to provide smart contracts on blockchains with data from an outside, or third-party source. Because smart contracts are simply self-executing code they take the data from the oracle and evaluate it before adding it to their execution flow where appropriate. This is intended to give smart contracts an increased flexibility and utility as they will be able to use third-party data seamlessly.
Consider the following example: Tom and his brother Sam make a bet about the temperature on the coming Sunday. Tom says the temperature will be 95 F or above, while Sam says the temperature will be 94 F or below. The two are programmers so they design a smart contract that will pay the winner depending on what the temperature actually is on Sunday. They both send some funds to the smart contract to cover the bet.
Because the blockchain containing the smart contract doesn’t have anything to do with the temperature it will need to query an outside source, or an oracle, to determine the correct temperature and use that to begin executing properly. The smart contract queries Accuweather on Sunday to determine the correct temperature and receives data indicating that Sunday’s highest temperature was 96 F. It then executes based on its conditions and the data received from the oracle and sends all the funds it is holding to Tom.
Some Types of Blockchain Oracles
A blockchain oracle gives smart contracts added functionality by giving them the means to communicate outside their blockchain. There are a number of forms that can be assumed by a blockchain oracle, which include the following (this is not an exhaustive list):
- Software Oracles
- Hardware Oracles
- Inbound Oracles
- Outbound Oracles
- Consensus Based Oracles
Software Oracles – These are online sources of information and are easily accessible by blockchain smart contracts. They will typically provide physical data such as temperatures, asset prices, transport information, and other publically accessible information. They are probably the most powerful of all the oracle types simply due to the breadth of information and their connection to the internet. Because software oracles are connected to the internet they are capable of providing the most up-to-date information for smart contracts.
Hardware Oracles – In some cases a smart contract needs to know when some event occurs in the real world, such as when a truck parks at a loading dock where motion sensors can detect the truck and send the information to the smart contract. Another use case is in the supply chain industry where RFID sensors are commonly used. The real challenge that hardware oracles face is to report accurately on readings without compromising data security. Oracalize proposes a two-step solution to the risks, by providing cryptographic evidence of the sensor’s readings and anti-tampering mechanisms rendering the device inoperable in the case of a breach.
Inbound Oracles – Inbound oracles are those that provide smart contracts with data from the outside world. Financial smart contracts might be programmed to buy or sell and asset when it reaches a certain price. This type of smart contract would use an inbound oracle to obtain accurate up-to-date price information.
Outbound Oracles – An outbound oracle gives a smart contract the ability to send data it has to the outside world. One example of an outbound oracle might be a smart lock in the physical world which has its own blockchain address. When it receives a payment on its blockchain address the smart contract needs to send a command to unlock it automatically.
Consensus Based Oracles – There are prediction markets on the blockchain such as Gnosis and Augur which rely on oracles to confirm future results. If they used just one source of information it could be unreliable and risky. Instead, prediction markets use a rating system for oracles, and to make things even more secure they can use a combination of different oracles. For example they might use a selection of 4 out of 7 oracles to accurately determine the outcome of some event.
As you can see there are definite advantages to using oracles, but there remains one huge disadvantage and that is Oracles Require Trust.
Oracles Require Trust
In every case the data being used by oracles must be seen as credible and trustworthy. For example, if Tom had somehow gained access to the Accuweather database it would be a trivial thing for him to input a data point showing a maximum temperature of 96 F and thus win the wager between himself and Sam. As you can see, where there exists the possibility of smart contracts receiving faulty or manipulated data from their oracles there also exists a serious security flaw. One possible remedy to this, which prediction engines already use, is to request the information from several oracles instead of just one. In that case if one oracle reported a temperature of 96, but four others reported the temperature as 86 we would know that other conditions might be used to resolve the conflict. For example, the smart contract might only accept the majority value, which is 86 in this case, and then Sam would have been the winner of the bet. Alternatively, the smart contract could be programmed not to function at all if it gets conflicting information, and instead require human intervention.
Blockchain oracles can both send and receive data from third-party sources, making them an extremely valuable resource for smart contracts on a blockchain, where the smart contract needs data that cannot be supplied by the blockchain. Oracles can greatly enhance the functionality of smart contracts by giving them a way to communicate outside their own blockchain. There are many different types of blockchain oracles, including software oracles and hardware oracles.
Despite the decentralized and trustless nature of blockchains, an oracle requires a certain level of trust to be useful. With this being the case we could see smart contracts becoming increasingly complex to deal with the trust issues of oracles. For example, a smart contract may be programmed to query several oracles in order to mitigate the trust required when using a single oracle.
One thing is almost certain, and that’s oracles making smart contracts even smarter. We’ve only begun to scratch the surface of what oracles can do. Prediction engines are one use, but smart contracts on the Internet of Things can make heavy usage of oracles for just about anything you can think of, greatly reducing the need for human intervention, and the possibility of human error.