What is Oracle
Oracles are data feed services acting as a bridge between a blockchain and the external world. It can bring off-chain data into the blockchain network and enable the data to be used by smart contracts or transmit the on-chain data to off-chain clients, allowing them to act based on the information. Mainstream blockchain oracles include Chainlink, UMA Oracle, Witnet, Band Protocol, etc.
Two Major Components of the Oracle
An oracle contract is an on-chain smart contract that receives data requests from other smart contracts, passes the request to the oracle node, and broadcasts the data results to the requester.
The oracle node is the off-chain component of the oracle service. It extracts, verifies, and transmits information from external sources to oracle contracts.
For security reasons, smart contracts are prohibited from accessing information stored outside the network, since external data sources may be mutable and nontransparent and this is not conducive to consensus among blockchain nodes.
Take for example a smart contract that executes a transaction based on the current ETH-USD exchange rate obtained from a traditional price API. Data from different data sources may be inconsistent (not to mention that the API could get deprecated or hacked), meaning nodes executing the same contract code would arrive at different results. And this could cause the networks' consensus to break down and eliminate the blockchain's value as a decentralized computing platform.
Therefore, it is crucial that a particular input to a smart contract would only produce one particular output.
In addition, being isolated from the outside world will limit the application of smart contracts, eg. prediction market, crop insurance, etc.
To solve this problem, Oracle uploads, and stores the outside data on blockchains. As the on-chain data is unalterable and publicly available, nodes can safely use off-chain data to compute state changes without breaking consensus.
The Applications of Oracle
For the decentralized lending market, the protocol needs the current market prices of assets (such as ETH) to determine the value of users' collateral. So that they can evaluate one's borrowing capacity and check if the position is safe.
Insurance protocols need data from on-chain or off-chain to verify the occurrence of insurable events during claims processing. For example, crop insurance pays out when certain weather phenomena have taken place. The weather data is fed by the oracle.
Cross-Chain Oracles refer to oracles that read and write information between different blockchains. It provides a middleware for protocols that enables them to connect to any blockchain without spending time and development resources integrating with each chain.
You might also be interested in the following information:
What else do you want to learn?