📈Price Feeds

Smart contracts often act in real-time on data such as prices of assets. This is especially true in DeFi. For example, Synthetix uses Data Feeds to determine prices on their derivatives platform. Lending and borrowing platforms like AAVE use Data Feeds to ensure the total value of the collateral. Data Feeds aggregate many data sources and publish them on-chain using a combination of the Decentralized Data Model and Off-Chain Reporting.

Read more about Chainlink Data Feeds

Step 1

The first prerequisite you will need is the creation of an account and a Project (API Key) on Cryptum Dashboard.

PS: Our dashboard is almost ready! To generate an API Key, contact hello@blockforce.in

Step 2

With a valid Cryptum API Key, you can then instantiate the SDK as follows:

const CryptumSdk = require('cryptum-sdk')

const sdk = new CryptumSdk({
  environment: 'testnet',  // 'testnet', 'mainnet'
  apiKey: "YOUR-API-KEY-HERE",

Step 3

Now we must select the function in our SDK:

Get Price By Address

In our SDK, there are enums of contracts for token pairs on Ethereum mainnet and testnet. If you cannot find the pair you desire, check the available Price Feeds Addresses.

const address = sdk.chainlink.feeds.MAINNET.ETHEREUM.ADA_USD

const price = await sdk.chainlink.getPricesByAddress({
    protocol: "ETHEREUM",
    address: address

Get Price By Asset

List currency price quotations

const price = await sdk.chainlink.getPrices({
    protocol: "ETHEREUM",
    asset: 'ETH'
// Prices {
//   "USD": 0.3495,
//   "BTC": 7.35687406736623e-06,
// }

Last updated