June 11, 2024

What Are Blockchain Oracles?

What Are Blockchain Oracles?

A blockchain oracle is a third-party service that provides external data to smart contracts, enabling them to access real-world or off-chain data. This access allows smart contracts to execute based on inputs and outputs from off-chain data, ultimately determining the outcomes of certain smart contracts.

Blockchain oracles bridge the gap between smart contracts and the real world by taking off-chain data and making it usable on a blockchain for smart contracts. 

Blockchains and the smart contracts running on them are deterministic, meaning that events or actions occur in a predefined logical order. By design, blockchains are isolated from off-chain data and must remain deterministic for network nodes to reach a consensus.

Image credit: Chainlink

However, due to this inherent design, blockchains can only access on-chain data and smart contracts cannot directly access real-world or off-chain data. This is where oracles come into play.

Blockchain oracles can provide real-time prices of tokens to DeFi protocols, data on real-world events to dApps e.g. the outcome of a football match to a betting protocol and lots more.

How  Blockchain Oracle Works

The operation of a blockchain oracle involves smart contracts requesting and retrieving information from an external source—data not stored on the blockchain—resulting in the seamless integration of external, real-world data with on-chain smart contracts. 

Here is a step-by-step explanation of how blockchain oracles function:

  1. Data Collation: Blockchain oracles actively gather data and information from diverse off-chain sources, such as websites, APIs, IoT/hardware devices, sensors, human input, and more. 

The objective is to acquire pertinent and real-time data for the execution of smart contracts within a blockchain network. 

  1. Data Validation:  After collating external data, oracles thoroughly validate its authenticity to ensure the accuracy and reliability of the information being brought onto the blockchain. 

This process helps safeguard against the inclusion of false, incorrect, or manipulated data, thereby maintaining the integrity of the smart contracts.

  1. Data Request: Smart contracts initiate data requests, each tailored to the specific requirements of the decentralized application. Generally, these requests specify the desired data and its sources, along with instructions on processing and aggregating responses into a singular value. 
  1. Transmission to Smart Contracts and Execution:  Validated data or information is transmitted onto the blockchain to interact with smart contracts. This data acts as the catalyst for predefined conditions or actions within the smart contract.

Equipped with real-world insights, smart contracts can autonomously execute actions or decisions based on the received external data. This capability enables smart contracts to respond to dynamic external events in real time.

Types of Blockchain Oracles 

Blockchain oracles can be categorised by their source of data, design, direction of information, administration(trust models) etc. Here are some popular types of oracles: 

Hardware Oracles: These oracles acquire real-world data from physical devices, computer peripherals, and offline sources. For example, they may need to obtain information or data from electronic sensors, QR scanners, and Internet of Things (IoT) devices. 

In short, they translate real-world events and data into digital values that smart contracts can understand, thereby enabling the integration of tangible elements into decentralised applications.

Software Oracles: Software oracles fetch data from online sources, which could include websites, cloud servers, or any data source on the web. Some common types of data include exchange rates, real-time weather data, match/game results, and more.

Centralised Oracles: These oracles are characterised by a single entity managing and controlling the oracle setup. In this setup, both data sourcing and validation are conducted by the same entity.

Image credit: Chainlink 

Decentralised Oracles: Decentralized oracles comprise a network of independent nodes where multiple nodes collate and validate external data, thus enhancing the reliability and correctness of the data. This type of oracle utilises consensus mechanisms to validate the accuracy and timeliness of external data before it is sent to the smart contract

Inbound Oracles: Inbound oracles transmit data from off-chain sources to the on-chain contract. They deliver off-chain data and real-world information to smart contracts

Outbound Oracles: Outbound oracles transmit data from the blockchain/smart contracts to an external party. This external/third party can be another blockchain or an off-chain/web2 application, website, or database.

Blockchain Oracles Use Cases 

Financial Data for DeFi Protocols

Blockchain oracles play a crucial role in the decentralized finance (DeFi) industry. DeFi protocols for lending and asset trading heavily depend on oracles to obtain real-time data on asset/token prices, exchange rates, and capital markets information. 

These oracles serve as bridges between the blockchain network and external data sources, ensuring the accuracy and reliability of the information used within the DeFi ecosystem 

Generating Authentic Randomness for Blockchain Applications 

Due to the deterministic nature of blockchains and smart contracts, they can not generate random and unpredictable outcomes so they rely on oracles. This is useful in gambling (betting) and gaming protocols.  

Accessing Real-World Event Outcomes

Blockchain oracles play a pivotal role in enabling smart contracts to react to real-world events. For instance, decentralized insurance protocols utilize oracles to access precise weather data or disaster reports, allowing smart contracts to adjust insurance policies accordingly. Moreover, oracles assist smart contracts in accessing real estate databases to ensure accurate property valuations and calculate occupancy rates for properties.

Challenges Associated With Blockchain Oracles

Despite their numerous uses, blockchain oracles also introduce certain vulnerabilities and attack vectors to decentralized applications (dApps), particularly within DeFi protocols. 

Malicious actors can exploit these vulnerabilities by executing flash loan attacks, which manipulate asset prices on DeFi protocols to exploit the protocol itself.

See: Understanding Crypto Flash Loan Attacks: The Risks & Prevention 

To mitigate these risks, it is often recommended for projects to utilise decentralised oracles instead of centralised ones, thereby avoiding the single point of failure inherent in centralised oracles.

Additionally, protocols should undergo thorough auditing processes to identify and address any potential loopholes or vulnerabilities.

The Bottomline

In essence, blockchain oracles play a crucial role by providing essential real-world information, thereby transforming smart contracts from static, on-chain deterministic programs into dynamic, adaptable decentralised applications. 

This transformation equips smart contracts with real-world value and utilities, enabling them to interact with and respond to external conditions and events further increasing the possibilities and functionalities of smart contracts. 

[Author’s Note: This article does not represent financial advice, everything written here is strictly for educational and informational purposes. Please do your own research before investing.] ‍

 Author: Godwin Okhaifo

Also Read: What is DePIN (Decentralised Physical Infrastructure Networks)?