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...
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) })
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.
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;
}
Take a look at Example React App too see how to use Polycode Chainlink SDK inside your project!
Polycode Chainlink SDK is fully open source, clonable & re-usable. Polycode retains no rights to the code or implementations.