Data Feeds Oracle
A blockchain oracle is a third-party service that connects smart contracts with the outside world, primarily to feed information from the world and reverse. Data from the world encapsulates multiple sources so that decentralized knowledge is obtained. Information to the world includes making payments and notifying parties. The oracle is the layer that queries, verifies, and authenticates external data sources, usually via trusted APIs, proprietary corporate data feeds and internet of things feeds, and then relays that information.
Many Ethereum applications use oracles. For example, the prediction market Augur would use election data to settle corresponding bets. Projects like Chainlink provide decentralized oracle network services to many blockchains.
Examples of data transmitted by oracles to smart contracts include price information, the successful completion of payment, the temperature measured by a sensor, election outcomes, etc. Data can be supplied by other software (databases, servers, or essentially any online data source), or by hardware (sensors, barcode scanners, etc.). Human oracles are individuals with specialized knowledge who can verify the authenticity of information before relaying it to smart contracts, and who prove their identity cryptographically.
Outbound oracles send information from smart contracts to the external world. For example, a smart contract receiving a payment could send information through an outbound oracle to a mechanism that unlocks a smart lock.
What is ChainLink Data Feed?
Chainlink Data Feeds are the quickest way to connect your smart contracts to real-world data such as asset prices. One use for data feeds is to retrieve the latest pricing data of an asset in a single call and use that data either on-chain in a smart contract or off-chain in another application of your choice.
Data Feeds aggregate many data sources and publish them on-chain using a combination of the Decentralized Data Model and Off-Chain Reporting.
Smart contracts often act in real-time on data such as the prices of assets. This is especially true in DeFi. For example, Synthetix uses Data Feeds to determine prices on their derivatives platform. Lending and borrowing platforms like AAVE use Data Feeds to ensure the total value of the collateral.
Components of a data feed
Data Feeds are an example of a decentralized oracle network and include the following components:
- Consumer: A consumer is an on-chain or off-chain application that uses Data Feeds. Consumer contracts use the [AggregatorV3Interface](<https://github.com/smartcontractkit/chainlink/blob/master/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol>) to call functions on the proxy contract and retrieve information from the aggregator contract. For a complete list of functions available in the AggregatorV3Interface, see the Data Feeds API Reference.
- Proxy contract: Proxy contracts are on-chain proxies that point to the aggregator for a particular data feed. Using proxies enables the underlying aggregator to be upgraded without any service interruption to consuming contracts. Proxy contracts can vary from one data feed to another, but the [AggregatorProxy.sol contract](https://github.com/smartcontractkit/chainlink/blob/develop/contracts/src/v0.7/dev/AggregatorProxy.sol) on Github is a common example.
- Aggregator contract: An aggregator is a contract that receives periodic data updates from the oracle network. Aggregators store aggregated data on-chain so that consumers can retrieve it and act upon it within the same transaction. For a complete list of functions and variables available on most aggregator contracts, see the Data Feeds API Reference.
You can use smart contracts to get asset prices on EVM Chains. This example shows you how to get the price of Ethereum (ETH) on the Ethereum network, but you can modify the examples to work on other EVM Chains as well. The list of data feeds for each network is available on the Data Feed Contracts page.
To consume price data, your smart contract should reference [AggregatorV3Interface](<https://github.com/smartcontractkit/chainlink/blob/master/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol>), which defines the external functions implemented by Data Feeds.