Skip to content
RED SAGSkills
mediumBlockchain Developer interview question

What is a blockchain oracle and how do you use price data safely?

What the interviewer wants to hear

  • Contracts cannot fetch off-chain data themselves
  • Oracles bring data such as prices on chain
  • Decentralised oracle networks like Chainlink
  • Check staleness, decimals and sequencer uptime on L2
  • Avoid spot prices from a single pool; use TWAP or multiple sources
  • Circuit breakers for extreme values

Model answer

Smart contracts cannot call external APIs, so anything from the outside world, like the ETH/USD price, must be pushed on chain by an oracle. Decentralised oracle networks such as Chainlink, or pull-based ones like Pyth, aggregate data from many sources and node operators. When I use a price feed, I check that the answer is positive, that updatedAt is recent compared with the feed's heartbeat so I am not using stale data, and I handle decimals correctly since feeds and tokens use different decimals. On Layer 2 networks I also check the sequencer uptime feed, because prices can be stale after an outage. I never use the spot price from a single DEX pool, because flash loans can move it in one transaction; if I need an on-chain price, I use a time-weighted average over enough time. For critical protocols I add sanity bounds and a fallback or pause when prices move unrealistically.

Can you answer it under time pressure?

Take a timed medium round and get scored on every answer.

Start mock interview

More medium Blockchain Developer questions