Learning Objectives – after this chapter you will be able to:
  • Explain the “oracle problem”.
  • Classify oracles by direction, source and trust model.
  • Describe how a price-feed oracle works.
  • Identify oracle risks and how to mitigate them.
The Oracle Problem
  • Smart contracts are deterministic and can only read data that is already on the blockchain. They cannot call a website, read a sensor or check a bank balance, because different nodes might get different answers.
  • Yet many applications need outside information: exchange rates for loans, match results for prediction markets, weather for crop insurance, delivery confirmation for supply chains.
  • A blockchain oracle is a service that brings external data on-chain (or sends on-chain events out) so contracts can use it.
  • The oracle problem: a decentralized, trust-minimised contract becomes only as reliable as the oracle feeding it. A single, centralized oracle re-introduces a trusted third party and a single point of failure.
Types of Oracles
TypeDescription
InboundBring off-chain data on-chain (prices, weather, sports results).
OutboundSend on-chain events to off-chain systems (e.g. trigger a bank payment or unlock a smart lock).
Software oraclesRead online sources such as APIs and websites.
Hardware oraclesReport data from physical sensors, RFID or IoT devices.
Human oraclesExperts or reporters who submit and attest to information.
Computation oraclesPerform heavy or private computation off-chain, e.g. verifiable random numbers (VRF).
Centralized vs decentralizedOne provider vs a network of independent nodes that aggregate many sources.
How a Price-Feed Oracle Works
1. SourcesMany exchanges and data providers.
2. Oracle nodesIndependent operators fetch and sign the data.
3. AggregationOn-chain contract takes the median of responses.
4. ConsumerDeFi contract reads the latest price.
  • Push model: the oracle updates the on-chain value regularly or when it moves beyond a threshold.
  • Pull model: the application fetches a signed data report when it needs it and verifies it on-chain.
  • Decentralized oracle networks (for example Chainlink) use many node operators and data sources, and economic incentives, to reduce trust in any single party.
Oracle Risks and Mitigations
RiskMitigation
Single point of failure / dishonest providerUse multiple independent oracle nodes and data sources.
Price manipulation (e.g. using a large flash loan to move a thin DEX pool’s spot price)Use time-weighted average prices (TWAP) and aggregated feeds rather than a single pool’s spot price.
Stale dataCheck timestamps and reject data older than a limit.
Data tampering in transitRequire signed reports and verify signatures on-chain.
Key Takeaways
  • Contracts cannot fetch off-chain data themselves; oracles bridge that gap.
  • The “oracle problem”: a contract is only as trustworthy as its data source.
  • Decentralized, aggregated, time-weighted feeds reduce manipulation risk.
Question / Answer (15 questions)

Answer : A blockchain oracle is a service that delivers external (off-chain) data to smart contracts, or sends on-chain events to external systems, so that contracts can react to real-world information.

Answer : Every node must execute a contract and get the same result. External data can differ between nodes or change over time, which would break deterministic execution and consensus.

Answer : It is the challenge that a decentralized smart contract is only as reliable as the external data it receives. If one centralized oracle supplies that data, it becomes a trusted third party and a single point of failure.

Answer : Inbound oracles bring off-chain data, such as prices or weather, onto the blockchain. Outbound oracles send information from the blockchain to off-chain systems, for example triggering a payment or a physical device.

Answer : A hardware oracle reports data from physical devices such as sensors, RFID tags or IoT devices – for example a temperature sensor confirming that a vaccine shipment stayed cold.

Answer : An oracle that performs computation off-chain, because it is too expensive or needs secret inputs, and returns the result with proof – for example generating verifiable random numbers (VRF) for games or lotteries.

Answer : It uses many independent node operators and multiple data sources and aggregates their answers (for example by taking the median), so a few faulty or malicious participants cannot control the result.

Answer : In the push model, the oracle regularly writes updates to an on-chain contract. In the pull model, the application requests a signed data report when needed and verifies it on-chain during its own transaction.

Answer : An attacker can temporarily move the price of a thin pool, for example with a large flash loan, and exploit contracts that trust that momentary price within the same transaction.

Answer : A Time-Weighted Average Price averages prices over a period of time. It is much harder and more expensive to manipulate than an instantaneous spot price.

Answer : If an oracle stops updating, the stored value becomes stale. Using outdated prices could allow unfair liquidations or trades, so contracts should reject data older than a defined limit.

Answer : DeFi lending that needs asset prices for collateral, parametric crop insurance that pays out based on weather data, and prediction markets that settle on sports or election results.

Answer : Oracle nodes sign their reports with private keys. The on-chain contract verifies the signatures, ensuring the data came from authorised nodes and was not altered in transit.

Answer : Centralized oracles are simple, fast and cheap but require trust in one provider. Decentralized oracles are more robust and trust-minimised but are more complex and costly to operate.

Answer : Determinism. Because all nodes must reach identical results, contracts can only use data available on-chain, which is why oracles must bring external data in.
MCQ Test : Check Your Understanding (5 questions)

Select an option and press Check Answer, or answer all questions and press Submit Test to see your score. Each answer comes with an explanation.

Q1. The main purpose of a blockchain oracle is to:

Show Answer

Correct Answer : B. Bring off-chain data to smart contracts
Oracles connect smart contracts with external data and systems.

Q2. An oracle that triggers an off-chain action from an on-chain event is:

Show Answer

Correct Answer : C. Outbound
Outbound oracles send information from the chain to the outside world.

Q3. Which technique reduces price-manipulation risk?

Show Answer

Correct Answer : D. Using a time-weighted average price from aggregated sources
TWAPs and aggregation make manipulation harder and costlier.

Q4. A temperature sensor reporting shipment conditions is an example of a:

Show Answer

Correct Answer : A. Hardware oracle
Hardware oracles report data from physical devices.

Q5. The “oracle problem” refers to:

Show Answer

Correct Answer : B. A contract being only as trustworthy as its external data source
Trusting one data provider undermines decentralization.

Bibliography/References

The notes, questions and MCQs on this page are original explanations written for this course. The works listed below were consulted and are cited for attribution and further reading. Product names, logos and trademarks belong to their respective owners. Short quotations, where used, are marked and attributed.

  1. ethereum.org. (n.d.). Oracles. Ethereum Developer Documentation. https://ethereum.org/en/developers/docs/oracles/
  2. ethereum.org. (n.d.). Decentralized finance (DeFi). https://ethereum.org/en/defi/
  3. ethereum.org. (n.d.). Smart contract security. Ethereum Developer Documentation. https://ethereum.org/en/developers/docs/smart-contracts/security/
  4. Antonopoulos, A. M., & Wood, G. (2018). Mastering Ethereum: Building Smart Contracts and DApps. O’Reilly Media.