From 07575a122d18810a6206ae1cbfec8cf4e961a730 Mon Sep 17 00:00:00 2001 From: Alexey Date: Tue, 2 Jun 2020 16:29:12 +0300 Subject: [PATCH] update readme --- README.md | 38 ++++++++++++++++++++++++++++++++++++-- package.json | 5 +++-- 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 6740b6a..e60f613 100644 --- a/README.md +++ b/README.md @@ -3,12 +3,46 @@ ## Instalation `npm i gas-price-oracle` -## Usage +## Import ```js const { GasPriceOracle } = require('gas-price-oracle'); +``` +## Usage +### Basic +```js const oracle = new GasPriceOracle(); -oracle.fetchGasPrices().then((gas) => { +oracle.gasPrices().then((gas) => { + console.log(gas) +}); +``` + +### Offchain oracles only +```js +const oracle = new GasPriceOracle(); + +oracle.fetchGasPricesOffChain().then((gas) => { + console.log(gas) +}); +``` + +### Custom RPC URL for onchain oracles +```js +const customRpc = 'https://mainnet.infura.io/v3/' +const oracle = new GasPriceOracle(customRpc); + +oracle.fetchGasPricesOnChain().then((gas) => { + console.log(gas) +}); +``` + +### Don't throw an error if oracles are down +```js +oracle.fetchGasPricesOnChain(false).then((gas) => { + console.log(gas) +}); + +oracle.fetchGasPricesOffChain(false).then((gas) => { console.log(gas) }); ``` diff --git a/package.json b/package.json index 38328c3..9b81be4 100644 --- a/package.json +++ b/package.json @@ -1,17 +1,18 @@ { "name": "gas-price-oracle", - "version": "0.1.0", + "version": "0.1.1", "description": "Gas Price Oracle library for Ethereum dApps.", "main": "lib/index.js", "types": "lib/index.d.ts", "prepare": "npm run build", - "prepublishOnly": "npm run lint", + "prepublishOnly": "npm test && npm run lint", "scripts": { "test": "mocha --timeout 30000 -r ts-node/register tests/*.test.ts", "build": "tsc", "lint": "tslint -p tsconfig.json" }, "author": "Alexey Pertsev (https://peppersec.com)", + "keywords": ["Gas", "Gas price", "Ethereum", "Oracle"], "license": "MIT", "devDependencies": { "@types/chai": "^4.2.11",