Gas Price Oracle library for Ethereum dApps
Go to file
2020-06-03 14:11:01 -07:00
.vscode init 2020-05-27 18:52:57 +03:00
src 0.1.0 version 2020-06-02 15:46:03 +03:00
tests 0.1.0 version 2020-06-02 15:46:03 +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 onchain oracle support 2020-06-01 17:29:58 +03:00
package.json update readme 2020-06-02 16:29:12 +03:00
README.md update readme 2020-06-02 16:29:12 +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

Instalation

npm i gas-price-oracle

Import

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

Usage

Basic

const oracle = new GasPriceOracle();

oracle.gasPrices().then((gas) => {
    console.log(gas)
});

Offchain oracles only

const oracle = new GasPriceOracle();

oracle.fetchGasPricesOffChain().then((gas) => {
    console.log(gas)
});

Custom RPC URL for onchain oracles

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

oracle.fetchGasPricesOnChain().then((gas) => {
    console.log(gas)
});

Don't throw an error if oracles are down

oracle.fetchGasPricesOnChain(false).then((gas) => {
    console.log(gas)
});

oracle.fetchGasPricesOffChain(false).then((gas) => {
    console.log(gas)
});