Using Data Feeds on EVM Chains
The code for reading Data Feeds is the same across all EVM-compatible blockchains and Data Feed types. You choose different types of feeds for different uses, but the request and response format are the same. To read a feed, specify the following variables:
- RPC endpoint URL: This determines which network that your smart contracts will run on. You can use a node provider service or point to your own client. If you are using a Web3 wallet, it is already configured with the RPC endpoints for several networks and the Remix IDE will automatically detect them for you.
- LINK token contract address: The address for the LINK token contract is different for each network. You can find the full list of addresses for all supported networks on the LINK Token Contracts page.
- Feed contract address: This determines which data feed your smart contract will read. Contract addresses are different for each network. You can find the available contract addresses on the following pages:
The examples in this document indicate these variables, but you can modify the examples to work on different networks and read different feeds.
This guide shows example code that reads data feeds using the following languages:
- Onchain consumer contracts:
- Offchain reads using Web3 packages:
- Javascript with web3.js
- Python with Web3.py
- Golang with go-ethereum
Reading data feeds onchain
These code examples demonstrate how to deploy a consumer contract onchain that reads a data feed and stores the value.
Solidity
To consume price data, your smart contract should reference AggregatorV3Interface, which defines the external functions implemented by Data Feeds.
undefined
The latestRoundData function returns five values representing information about the latest price data. See the Data Feeds API Reference for more details.
Vyper
To consume price data, your smart contract should import AggregatorV3Interface which defines the external functions implemented by Data Feeds. You can find it here.
You can find a PriceConsumer example here. Read the apeworx-starter-kit README to learn how to run the example.
Reading data feeds offchain
These code examples demonstrate how to read data feeds directly off chain using Web3 packages for each language.
Javascript
This example uses web3.js to retrieve feed data from the BTC / USD feed on the Sepolia testnet.
undefinedundefinedLatest Price
Python
This example uses Web3.py to retrieve feed data from the BTC / USD feed on the Sepolia testnet.
undefined
Golang
You can find an example with all the source files here. This example uses go-ethereum to retrieve feed data from the BTC / USD feed on the Sepolia testnet. To learn how to run the example, see the README.
Getting a different price denomination
Chainlink Data Feeds can be used in combination to derive denominated price pairs in other currencies.
If you require a denomination other than what is provided, you can use two data feeds to derive the pair that you need. For example, if you needed a BTC / EUR price, you could take the BTC / USD feed and the EUR / USD feed and derive BTC / EUR using division.

undefined
More aggregator functions
Getting the latest price is not the only data that aggregators can retrieve. You can also retrieve historical price data. To learn more, see the Historical Price Data page.