In the previous article of the series on smart contracts, we considered the scope of application of smart contracts, their advantages, and disadvantages.
We partially touched on the topic of oracles for smart contracts. For their work, smart contracts need to receive information from the outside world. This is responsible for special software “pads” to the outside world, which are called oracles.
In today’s article, we will analyze what oracles are and how they work, and also find out how oracles allow smart contracts to reduce infrastructure costs.
What are oracles and why are they needed
Oracles are third-party services that provide smart contracts with information from the outside world. Oracles act as a bridge between the blockchain, on which smart contracts work, and the outside world. In fact, oracles are tools that allow smart contracts to learn the results of necessary events from the real world.
The need to use oracles for smart contracts is conditioned by the fact that blockchain and smart contracts do not have the necessary technical capabilities to obtain information from the outside world. At the same time, for many contracts, it is vital to obtain information from the outside world to comply with the terms of the transaction.
For example, smart contracts for the sale of goods need to confirm the fact that the customer has received the goods. For smart contracts that trade exchange assets, it is necessary to receive information about exchange summaries of the cost of goods.
It is for these purposes that oracles are used in smart contracts. Oracles are an important part of the technology stack needed for a wide range of decentralized applications (dApps). They are the link between the physical universe and the virtual reality of blockchain platforms and are an integral part of the communication of smart contracts.
Oracles are a necessary element of the blockchain system since they allow you to significantly expand the capabilities of smart contracts. Without the existence of oracles, smart contracts would be very limited in their capabilities, since in this case, smart contracts would receive information only from their internal sources.
The need to develop reliable and effective oracles is one of the main technical barriers to the mass implementation of smart contracts.
Types of oracles
Oracles in the blockchain can be classified depending on several different qualities:
- The source of origin of the data. The sources can be software, hardware, or it can be a real network participant providing services to the blockchain system;
- The direction of the information. The information can be either incoming or outgoing;
- The distribution of the source. Information sources can be either decentralized or centralized.
Depending on the criteria described above, oracles can include:
- Machine oracles are sensors that generate and send digital information in a format readable by smart contracts. Machine oracles include measuring devices, light sensors, thermometers, pressure sensors;
- Network participants who provide information exchange services with the blockchain system for a reward in cryptocurrency;
- Artificial Intelligence (AI). AI can also be used as an oracle for smart contracts. AI algorithms can search for the necessary information on the Internet, analyze it and provide it as a report to a smart contract;
- Software systems with their own consensus mechanisms for confirming the receipt of data from the outside, built on top of the main data registry. Such systems use consensus mechanisms similar to those used in the blockchain to confirm the authenticity of transactions. It should be noted that in the case of smart contracts, these systems can be both centralized and decentralized.
In some cases, oracles can be integrated with the main blockchain and work within the same consensus mechanism as the rest of the network.
How do oracles work?
As we have already found out, access to external information is necessary for the development of a decentralized economy.
All applications and smart contracts running on the blockchain need triggers to launch a software algorithm for providing a service in the form of an automated action. These triggers come from various sources that initiate transactions in the blockchain or instruct smart contracts to launch a programmed algorithm and fulfill the conditions laid down in it.
Information sources can initiate requests to smart contracts through transactions on the blockchain, and smart contracts respond to them with an appropriate on-chain transaction and launch a mechanism for automated fulfillment of the conditions specified in the contract.
Let’s consider the mechanism of the work of oracles on a specific example.
For example, a farmer wants to ensure his crop in case of drought. He enters into a contract with a decentralized insurance platform.
An outdoor temperature sensor is used as an oracle. If the sensor detects an excess of the permissible temperature level for a certain period of time, this may indicate a drought in the region and a loss of crop for the farmer. The information from the sensor is recorded and transmitted to the smart contract.
If the terms of the smart contract stipulate that in the event of a signal from the sensor about exceeding the permissible air temperature within a specified period of time, an insurance amount in cryptocurrency is paid to the farmer’s wallet.
Machine oracles allow you to automate a wide range of actions related to insurance, without the need for intermediaries.
The sensors can act in tandem with custom oracles. Additional confirmation by real network participants may be necessary for the event of a breakdown of the temperature sensor. For example, as the temperature sensor detects an excess of temperature, one or more user oracles must confirm the accuracy of the information for a reward in cryptocurrency.
In this example, to determine the drought in the region, you can use an AI that will collect and analyze data on the weather forecast for each day in the region. If the permissible air temperature is exceeded, the AI algorithms send a signal to the smart contract, and it sends the insurance amount in cryptocurrency to the farmer’s account.
Areas of use of oracles
Decentralized insurance is not the only industry where the use of oracles can significantly increase efficiency and expand the range of services. Among the industries where the use of oracles is necessary are:
- Product supply chain management — containers or packages equipped with sensors can trigger the execution of a smart contract depending on the location;
- Component lifecycle monitoring — initiating replacement purchases before a system failure;
- Tolls — automatic payments for the use of public or private transport infrastructure.