Oracles

How blockchains learn about the outside world — prices, weather, randomness, and more.

In one minute

Note: Educational only — not financial advice. Always use official docs to verify oracle addresses and feeds.

What an oracle actually does (plain English)

1) Collect

Fetch data from one or many sources (exchanges, APIs, weather stations).

2) Process

Clean & combine values (e.g., take a median across multiple exchanges to reduce outliers).

3) Prove

Attach signatures or cryptographic proofs so contracts can verify who reported the data and when.

4) Publish on-chain

Post the result to a smart contract that other contracts can read.

Main oracle categories

Price feeds

Token prices for DeFi (swaps, loans, liquidations). Often aggregated from many exchanges; pushed on a schedule or when prices move enough.

Randomness (VRF)

Verifiable random numbers for fair raffles, games, NFT traits. Proof lets anyone verify randomness wasn’t biased.

Automation / Keepers

Bots that call functions on a timetable or when conditions are met (e.g., rebalance a vault, trigger a payout).

Event data

Scores, weather, delivery confirmations, IoT signals — anything the chain can’t see directly.

Custom APIs

Bring in app-specific data (e.g., loyalty points, off-chain KYC attestations) with signatures.

Trust models (how secure is the feed?)

No oracle removes all trust. Good systems make cheating costly and easy to detect.

Update patterns

Common pitfalls & attacks

Practical examples

DeFi loan with price feed

  1. User borrows against collateral.
  2. Protocol reads the oracle price to compute health.
  3. If price drops and health falls below a threshold, liquidation triggers — also using the oracle.

If the feed is wrong or slow, healthy users could be liquidated. This is why robust oracles matter.

Fair raffle with VRF

  1. Contract requests randomness; oracle posts a random value with proof.
  2. Contract verifies the proof and picks a winner.
  3. Anyone can check the proof on-chain to see it wasn’t tampered with.

User checklist

Builder checklist

See also: DeFi, Smart contracts, and On-chain vs off-chain.

Quick glossary

More crypto topics