getPrice

Function using for get token price

This function using web3.js Library and API

Get price from Binance

Input parameters

// JavaScript

const tx = {
   source: 'binance', // required
   tokenName1: 'ETH', // required
   tokenName2: 'BUSD', // option
   returnfullquery: false // option
}
tokenName2 default BUSD
// JavaScript

const tx = {
   source: 'chainlink', // required
   to: '0x9D50C095D29655C1f0589c61A8F3d10280D6C91e', // address price feed // required
   rpc: 'https://data-seed-prebsc-1-s3.binance.org:8545/', // required
   returnfullquery: true, // option
}
Price feed addresses can find on chainlink website.

Using

// JavaScript

const price = await getPrice(tx)

Return

If returnfullquery == true function return object, else numder

Last updated