Socket
Book a DemoInstallSign in
Socket

eth-gas-price-suggestor

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eth-gas-price-suggestor

A module for suggesting a reasonable successful ethereum gas price.

latest
Source
npmnpm
Version
1.0.2
Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

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)

Keywords

ethereum

FAQs

Package last updated on 23 Jun 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts