Need a crash course on Bitcoin layers?
→ READ OUR FREE GUIDE
Need a crash course on Bitcoin layers?
→ READ OUR FREE GUIDE
Need a crash course on Bitcoin layers?
→ READ OUR FREE GUIDE
Need a crash course on Bitcoin layers?
→ READ OUR FREE GUIDE
Need a crash course on Bitcoin layers?
→ READ OUR FREE GUIDE

What Are Blockchain Oracles and What’s Their Role in dApps

The self-contained nature of blockchains prevents Web3 apps from natively accessing data in, or sending data to, off-chain systems. How can a Web3 app verify that something happened in the physical world, for example? Blockchain oracles are key pieces of infrastructure that enable blockchain apps to access and process real-world data. Read on to learn more about the role of blockchain oracles in Web3 applications.

Type
Deep dive
Topic(s)
Published
February 15, 2023
Author(s)
Community Manager
Blockchain oracles
Contents

What Is a Blockchain Oracle?

Blockchain oracles are third-party services that connect decentralized applications (dApps) to external data sources. They’re key parts of the Web3 tech stack that enable dApps to access both on-chain data from other blockchains as well as off-chain data from other applications and services.

From there, the dApp can display that information to users or use it to affect the outcome of smart contracts and actions within the app. In a sense, this is a similar function to how a blockchain API works—both an oracle and an API help serve data to smart contracts and apps. The important difference is that the oracle handles all external data needs whereas an API handles queries related to the blockchain the Web3 app is built on.

Do Blockchains Need Oracles?

The short answer: all blockchain ecosystems need oracles, but not all Web3 apps need an oracle.

Blockchain oracles are powerful tools that can be used to unlock a world of possibilities when creating Web3 apps. As we touched on above, oracles help access and verify data that exists outside of the blockchain, whether it’s real world data or data from another blockchain ecosystem.

That could be a price oracle: for example, one that makes the current price of Ethereum available in the Stacks ecosystem. This would be invaluable for DeFi apps that want to enable swaps between assets on various blockchains: developers need to ensure that the swap price is fair, and that users are getting market value (minus fees) for whatever asset they are swapping their ETH for.

Not all apps need external data in order to function (for example, a Web3 game might be a great game without needing to pull in data from another blockchain or the real world), but many do. Blockchain oracles open up new possibilities for Web3 apps by giving them reliable access to more data, and with that data smart contracts can have expanded functionality and ultimately bridge to real world use cases.

The Challenge With Oracles 

While blockchain oracles serve an important function in connecting dApps to off-chain data, they also introduce challenges relating to the accuracy of that data, as well as the centralization of its source. At its heart, the challenge is this: how can you trust the data coming from the oracle?

If an oracle provides incorrect data, that could trigger the wrong action from a smart contract. Such a mistake could have potentially devastating effects in a world where smart contracts are used to control billions of dollars, and transactions are final. Users could lose their money, or worse. Oracles also introduce centralization risks: if a decentralized network relies on a single centralized oracle as a data input, that oracle becomes a target for hackers. And what happens if the oracle goes offline for any reason?

To combat the security challenges with blockchain oracles, we’ve seen two major approaches appear in the industry: trusted 3rd-parties that provide oracles as a service, such as Chainlink and Band Protocol, and the overall decentralization of oracle networks. For example, apps can now use data from a decentralized network of oracles that all contribute and verify data, and there is a reputation system in place to help developers identify which oracles can be relied on to provide accurate data.

6 Types of Blockchain Oracles

There are a variety of blockchain oracles in the market today, each with different functions. Some oracles might have a single function, but many fall into multiple categories. 

  • Software oracles are integrated into the smart contracts of Web3 apps primarily through code. They can pull data on certain events or conditions simply by connecting to external data using webhooks. 
  • Hardware oracles are integrated into blockchain and Web3 apps primarily through physical devices—such as IoT sensors and beacons. They pull data from the physical world—such as tracking info in supply chain management or weather conditions—to the blockchain in real time.
  • Inbound oracles provide external data for use in a blockchain or Web3 app. Most blockchain oracles fall into this category.
  • Outbound oracles are the opposite of inbound oracles. They make data from the blockchain available and accessible to off-chain services and applications. 
  • Cross-chain oracles make data from one blockchain available and accessible to applications on another blockchain. They’re crucial for enabling interoperability across blockchain ecosystems.
  • Consensus oracles—also known as decentralized oracles—aggregate data from several oracles. They verify this data for accuracy and legitimacy before returning a single authenticated data point for use in smart contracts.

Whatever blockchain oracle you use, check its reputation by analyzing the historical data that it has signed and delivered to gain some insights into its reliability. If the oracle is reliable, you’re less likely to run into incorrect smart contract transactions.

5 Use Cases for Blockchain Oracles

Without oracles, smart contracts would only be able to use the data that is stored on the blockchain the contract exists on—significantly limiting their functionality. Integrating them with oracles opens up a whole new world of opportunity for many Web3 applications. 

Below are a few use cases for blockchain oracles to highlight how powerful they can be.

  • A DeFi app that wants to include assets from different blockchains (BTC, ETH, SOL, STX, etc) needs an oracle to pull in real-time price data on the current market value of the various assets that trade on the platform.
  • A decentralized health insurance smart contract that is designed to settle claims will need data from an oracle to get real-time data such as patient records, medical history, or prescription databases, among others.
  • A decentralized sports betting platform will need to pull the outcomes of sporting events from an oracle in order to decide outcomes and pay out users. 
  • A decentralized mortgage service may need to access housing records such as land registries, zoning regulations, and certificates of habitability records, among others. 
  • A blockchain-powered supply chain management system that tracks the condition of cargo en route will need GPS tracking data from an oracle to know the location of the cargo in real time and monitor provenance. 

Keep in mind that not all Web3 apps need to be integrated with blockchain oracles. For instance, you don’t need an oracle to buy an NFT on an NFT marketplace. The blockchain nodes can validate the transaction and update the ledger accordingly.

Learn More About the Tech Stack for Building Web3 Apps 

When building a Web3 app, you’ll need an oracle in order to interact with external data. Blockchain oracles are a critical part of the Web3 tech stack, but they are only one of many important components required to build versatile Web3 apps.

In our Comprehensive Guide to Web3 App Development, we cover everything you need to know about building Web3 apps, from getting comfortable with developer tooling to connecting your app to the blockchain, and more.

Want to get started on your Web3 developer journey?

Product updates & dev resources straight to your inbox
Your Email is in an invalid format
Checkbox is required.
Thanks for
subscribing.
Oops! Something went wrong while submitting the form.
Download Hiro’s Guide to Web3 App Development
Copy link
Mailbox
Hiro news & product updates straight to your inbox
Only relevant communications. We promise we won’t spam.

Related stories