@samyan/gas-tracker
v1.0.6
Published
Library for get gas price from different sources
Downloads
4
Maintainers
Readme
GasTracker
Library for get gas price from different sources. The currently supported blockchains:
- Bitcoin
- Ethereum (requires API TOKEN from etherscan.io)
- Polygon (requires API TOKEN from polygonscan.com)
- BNB Chain / Binance Smart Chain (requires API TOKEN from bscscan.com)
Install
npm i @samyan/gas-tracker
Usage
Example 1
const gasTracker = new GasTracker();
gasTracker
.getBlockchain(BlockchainType.BITCOIN)
.getPrices()
.then((result: BitcoinResult) => {
console.log(result.getRegularPrice());
})
.catch((error: any) => {
console.log(error.message);
});
Example 2
try {
const gasTracker = new GasTracker('YOUR_API_TOKEN');
const result = (await gasTracker
.getBlockchain(BlockchainType.ETHEREUM)
.getPrices()
) as EthereumResult;
console.log(result.getFastPrice());
} catch (error) {
console.log(error.message);
}