update readme
This commit is contained in:
parent
305072f198
commit
bb8dc28075
16
README.md
16
README.md
@ -30,6 +30,7 @@ const { GasPriceOracle } = require('gas-price-oracle');
|
|||||||
```js
|
```js
|
||||||
const options = {
|
const options = {
|
||||||
defaultRpc: 'https://api.mycryptoapi.com/eth',
|
defaultRpc: 'https://api.mycryptoapi.com/eth',
|
||||||
|
timeout: 10000,
|
||||||
};
|
};
|
||||||
const oracle = new GasPriceOracle(options);
|
const oracle = new GasPriceOracle(options);
|
||||||
// optional fallbackGasPrices
|
// 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
|
### Offchain oracles only
|
||||||
|
|
||||||
```js
|
```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
|
### Custom RPC URL for onchain oracles
|
||||||
|
|
||||||
```js
|
```js
|
||||||
|
Loading…
Reference in New Issue
Block a user