New: Wallet recovery made easy with Ledger Recover, provided by Coincover

Get started

Up your Web3 game

Ledger Academy Quests

  • Test your knowledge
  • Earn POK NFTs
Play now See all quests

What Is a Blockchain Oracle?

Read 7 min
Medium
Blockcahin on a grey background
KEY TAKEAWAYS:
— Blockchains cannot independently access data from external sources. 

— Oracles provide the blockchain with real-world data, expanding the capabilities of smart contracts.

— Different types of oracles have different uses defined by three primary factors: data source, direction of information, and trust model.

Blockchains are popular because they can operate without a centralized intermediary, making transactions secure, fast, and cost-efficient. But they have a limitation: Since they are isolated systems, they cannot access data from the outside world. 

Blockchains like Ethereum and Solana use apps powered by smart contracts, which are essentially programs that can self-execute. However, these applications often need data from sources outside their chain’s ecosystem.

So, how do decentralized applications (dApps) get that data?

Through blockchain oracles. But what are oracles?

In this article, Ledger Academy explains how blockchain oracles work, their importance in Web3, and their use cases.

What Is a Blockchain Oracle?

Blockchain oracles are third-party services that can read data on the blockchain and in the real world. This offers smart contracts the use of real-world information and vice versa.

For example, the smart contract of a betting app may need to know the result of a game to decide on a bet winner. An oracle can acquire this data and broadcast it to the contract.

On the other hand, some oracles transmit data from a smart contract to the outside world. This means that an on-chain transaction can dictate an off-chain action’s completion. 

For example, imagine a shop with no cashier. For security, the automatic doors only open when a transaction for the correct amount is processed. In this case, the blockchain oracle will read the approved transaction and broadcast the permission to the automatic doors.   

But why do we even need oracles in the first place?

What Is a Blockchain Oracle For?

Put simply, a blockchain can not read data from or interact with the real world. But you may be wondering why. Well, to understand what oracles are for, you must first understand the blockchain’s shortcomings.

To explain, blockchains are decentralized systems that rely on multiple crypto nodes to execute a transaction. Nodes can only read true or false results derived from on-chain data to reach a consensus.

This limitation helps blockchains maintain a deterministic state. That means, given an initial state and a particular input, the nodes will always produce the same output.

If smart contracts could inherently acquire data from external sources, it would risk a chain’s determinism. 

To understand why, let’s take the example of a BTC to USDT swap.

The BTC-USDT exchange rate changes every second. If a smart contract were to source the exchange rate through a live price API, the nodes would receive different values. That means they’ll arrive at different results while executing the same smart contract. 

Consequently, the nodes will not reach a consensus on a single state of the chain, thus making the system unreliable.

That’s why blockchains and smart contracts can’t directly acquire data from off-chain sources.

This is where blockchain oracles come in. They act as a data bridge between blockchains and any off-chain system. As a result, smart contracts can execute on-chain transactions that otherwise wouldn’t be possible.

How Does a Blockchain Oracle Work?

Oracles have two sides: the on-chain smart contract and the off-chain nodes.

The on-chain smart contract of an oracle listens to any new data requests from all linked smart contracts. When there’s a new request, it passes that on to the off-chain nodes, which then query relevant data sources.

Once the off-chain nodes find the relevant data, they check its validity. Then they extract and translate the data into a format the blockchain can read: a transaction. This transaction goes to the oracle contract on-chain, which can communicate with the original smart contract.

Upon receiving the data, the smart contract self-executes, and the blockchain nodes validate the transaction.

There are also hybrid applications that rely on on-chain transactions to take off-chain actions. These types of oracles send transaction data from a contract to an off-chain system. This will then trigger an off-chain event.

Some oracles even execute off-chain computation for smart contracts. This is especially helpful as on-chain computation is expensive and inefficient.

For example, Chainlink’s Verifiable Random Function (VRF) performs off-chain computation to generate truly random values. It is helpful for apps like lottery games that need unpredictable outcomes.

Types of Blockchain Oracles 

Oracles come in many shapes and sizes, but the best way to categorize them is by their nature. Oracles receive their information from and broadcast their information to, completely different data sources using different tools. The easiest way to understand them is via these three factors,

1. Their source of data: Whether an oracle acquires data from online or offline sources. 

2. Direction of information: Whether an oracle receives or broadcasts information to the real world. 

3. Trust models: Whether the oracle is centralized or decentralized.

Software and Hardware Oracles

Oracles source their data one of two ways: online or offline. 

Software oracles acquire data from online sources. These sources include websites, cloud servers, or any data source on the web. 

The data an oracle extracts depends on the smart contract it is broadcasting to. Some common types of data include exchange rates, real-time weather data, flight information, and match results. 

Then, hardware oracles acquire real-world data from offline sources. For example, they might need to obtain information from electronic sensors, QR scanners, or other information-reading devices. In short, they translate real-world events into digital values that smart contracts can understand. 

