1.0.9 • Published 6 months ago

polycode-chainlink-feeds v1.0.9

Weekly downloads
-
License
MIT
Repository
-
Last release
6 months ago

Polycode Chainlink SDK

Polycode Chainlink SDK is a fully open source Typescript SDK which enables any frontend developer to fetch the prices of various assets through Chainlink DataFeeds. Users can fetch price pairs, NFT floor price information & more...

Getting started

Install the SDK by typing in your npm project (Angular, React, vanilla npm, ...)

npm install polycode-chainlink-feeds

In your JavaScript or TypeScript file import the SDK with:

import { PolycodeChainlinkSDK } from 'polycode-chainlink-feeds'

Then import all the Price Feeds you want:

import { PriceFeedsETH } from 'polycode-chainlink-feeds'
import { PriceFeedsAVAX } from 'polycode-chainlink-feeds'
import { PriceFeedsBSC } from 'polycode-chainlink-feeds'

Initialize the SDK by calling:

const ethSDK = new PolycodeChainlinkSDK('https://rpc-node-url.xx', new PriceFeedsETH())
const avaxSDK = new PolycodeChainlinkSDK('https://avax-rpc-url.xx', new PriceFeedsAVAX())

And simply fetch a price pair by calling the price feeds functionality on the SDK:

ethSDK.getFromOracle(ethSDK.feeds.AAVE_ETH).then(res => { console.log(res) })

Modern development

Polycode Chainlink SDK extracts all the pair contracts addresses for all networks that are compatible into code generated classes, so all modern editors will support full code autocomplete.

Screenshot 2023-03-31 at 17 48 26

Reading data

The data is returned in the form of an RoundDataModel object:

export interface RoundDataModel {
    roundID: BigNumber;
    answer: BigNumber;
    formattedAnswer?: string;
    startedAt: BigNumber;
    updatedAt: BigNumber;
    answeredInRound: BigNumber;
    assetName?: string;
    dataFeedName?: string;
}

Example app

Take a look at Example React App too see how to use Polycode Chainlink SDK inside your project!

License

Polycode Chainlink SDK is fully open source, clonable & re-usable. Polycode retains no rights to the code or implementations.

1.0.9

6 months ago

1.0.8

6 months ago