update readme
This commit is contained in:
parent
d34559deff
commit
07575a122d
38
README.md
38
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/<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)
|
||||
});
|
||||
```
|
||||
|
@ -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 <alexey@peppersec.com> (https://peppersec.com)",
|
||||
"keywords": ["Gas", "Gas price", "Ethereum", "Oracle"],
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@types/chai": "^4.2.11",
|
||||
|
Loading…
Reference in New Issue
Block a user