TermDeFi and on-chainAdvanced

Oracle

An oracle is a service that feeds a smart contract data from outside, such as an asset price. The blockchain itself cannot see anything beyond its own network.

How it works

A smart contract can only read what is already on the blockchain. To know the dollar price of ETH, a match result or the weather, it needs an oracle: a service that takes data from outside sources and writes it on-chain. The oracle is the bridge, and the contract is only as reliable as that bridge.

Good oracles are decentralized: many independent nodes pull prices from different venues and the contract uses the median or average. The price updates on a schedule or when it moves enough. Some protocols read the price straight from a DEX pool, often averaged over time (TWAP), but such a source is easier to push around.

Lending, stablecoins, derivatives and insurance in DeFi all depend on oracles. If an oracle is wrong or gets fooled, the contract acts on bad data: it liquidates honest borrowers or lends an attacker money against inflated collateral. Oracle attacks are one of the common causes of DeFi hacks.

Example with numbers 1

A DeFi loan is closed by force when the collateral drops below a threshold. The contract learns the collateral price from an oracle.

Example with numbers 2

A protocol reads a token's price from one small pool. An attacker takes a flash loan (a loan issued and repaid within one transaction), buys up the token in that pool and its price spikes 5x for a moment. The protocol sees the new price, the attacker borrows against that collateral and walks away with the funds.

Common mistake

Do not trust a protocol that takes its price from one weak source, such as a single small pool: that price is easier to distort. Before you deposit, check the docs for which oracle is used, how many sources it has and whether it guards against sudden price spikes.

Questions and answers

What is a blockchain oracle in simple terms?

It is a middleman that brings outside information, such as an exchange rate, onto the blockchain. Without it a smart contract knows nothing beyond the data inside its network.

Why does DeFi need oracles?

To know asset prices. Collateral values, liquidations, stablecoin pegs and derivative payouts are all calculated from them.

What is an oracle attack?

An attacker distorts the price a contract sees, for example by moving it sharply in a small pool. The contract trusts the wrong price and pays out funds or liquidates positions.

Read next

Updated: 2026-10-19