How Do Blockchain Oracles Interact With Smart Contracts?
The concept of smart contracts has been used for a long time in the world of blockchain technologies. Bitcoin allows writing a program code obligating parties to mandatory follow the conditions of the agreement. The implementation of more complex programing languages to write contracts increased their potential and expanded their opportunities. Ethereum itself may be considered as a raw model of such smart contracts application.
Using smarts assures agreement execution once certain conditions are reached. But compliance with these conditions must be verified. If the deal is related to blockchain and its components only, there are no problems. Unfortunately, blockchain does not store any information about the off-chain world. Thus, such a kind of verification cannot be performed entirely through blockchain and smart contract.
Smart contracts flaws
Some blockchains solutions allow writing smart contracts so that it could address external data sources. Unfortunately, this involves various complications and unacceptable consequences. Because of different geolocations, network lags, distributed services, and other breaches of the computer network, two instances of the same smart contract might receive different results after calculations. If two similar contracts on different nodes come to different conclusions, the transaction inconsistency occurs. As a result, the transactions might never been added to the block or might even cause a fork. Moreover, the main concept of smart contracts possesses the following disadvantages:
- A contract is limited to its blockchain as the application area;
- Correct objective execution requires consideration of changing factors;
- It is hard to write a contract correctly;
- An activated contract can’t be changed or removed.
To compensate access limitations, smart contracts require a link between blockchain and the external environment. Software called oracles plays the role of such links. Simply speaking, an oracle is a program that provides blockchain-based contracts with access to external information. A contract asks the oracle for information that will help it make a decision, and the oracle in response will supply the contract with this information.
Oracles may be considered as a specific type of smart contracts. Indeed, an oracle code must be placed in one of full nodes. It interacts with requests from smart contracts and operates according to the strict algorithm. On the other hand, the oracle by itself brings no changes into the blockchain content. It can only send a request to an external data source and retransmit the response to the smart contract.
It should be noted that smart contracts will be different for each blockchain. This is due to the application of different programming languages. In case of Bitcoin, it is a scripting language. Ethereum smarts are built as full-fledged programs written in several languages. Other cryptocurrencies may have absolutely different approaches. Differences in contracts dictate oracles’ variety. Nevertheless, there is no core differences in the role oracles play for smart contracts.
Smart contracts are program products of small size, included in blockchain. Each full node owner has a full copy of all smart contracts. Smart contracts can use the blockchain content only to make decisions.
An oracle is a program code placed on the border of blockchain that can exchange data with smart contracts. Oracles play the role of hardware or software interface. Obviously, the only smart oracle on blockchain threatens the principle of complete distrust to a counterparty. To solve this problem, various approaches are used, including hardware components verification and the polling of other oracles.