Oracles
Oracles bring outside data like prices and event results onto blockchains. Learn how Chainlink feeds and UMA's optimistic oracle work, and how attacks happen.
Blockchains are closed systems: smart contracts can read data on the chain, but they cannot see the outside world. They do not know the price of Bitcoin on exchanges, the result of an election or the temperature in Chicago. Oracles solve this problem by bringing external data onto the blockchain in a form contracts can use. Lending protocols use oracles to value collateral, derivatives use them to settle, and prediction markets such as Polymarket use them to resolve outcomes. Because so much money depends on oracle data, oracles are critical infrastructure and a frequent target of attacks.
Why oracles are needed#
| Application | Data needed |
|---|---|
| Lending protocols | Collateral prices to decide liquidations. See DeFi Basics |
| Perpetual DEXs | Index prices for funding and liquidations |
| Stablecoins | Collateral values |
| Prediction markets | Event outcomes and asset prices |
| Insurance | Weather data, flight delays |
Types of oracles#
| Type | How it works | Examples |
|---|---|---|
| Decentralised price feeds | Many independent node operators report prices from multiple sources; the contract uses an aggregate | Chainlink, Pyth |
| Optimistic oracles | Someone proposes an answer with a bond; it becomes final unless disputed during a challenge window | UMA |
| On chain DEX prices | Prices taken from on chain trading pools, often averaged over time (TWAP) | Uniswap TWAP |
| Centralised oracles | A single trusted provider posts data | Exchange or company feeds |
Chainlink price feeds#
Chainlink is the most widely used oracle network. Independent node operators fetch prices from data aggregators and exchanges, and an aggregation contract combines their reports. Feeds update when prices move beyond a set threshold or after a set time. Chainlink Data Streams provide lower latency prices for derivatives and fast markets.
Polymarket's short crypto up or down rounds, such as 5 minute and 15 minute Bitcoin rounds, settle on Chainlink price data, which is why the price to beat and final price come from Chainlink rather than any single exchange. See Price to Beat and How Rounds Settle and Up or Down Markets Explained.
UMA's optimistic oracle#
For questions that are not simple prices, such as "Did this event happen?", UMA uses an optimistic design:
- A proposer submits an answer and posts a bond.
- A challenge period follows, often two hours for many Polymarket markets.
- If no one disputes, the answer becomes final.
- If disputed, the question goes to a vote by UMA token holders, and the losing side forfeits its bond.
This lets many markets resolve cheaply, relying on economic incentives to keep proposers honest. Disputes have occurred over ambiguous wording, which is why reading market rules matters. See How Polymarket Works.
Oracle attacks#
Defences#
- Multiple data sources and node operators.
- Time weighted averages to resist short spikes.
- Deviation thresholds and circuit breakers.
- Using deep, liquid markets for price sources.
- Dispute mechanisms with economic penalties.
Why traders should care#
- Liquidation triggers depend on oracle prices, not the last trade on your exchange. See Mark Price vs Index Price.
- Settlement sources determine prediction market and option payoffs.
- Oracle delays during fast markets can create gaps between oracle and exchange prices.
- Oracle failures are a source of smart contract risk. See Bridge and Smart Contract Risk.
Frequently asked questions#
What is a blockchain oracle?#
A service that brings external data, such as prices or event results, onto a blockchain so smart contracts can use it.
How does Chainlink work?#
Independent node operators report data from multiple sources, and an on chain contract aggregates their reports into a single price feed.
What is an optimistic oracle?#
A system where a proposed answer is accepted unless someone disputes it within a challenge period, as used by UMA for Polymarket resolutions.
Next, learn how transaction ordering creates profit and risk in MEV.
3 quick questions on this lesson. Get them all right to finish it.
Turn on JavaScript to take the quiz.
Mentioned in
- AltcoinsCrypto
- Blockchain BasicsCrypto
- Crypto and Prediction Markets Learning PathStart Here
- Market Data ExplainedData and Alternative Data