γνῶθι σεαυτόν
"Know thyself" - the inscription over the temple at Delphi.
Smart contracts are only aware of the state of the network on which they live. We need some way of informing them about stuff going on in the wider world in order for some use cases to be possible. For instance, most of the simple machines we've described in this section require information about the price of tokens in terms of US dollars. Enter oracles.
Oracles are software which are used to provide information about events occuring off chain to contracts that exist on chain.
| Kind of Oracle | Example Users |
|----------|---------------|
| Generalized oracles | Augur |
| API oracles | Chainlink |
| Price oracles | Maker, Chainlink, UMA, Uniswap v2+v3 |
| Validity oracles | ZK proofs, optimistic proofs, TrueBit |
| Cross-chain oracles | Bridges, SPV proofs, fast withdrawals |
There is a lot of information (and assumptions) bundled up in the simple table above, because getting data onto any blockchain in a way which maintains the security guarantess of the chain itself provides is a very difficult - if not conceptually impossible - problem.
Generalized oracles are intended to provide information about any given event in the world: which is what is required if you wish to run a prediction market about anything that could happen. Such oracles entail data provenance, validity, and game theoretical issues which must be overcome in order for the protocol which relies on them to work as intended.
API (Application Programmer Interface) oracles provide information according to a predetermined set of functions (i.e. an interface) which you can call for specific purposes.
Price oracles provide information about prices, most often about the dollar. There is a wealth of information and history to grok here. [Maker's oracles](https://github.com/chronicleprotocol/oracles) were designed from the ground up to try and strike the best trade-off they could between some of the issues outlined above. Chainlink, on the other hand, just launchd a service, asked people to trust the information they provided, backed it up with the $LINK Marines, and gradually improved what they can offer over time. It was much more crude, but seems to have been effective.
Uniswap has also been through various different kinds of oracles, as it has become clearer what the most effective way of getting price information is in their particular case. The latest oracles use a method known as Time-Weighted Average Price (TWAP), which you can learn more about [here](https://uniswap.org/blog/uniswap-v3-oracles).
Validity oracles will be increasingly found in various Layer 2 solutions, especailly in those which rely on rollups (whether zk-rollups or the optimistic kind).
Cross-chain oracles are used to provide the information necessary to move from one chain to another, which is most often done using Simple Payment Verification (SPV), which is a method that enables a lightweight client to check if a transaction is on a given blockchain without having to download that entire blockchain.