Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
pertsev committed Jun 2, 2020
1 parent d34559d commit 07575a1
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 4 deletions.
38 changes: 36 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
});
```
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit 07575a1

Please sign in to comment.