1.0.2 • Published 7 years ago

eth-gas-price-suggestor v1.0.2

Weekly downloads
3
License
ISC
Repository
github
Last release
7 years ago

Eth Gas Price Suggestor

A module for getting the current average gas price of ethereum transactions.

Installation

npm install eth-gas-price-suggestor -S

Example Usage

const Eth = require('ethjs');
const provider = new Eth.HttpProvider('https://mainnet.infura.io');
const BlockTracker = require('eth-block-tracker')
const Suggestor = require('eth-gas-price-suggestor')

const blockTracker = new BlockTracker({ provider })
blockTracker.start()

const suggestor = new Suggestor({
 blockTracker,
 historyLength: 10, // number of blocks to average, default 20.
 defaultPrice: 20000000000, // In case of network error. Default 20 gwei.
})

setInterval(async function() {
  try {
    const suggested = await suggestor.currentAverage()
    console.log('CURRENT SUGGESTION in GWEI: ' + Eth.fromWei(suggested, 'gwei'))
  } catch (e) {
    console.log('failed: ', e)
  }
}, 10000)
1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago