Data Feed Consumer

This page guides you through an example of consuming a data feed from your consumer contract.

The example consumer contract is at 0x0A787d834cEbFfedCb43a531Cf788F7229E7Fc51.

As you can see in the consumer contract, we must create a variable to store the address of the data feed contract and use AggregatorV2V3Interface to consume a token price.

If you want to get the answer of the latest round, you can use aggregator.latestRoundData().

Five values will be returned after your contract is allowed to consume the data feed. The price is the second value of the returned values. In this case, the answer is the price of BTC in USD.

Right now, we only offer 8 decimal places for the token prices.

The number of decimal places of each token price can be obtained using aggregator.decimals().

Last updated