For example, in a supply chain, a sensor checking a ship’s arrival status can transmit the information to a hardware oracle. The hardware oracle can then relay the information to the smart contract, which can update the supply chain records across all involved parties.

Inbound and Outbound Oracles

The direction of information determines whether a blockchain oracle is inbound or outbound.

Inbound oracles transmit data from off-chain sources to the on-chain contract. 

Take a blockchain insurance application, for instance. A farmer may file a claim to receive payouts for flood or drought damage on the app. But how does the smart contract know if the claim is legitimate?

Well, an inbound oracle can access weather data from trusted sources and even verify that data using real-world devices like thermometers. Outbound oracles, on the other hand, transmit data from the blockchain to an external party. This external party can be another blockchain or an external application or database.

Centralized and Decentralized Oracles

Centralized oracles are those where a single entity manages an oracle setup. The setup relies on a single data publisher to source and verify the information. 

If the single data publisher goes offline, the smart contract will not have access to the latest data. Even worse, a centralized oracle could broadcast incorrect information to a contract. Since the blockchain is immutable, this poses a problem as the smart contract will execute irreversible incorrect transactions.

Due to these concerns, dApp developers tend to avoid centralized oracle services.

Decentralized oracles solve those challenges. They work with multiple nodes and reliable data sources. This lets them avoid single points of failure and eliminate data inaccuracy, manipulation, or downtime. 

Smart contracts using decentralized oracles can query multiple oracles to determine data accuracy and hence act more reliably.

Other Types of Blockchain Oracles

In addition to the above categories, there are other less common types of oracles:

  • Human oracles: These are individuals with specialized knowledge in a particular field. On-chain apps can use them to answer arbitrary queries or research and verify the information authenticity and relay their findings to smart contracts.
  • Contract-specific oracles: Developers can also create contract-specific oracles to serve the data requests of a single smart contract.
  • Computation oracles: These oracles perform computations off-chain and relay the proof back to the blockchain. 

Blockchain Oracle Use Cases

Oracles help developers build decentralized applications with more complex logic and data requirements.

Here are four popular uses of blockchain oracles.

Insurance: Smart contracts of insurance applications use oracles to verify the occurrence of insurable events. Once a user makes a claim, oracles acquire data from trusted sources to substantiate the claim and send it to the contract. If the claim is legitimate, the contract makes payouts without any manual intervention.

Real estate: Oracles can pull data from real estate databases to provide accurate property valuations and calculate occupancy rates of properties. They also allow smart contracts to verify property-related documents easily. This reduces paperwork and makes the process of buying a property much faster.

Dynamic NFTs: Oracles provide off-chain data and computation services to trigger metadata changes in dynamic NFTs. For example, an NFT character that’s programmed to change its outfit based on the weather requires the help of an oracle to fetch live weather data.

Betting: Blockchain gambling and betting applications use blockchain oracles to receive information on the outcome of events like elections, races, tournaments, etc. The contract can then identify the winners and distribute the rewards.

Examples of Blockchain Oracles

There are several oracle solutions that cater to different use cases and requirements in the DeFi space. But the most commonly used ones include:

Chainlink 

Chainlink is a decentralized oracle network that automates data transfer between a blockchain and an external system. 

It relies on a decentralized network of nodes to retrieve data from multiple data sources. The nodes then aggregate this data and deliver it to smart contracts to trigger its execution.

Chainlink supports many data types, from financial market data to weather reports. Smart contract developers can customize the kind of data their contract needs from the oracles.

Augur 

Augur is a decentralized prediction market platform that uses its own decentralized and trustless oracle service.

Augur users can create prediction markets for any event ranging from the weather to election outcomes. But the smart contract needs reliable data to finalize the outcome of every prediction market.

Augur oracles offer a data source for smart contracts that is free of any centralized intermediaries.

Pyth Network

Pyth Network is a decentralized oracle platform compatible with 13 blockchains. It provides real-time data for financial markets and asset classes like U.S. equities, commodities, and cryptocurrencies.

Pyth sources its data from a network of almost 70 data publishers, including some of the largest exchanges and market-making entities globally. 

How To Interact With Blockchain Oracles Securely

To interact with smart contracts, and oracles, you need a non-custodial crypto wallet. These wallets come in two types: hot wallets and cold wallets.

Both of them offer you complete control over your private keys and digital assets. However, hot wallets stay online and are prone to hacks and thefts.

Hardware wallets like the Ledger Nano X and Stax solve this problem. They store your private key and seed phrase offline at all times, so no one can tamper with your digital assets. 

Despite keeping your private key offline, Ledger lets you interact with online dApps and smart contracts through Ledger Live. This gives you great flexibility without compromising your assets’ security.


Stay in touch

Announcements can be found in our blog. Press contact:
[email protected]

Subscribe to our
newsletter

New coins supported, blog updates and exclusive offers directly in your inbox


Your email address will only be used to send you our newsletter, as well as updates and offers. You can unsubscribe at any time using the link included in the newsletter.

Learn more about how we manage your data and your rights.