update readme

This commit is contained in:
Alexey 2020-06-02 16:29:12 +03:00
parent d34559deff
commit 07575a122d
2 changed files with 39 additions and 4 deletions

@ -3,12 +3,46 @@
## Instalation ## Instalation
`npm i gas-price-oracle` `npm i gas-price-oracle`
## Usage ## Import
```js ```js
const { GasPriceOracle } = require('gas-price-oracle'); const { GasPriceOracle } = require('gas-price-oracle');
```
## Usage
### Basic
```js
const oracle = new GasPriceOracle(); 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/<API_KEY>'
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) console.log(gas)
}); });
``` ```

@ -1,17 +1,18 @@
{ {
"name": "gas-price-oracle", "name": "gas-price-oracle",
"version": "0.1.0", "version": "0.1.1",
"description": "Gas Price Oracle library for Ethereum dApps.", "description": "Gas Price Oracle library for Ethereum dApps.",
"main": "lib/index.js", "main": "lib/index.js",
"types": "lib/index.d.ts", "types": "lib/index.d.ts",
"prepare": "npm run build", "prepare": "npm run build",
"prepublishOnly": "npm run lint", "prepublishOnly": "npm test && npm run lint",
"scripts": { "scripts": {
"test": "mocha --timeout 30000 -r ts-node/register tests/*.test.ts", "test": "mocha --timeout 30000 -r ts-node/register tests/*.test.ts",
"build": "tsc", "build": "tsc",
"lint": "tslint -p tsconfig.json" "lint": "tslint -p tsconfig.json"
}, },
"author": "Alexey Pertsev <alexey@peppersec.com> (https://peppersec.com)", "author": "Alexey Pertsev <alexey@peppersec.com> (https://peppersec.com)",
"keywords": ["Gas", "Gas price", "Ethereum", "Oracle"],
"license": "MIT", "license": "MIT",
"devDependencies": { "devDependencies": {
"@types/chai": "^4.2.11", "@types/chai": "^4.2.11",