What is a blockchain oracle?
A blockchain oracle is a service that feeds outside information, such as market prices, to smart contracts that cannot look it up themselves.
A blockchain oracle is a service that delivers information from the outside world to a blockchain. Programs on a blockchain cannot browse the internet or check a stock exchange. An oracle fetches the data, most often a price, and publishes it where those programs can read it.
Why do blockchains need oracles?
A blockchain works because every computer on the network runs the same transactions and gets the same answer. That rules out looking things up online, since two computers might see different results at different moments. A smart contract, meaning a program stored on the blockchain, therefore knows only what is already recorded there.
Many applications need more. A lending service in DeFi, short for decentralized finance, must know what a borrower's collateral is worth. A stablecoin backed by other crypto needs the same information. This gap is known as the oracle problem.
How does an oracle work?
The simplest oracle is one party that posts a number to the blockchain. That brings back the single point of trust that blockchains are meant to remove. Most large applications use an oracle network instead.
In a typical network:
- Independent operators each collect the same figure, such as the price of ether in dollars, from several exchanges and data providers.
- Their answers are combined, usually by taking the middle value, so one bad report does not move the result.
- The combined figure is written to a smart contract on the blockchain, called a price feed, and refreshed when the price moves or a set time passes.
- Other contracts read the feed whenever they need it.
Chainlink, whose network went live in 2019, is the most widely known example. Its operators are paid in the project's own token, LINK. Some services read prices directly from a decentralized exchange, using an average over time to make them harder to distort.
Oracles can also supply random numbers for games and pass messages between blockchains.
Why are oracles a risk?
A smart contract cannot tell whether the data it receives is true. It acts on whatever the oracle reports. That makes the oracle a target.
The most common attack is price manipulation. An attacker trades heavily in a thinly traded token to push its price up on the one market an oracle watches, then borrows against the inflated value from a lending service and leaves the service with the loss. Schemes of this kind have drained several lending protocols, often within a single transaction.
Other failures are less dramatic. A feed can freeze or lag during a market crash, which is exactly when accurate prices matter most. An oracle network may also be controlled by a small group of operators or by keys held by its developers. Critics note that an application is only as decentralized as the oracle it depends on.
This guide explains how things work. It is not financial, legal or tax advice. Last updated .