An example project for reading API3 data feeds
- Install dependencies
yarn- Create a
.envfile similar toexample.env
echo 'MNEMONIC="bike north stone..."' > .env- Browse market.api3.org and find a data feed you like
- Fund the data feed (unless it is already funded)
- Deploy the proxy to the data feed (unless it is already deployed)
- Copy the address of the proxy
- Deploy DataFeedReaderExample.
See the command below, but use your own
NETWORKandPROXYvalues. See the supported networks section for validNETWORKvalues.
NETWORK=polygon-testnet PROXY=0x26690F9f17FdC26D419371315bc17950a0FC90eD yarn deploy- Have DataFeedReaderExample read from the proxy.
See the command below, but use your own
NETWORKvalue.
NETWORK=polygon-testnet yarn read-data-feedSee https://github.com/api3dao/chains for details
- arbitrum-goerli-testnet
- arbitrum
- avalanche-testnet
- avalanche
- bsc-testnet
- bsc
- ethereum-goerli-testnet
- ethereum-sepolia-testnet
- ethereum
- fantom-testnet
- fantom
- gnosis-testnet
- gnosis
- moonbeam-testnet
- moonbeam
- moonriver
- optimism-goerli-testnet
- optimism
- polygon-testnet
- polygon-zkevm-goerli-testnet
- polygon-zkevm
- polygon
@api3/contracts provides a MockProxy contract for local development testing.
See the tests for its usage, and run the tests with
yarn testInstructions have you use API3 Market to deploy a DapiProxy.
To do it programmatically, see the command below, but use your own NETWORK and DAPI_NAME values.
NETWORK=polygon-testnet DAPI_NAME=ETH/USD yarn deploy-dapi-proxyYou can see the valid dAPI names on API3 Market.
WARNING: DapiProxy reads a data feed whose composition is managed by API3, and using it is essentially outsourcing data feed curation to API3. DataFeedProxy reads a data feed whose composition is immutable, which is fully trust-minimized when used with first-party oracles. However, this also means when there is something wrong with the composition of the DataFeedProxy you are using, you will need to deploy a new one and switch to that, i.e., you will need to do your own data feed curation. Do not prefer DataFeedProxy over DapiProxy unless you understand the distinction and are capable of managing your own data feeds.
See the command below, but use your own NETWORK and DATA_FEED_ID values.
NETWORK=polygon-testnet DATA_FEED_ID=0x4385954e058fbe6b6a744f32a4f89d67aad099f8fb8b23e7ea8dd366ae88151d yarn deploy-data-feed-proxySee https://github.com/nodaryio/examples for a more detailed example.
You can update the proxy that your DataFeedReaderExample reads from.
- Follow the instructions
- Deploy a new proxy
- See the command below, but use your own
NETWORKandPROXYvalues
NETWORK=polygon-testnet PROXY=0xe5Cf15fED24942E656dBF75165aF1851C89F21B5 yarn update-proxy