BKC Oracle
  • About
    • About BKC Oracle
    • Connect with MetaMask
  • Features
    • Data feeds
    • Verifiable Random Function (VRF)
  • How to
    • Using Data Feed
    • Using VRF
  • Examples
    • Data Feed Consumer
    • VRF Consumer
  • Utilities
    • Contract Addresses
      • Bitkub Mainnet
      • Bitkub Testnet
    • Data Feed Proxy Contract Interface
      • AggregatorInterface’s Methods
      • AggregatorV3Interface’s Methods
    • Key Hash
  • Deprecated
    • What’s dashboard?
      • How to manage subscriptions?
      • How to add a new subscription?
      • How to convert KUB to KKUB?
    • Interface Requirement of a Consumer Contract
    • How to subscribe to data oracle?
      • Monthly subscription
      • Annual subscription
  • Links
    • Get KDEV
Powered by GitBook
On this page
  1. Examples

Data Feed Consumer

PreviousUsing VRFNextVRF Consumer

Last updated 1 year ago

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

The example consumer contract is at .

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().

0x0A787d834cEbFfedCb43a531Cf788F7229E7Fc51