Apr 28, 2024 1:13:57 AM

Blockchains are deterministic systems, so their operations need to run in a closed environment. Blockchains cannot send queries to websites or applications outside their own environment.

However, for blockchains to have real-life applications, they need to be aware of events outside of them. For example, a smart contract involving tokens might need to query the current price of a specific token relative to the dollar. Another example would be a betting contract, in which the result of a game must be able to be consulted by the smart contract so that it resolves the winners.

It is to solve this problem that Oracles come in. They are a gateway for smart contracts to communicate with the outside world. In general, Oracles are applications that keep smart contracts continuously updated with relevant information or based on requests from other contracts.

Let’s imagine an Oracle that must keep the bitcoin price relative to the dollar updated on a blockchain. Such Oracle will have a smart contract that registers such price, and an Oracle will be responsible for keeping this contract updated through regular transactions. So, when a contract wants to know the current value of bitcoin, just request this information from the Oracle smart contract registered on the blockchain.

Notice that at no time is the smart contract communicating with the outside world. The Oracle has to inject the outside world into the blockchain environment.

Another case would be the need for a contract to run an API on a website. Contracts cannot do this directly. What Oracles can do is maintain contracts that accept requisition requests. Those contracts are monitored by the Oracle, and when a request is received, the Oracle takes care of fetching the data from the site in question and injecting them into the blockchain environment in some way.

One of the biggest problems faced by Oracles is the issue of centralization. Contracts need to trust that Oracles keep the information up to date and return accurate answers. That is, contracts need to trust Oracles not to act maliciously. But the idea of creating an execution environment without needing trusted third parties is precisely the purpose of the blockchain.

Thus, Oracles must be maintained by the community or decentralized environments. An example of a decentralized Oracle is ChainLink. Chainlink is an Oracle service for blockchains that is supported by a network of users in a decentralized way. A single entity is never responsible for generating the information an Oracle needs; data is collected from multiple users and aggregated into a final value.

Some blockchains, like Neo, have built-in Oracle services. Oracle nodes are chosen by a committee in the Neo ecosystem, similar to consensus nodes, which are also selected by the community. Thus, the information also goes through a consensus process.