A blockchain oracle is a service that feeds smart contracts with data from the outside world: coin and currency prices, event outcomes, weather. A blockchain only sees its own records, so without oracles DeFi would not know any prices.
Why oracles are needed
A smart contract runs on thousands of network nodes, and each must reach the same result. That is why a contract cannot simply fetch a price from a website: different nodes would get different answers. Data is brought onto the blockchain by a separate transaction, and that is the oracle's job. A lending protocol uses its price to decide when to liquidate collateral, a synthetic asset to know what it is worth, an insurance contract to determine whether a claim event has occurred. The more money depends on a single number, the more it matters where that number came from.
How oracles are built
The simplest oracle is a single address that publishes a price. It is fast, but everything rests on the honesty and security of whoever holds the key. Decentralized oracles gather data from many independent nodes, each pulling quotes from several venues; the median is written on-chain, and nodes put up collateral that they lose for reporting bad data. There are also on-chain oracles that take the price from a decentralized exchange pool, usually as an average over a time window so that a single trade cannot move it.
Risks
A weak oracle is a frequent cause of DeFi exploits. If a protocol reads its price from a small pool, an attacker can use a flash loan to inflate it for a moment, borrow heavily against overvalued collateral and never repay. Honest failures happen too: delayed updates during a sharp market move, an error at the data source, a network halt. Liquidations then run at the wrong price. When assessing a protocol, check which oracle it relies on and what happens if the data stops arriving.
Oracles and real-world assets
Tokenized bonds, gold and real estate also depend on oracles: someone has to confirm on-chain that the reserve exists and what the asset is worth. Here the oracle becomes a trusted witness rather than pure mathematics, and a token is only as reliable as whoever signs the data. The takeaway for investors is general: in DeFi, code decides only part of the outcome, many numbers inside smart contracts come from outside providers, and their mistakes become yours. This is not investment advice.
Hypothetical example: a lending protocol takes a coin's price from a small pool holding 50,000 USDT. Normally 1,000 of these coins are worth 1,000 USDT and can secure an 800 USDT loan. An attacker takes a flash loan, buys up the coin in the pool and pushes its price up fivefold. The protocol now sees 5,000 USDT of collateral and lends 4,000 USDT. The attacker sells the coins back and repays the flash loan, leaving the protocol with collateral worth a quarter of the debt.
Related terms
Smart ContractDeFiCrypto LendingReal-World Asset TokenizationDecentralisationAutomated Market Maker
On the site
Coin categoriesNew coinsMarket makers
This article was written by AI. Check specific rates, taxes and broker terms with primary sources.