An oracle is a service that feeds external, real-world data to smart contracts on a blockchain. Since blockchains cannot natively access off-chain data, oracles serve as the bridge between the blockchain and the outside world.
Why Oracles Are Needed
Smart contracts can only access data that exists on their blockchain. But many DeFi applications need external data — asset prices, weather conditions, sports results, random numbers. Oracles provide this data in a trustworthy way.
Types of Oracles
Price Feeds: Provide real-time asset prices to DeFi protocols (Chainlink, Pyth).
Randomness: Generate verifiable random numbers for gaming and NFTs (Chainlink VRF).
Cross-Chain: Relay data between different blockchain networks.
Computation: Perform off-chain calculations and deliver results on-chain.
The Oracle Problem
Oracles are a potential centralization point — if a price oracle is compromised, it could feed incorrect data and cause massive losses in DeFi protocols. This is why decentralized oracle networks like Chainlink use multiple independent data sources and validators to ensure accuracy.