DeFi

Blockchain oracle

Also called: oracle · price oracle · price feed

Definition

A blockchain oracle is a service that brings outside data, most often asset prices, onto a blockchain so smart contracts can use it for actions like liquidations, settlements and swaps.

This entry is shown in English.

How Blockchain oracle works

Smart contracts can only read data already on their own chain. To know the price of ETH in dollars, a lending protocol needs someone to publish that price on-chain. Oracle networks such as Chainlink and Pyth collect prices from many sources and publish them, often with several independent node operators.

Oracles decide when loans get liquidated, how perp DEXs mark positions, and how synthetic assets are priced. If an oracle reports a wrong price, even briefly, contracts act on it.

Many DeFi exploits came from weak oracle design, for example using the spot price of a single thin DEX pool, which an attacker can move with a large trade or a flash loan. Stronger setups use aggregated prices, time-weighted averages and sanity checks.

Example

Suppose a lending protocol reads the price of a small token from one DEX pool holding only 200,000 dollars. An attacker uses a flash loan to buy the token in that pool, pushing its price from 1 to 4 dollars. The protocol now values the attacker's 100,000 tokens of collateral at 400,000 dollars instead of 100,000, and the attacker borrows against that inflated value. An aggregated oracle using many markets would have shown a far smaller move.

Common mistakes

  • Assuming a DeFi price is always the same as the price on major exchanges.
  • Ignoring which oracle a lending or perp protocol uses before depositing.
  • Thinking oracles are only about prices, when they can also deliver data such as random numbers or event outcomes.

Learn and practise

FAQ

What is the oracle problem?

Blockchains cannot verify outside data by themselves, so contracts must trust the oracle's data. The challenge is making that data hard to manipulate or fake.

Is Chainlink an oracle?

Yes. Chainlink is one of the most widely used decentralized oracle networks, providing price feeds and other data to many blockchains.