Skip to content

OpenST/ost-dynamic-gas-price

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OST Dynamic Gas Price

This service fetches an estimated gas price for which transaction could get mined in less than 5 minutes.

Two services are used for this purpose.

  1. Eth Gas Station
    This service is used primarily. An API call is made to the below URL and gasPrices are parsed for usage.
    (Source: 'https://ethgasstation.info/json/predictTable.json').
  2. Ether Chain
    In case EthGasStation returns gasPrice as 0 or a price greater than the threshold, price is fetched from EtherChain.
    (Source: 'https://www.etherchain.org/tools/gasPriceOracle').

Usage:

dynamicGasPriceProvider = require('@ostdotcom/ost-dynamic-gas-price');
chainId = 1; //main Ethereum Network
dynamicGasPriceProvider.dynamicGasPrice.get(chainId).then(function(val){
console.log("Gas Price In GWei", val);
});