Gas Price Oracle library for Ethereum dApps
Go to file
dependabot[bot] b029bcc89b
Bump lodash from 4.17.15 to 4.17.19
Bumps [lodash](https://github.com/lodash/lodash) from 4.17.15 to 4.17.19.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/compare/4.17.15...4.17.19)

Signed-off-by: dependabot[bot] <support@github.com>
2020-07-20 21:50:35 +00:00
.github/workflows switch to axios 2020-06-04 18:45:33 +03:00
.vscode init 2020-05-27 18:52:57 +03:00
src switch to axios 2020-06-04 18:45:33 +03:00
tests fix test 2020-06-04 18:49:16 +03:00
.editiorconfig init 2020-05-27 18:52:57 +03:00
.gitignore init 2020-05-27 18:52:57 +03:00
LICENSE Create LICENSE 2020-06-03 14:11:01 -07:00
package-lock.json Bump lodash from 4.17.15 to 4.17.19 2020-07-20 21:50:35 +00:00
package.json switch to axios 2020-06-04 18:45:33 +03:00
README.md update build shield 2020-06-04 10:16:04 +03:00
tsconfig.json init 2020-05-27 18:52:57 +03:00
tslint.json onchain oracle support 2020-06-01 17:29:58 +03:00

Gas Price Oracle library for Ethereum dApps GitHub Workflow Status npm

A library that has a collection of onchain and offchain gas price oracle URLs

Current offchain list:

Current onchain list:

Installation

npm i gas-price-oracle

Import

const { GasPriceOracle } = require('gas-price-oracle');

Usage

Basic


const options = {
    defaultRpc: 'https://api.mycryptoapi.com/eth'
}
const oracle = new GasPriceOracle(options);
// optional fallbackGasPrices
const fallbackGasPrices = {
    instant: 70, fast: 31, standard: 20, low: 7
}
oracle.gasPrices(fallbackGasPrices).then((gasPrices) => {
    console.log(gasPrices) // { instant: 50, fast: 21, standard: 10, low: 3 }
});

Offchain oracles only

const oracle = new GasPriceOracle();

oracle.fetchGasPricesOffChain().then((gasPrices) => {
    console.log(gasPrices) // { instant: 50, fast: 21, standard: 10, low: 3 }
});

Custom RPC URL for onchain oracles

const defaultRpc = 'https://mainnet.infura.io/v3/<API_KEY>'
const oracle = new GasPriceOracle({ defaultRpc });

oracle.fetchGasPricesOnChain().then((gasPrices) => {
    console.log(gasPrices) // 21
});