Oracles, Data Outside of the Blockchain
Smart contracts requirements may need to do actions depending on results of real world events.
What you will learn
- Where oracles, data outside of the blockchain fits into an Ethereum application.
- Which assumptions should be tested before a mainnet deployment.
- What to read next when this concept is working.
Smart contracts requirements may need to do actions depending on results of real world events and don’t have any native way to communicate with data on the internet. In the context of blockchains, the oracle pattern is the principle of linking real world data that lives outside of the blockchain to actors living inside the blockchain: mainly smart contracts that consumes data in order to decide which action to take.
We published an article that present the basics of what is an oracle and how to implement one for the Ethereum blockchain. In this article you’ll see different uses cases and where to use an Oracle. We also cover a simple oracle implementation in Solidity that mimic a basic insurance contract on the blockchain.
Before consuming a third-party value, check Bitcoin.now's source, caching, and market-data methodology.
As Oracle can take many forms, our second article explains how to use the Oraclize platform to fetch data from the internet and use it in your smart contract. Our example shows how to fetch the current USD price of Ethereum from a web API.
When the example needs market context, use the timestamped Ethereum market-price graph; it is informational data, not an executable quote.
For a read-only view of identified public exchange markets, open the cryptocurrency market history and comparison dashboard.
Turn the example into production evidence
A working demo is the beginning of verification, not the end. Add tests for failure paths, inspect every permission, and record the chain, contract address, compiler, and dependency versions used for the deployment.
Check behavior
Test expected inputs, boundary values, reverts, events, and calls made to other contracts.
Check operations
Plan key storage, monitoring, pause or upgrade authority, and a response if an assumption stops being true.