update readme

This commit is contained in:
Alexey 2020-10-19 15:15:25 +03:00
parent 305072f198
commit bb8dc28075

@ -30,6 +30,7 @@ const { GasPriceOracle } = require('gas-price-oracle');
```js
const options = {
defaultRpc: 'https://api.mycryptoapi.com/eth',
timeout: 10000,
};
const oracle = new GasPriceOracle(options);
// optional fallbackGasPrices
@ -44,6 +45,9 @@ oracle.gasPrices(fallbackGasPrices).then(gasPrices => {
});
```
The `gasPrices` method also accepts `median` argument (`true`) by default. For more details see [below](<#Offchain-oracles-only-(get-median-price)>).
Under the hood it's a combination of `fetchMedianGasPriceOffChain`(`fetchGasPricesOffChain`) and `fetchGasPricesOnChain` methods.
### Offchain oracles only
```js
@ -54,6 +58,18 @@ oracle.fetchGasPricesOffChain().then(gasPrices => {
});
```
### Offchain oracles only (get median price)
```js
const oracle = new GasPriceOracle();
oracle.fetchMedianGasPriceOffChain().then(gasPrices => {
console.log(gasPrices); // { instant: 50, fast: 21, standard: 10, low: 3 }
});
```
it returns the median gas price of all the oracles configured.
### Custom RPC URL for onchain oracles
```js