Coming soon: The only portfolio tracker you’ll ever need. Find out more

The Role of Oracles in Smart Contract Execution

The Role of Oracles in Smart Contract Execution

Learn the role of oracles in smart contracts, how they work, key challenges, and what's next for the space.

In Greek mythology, people would ask questions to Apollo – the god of prophecy – who channeled answers through the Oracle of Delphi. The priestess would go into a trance and sometimes deliver cryptic information about everything from wars to planting schedules.

Blockchain oracles serve as a bridge between on- and off-chain infrastructure, much like the Oracle of Delphi was a bridge between Apollo and the people. Since we have intentionally separated blockchains from external systems, oracles are essential for feeding external information into smart contracts that rely on real-world conditions.

In this article, we’ll dive into the role of oracles in smart contracts, how they work, key challenges, and what’s next for the space.

What Are Oracles & How Do They Work?

Suppose you want to bet a friend on the outcome of a sports match using a smart contract. You might bet $10 on Team A, and your friend might bet $10 on Team B, with a smart contract holding the $20 in escrow before releasing it to the winner.

But how does the smart contract know who won the match?

Here’s where an oracle comes into play. The smart contract itself can’t access external data, like sports scores. It needs an external source – the oracle – to provide the information.

The smart contract might implement an oracle client that forwards the request (and a payment) to an oracle contract that runs alongside off-chain oracle nodes. For example, you may send a request to execute a specific job (checking a specific sports scores API) that sends the response back to a specific callback function in your smart contract to determine the winner.

What Are Oracles & How Do They Work?
Chainlink uses the LINK token and oracle contracts to facilitate these capabilities. Source: Chainlink Documentation

Of course, you can improve the system even more by using aggregator contracts that look at multiple data sources and checking for consensus among a minimum number of oracle node operators. That way, it’s harder to argue that your friend found a way to alter the sports scores API or secretly spun up an oracle node to publish a fake score.

Different Approaches to Building Oracles

The blockchain oracle ecosystem has been rapidly expanding over the past few years. There are nearly 20 decentralized oracles networks as of 2023, operating on Ethereum, Polygon, BNB, Avalanche, and other blockchains. Depending on the use case, these oracles can use several approaches to bridge on-chain and off-chain data.

Levels of Decentralization

Decentralization is a core tenant of blockchains, but oracles aren’t always decentralized. Instead, they typically fall on a spectrum of decentralization.

  • Centralized Oracles – A single trusted entity controls these centralized oracles, aggregates off-chain data, and updates the oracle’s data as needed. While they’re the most efficient option, they may be susceptible to manipulation, censorship, or hacks, creating a single point of failure for smart contracts relying on them.
  • Consensus Oracles – Consensus oracles leverage data from other oracles to reach a consensus. While they still rely on the accuracy of other oracles in their network, they aren’t genuinely centralized. An owner must approve the consensus among these oracles, meaning there’s another single point of failure.
  • Decentralized Oracles – Decentralized oracles rely on multiple participants in a peer-to-peer network to form a consensus on off-chain data before broadcasting it to a smart contract. While this eliminates any single point of failure, they may be slower and more expensive to operate than centralized or consensus oracles.

Sources of Information

Most blockchain oracles rely on software APIs – but that’s not their only source of information. Depending on the use case, they may rely on hardware or people.

  • Software Oracles – Software oracles are the most common and gather information from digital sources, like APIs or databases.
  • Hardware Oracles – Hardware oracles gather information from real-world sources, such as Internet-of-things (IoT) devices or sensors.
  • Human Oracles – Human oracles gather information from various sources and act as a trusted intermediary, using cryptography to authenticate their identity.

Directionality of Information

Blockchain oracles typically take information from the outside world and deliver it to a smart contract. But in some cases, data may flow the other way, too.

  • Inbound Oracles – Inbound oracles receive off-chain information and bring it to the blockchain. For instance, the oracle we discussed earlier brings sports scores to a smart contract to determine the winner of a bet.
  • Outbound Oracles – Outbound oracles transmit information from the blockchain to an outside source. For example, an oracle might transmit a reward code when the blockchain receives a payment.

Popular Oracle Use Cases

Blockchain oracles can help address problems well beyond sports bets. According to Chainlink, smart contracts must connect to the outside world to realize up to 90% of their potential use cases. And it’s easy to see why: Most financial services rely on external data.

Some common examples include:

  • Decentralized Finance – Many DeFi smart contracts rely on different asset prices to calculate borrowing capacity or collateralization levels. With a blockchain oracle, these smart contracts can determine the market price of different assets to make these calculations reliably.
  • Non-Fungible TokensNFTs typically rely on randomness to generate attributes and ensure the uniqueness of each token. Using things like Chainlink VRF, which uses verifiable random functions to generate randomness, smart contracts can verify that they’re using tamper-proof randomness on-chain.
  • Financial Products – Crypto-powered insurance companies can use blockchain oracles to incorporate weather information or other factors into insurance products and use that information to verify claims. And that’s just scratching the surface of what’s possible when developing financial products using the blockchain.

Key Risks & Challenges

Blockchain oracles have a unique solution to the pressing problem of delivering off-chain information to on-chain smart contracts. But like any technology, users should understand a handful of challenges before diving in.

These challenges include:

  • Concentration Risk – Chainlink dominates the blockchain oracle market. While its decentralization means it’s not a single point of operational failure, there is a concentration of governance and decision-making.
  • Data Quality – Oracles must obtain data from off-chain sources, creating the risk of selecting low-quality or manipulated data. Poor data quality could happen due to misreporting from a centralized oracle or the nodes of a decentralized oracle.
  • Technical Risk – Smart contracts relying on off-chain data could experience a disruption when oracles go offline, creating network congestion and latency. And these issues could lead to a failure of smart contracts to execute.

Fortunately, blockchain oracles are constantly improving and building solutions to these problems. For example, Chainlink ties data into categories, such as verified, monitored, or provisional, to highlight their quality and risk level. Over time, these efforts could make them a more robust part of the Web3 ecosystem.

The Bottom Line

Oracles are essential in connecting on-chain smart contracts with off-chain data sources, much like the Oracle of Delphi helped connect people with Apollo. However, some significant challenges face the development of oracles before they become a mainstay in the crypto ecosystem.

If you trade crypto assets, ZenLedger can help you stay organized for tax time by aggregating transactions, computing gains and losses, and generating the forms you need to file. In addition, you can find ways to harvest tax losses and access a grand unified accounting spreadsheet.

Get started today for free!

This material has been prepared for informational purposes only and should not be interpreted as professional advice. Please seek independent legal, financial, tax, or other advice specific to your particular situation.

Justin Kuepper