An example project that reads an API3 data feed
- Install dependencies
yarn- Create a
.envfile similar toexample.env
echo 'MNEMONIC="bike north stone..."' > .env- Go to market.api3.org and find a data feed you like. If the data feed is not already activated, purchase a subscription. Refer to the docs for help.
- On the data feed page, click the
Integratebutton and copy the address of the communal Api3ReaderProxyV1. Alternatively, you can get the proxy address with the following command.
NETWORK=ethereum-sepolia-testnet DAPI_NAME=ETH/USD yarn print:communal-api3readerproxyv1-address- Deploy
DataFeedReaderExampleby using the command below with yourNETWORKandPROXYvalues. See the supported networks section for validNETWORKvalues.
NETWORK=ethereum-sepolia-testnet PROXY=0x5b0cf2b36a65a6BB085D501B971e4c102B9Cd473 yarn deploy- Have
DataFeedReaderExampleread from the proxy by using the command below with yourNETWORKvalue
NETWORK=ethereum-sepolia-testnet yarn read-data-feedChains listed on market.api3.org are all supported. You can run the following command to list them.
yarn print:supported-chains@api3/contracts provides a MockApi3ReaderProxy contract for local development.
See the tests for its usage, and run the tests with the following command.
yarn testApi3ReaderProxyV1 also implements AggregatorV2V3Interface, which enables you to use it as a drop-in replacement for a Chainlink data feed.
See the tests for an example of how that is to be used, and refer to the respective docs page for more information.
See the advanced instructions.