1import { useState, useEffect } from 'react';
2import { NETWORK_TYPES } from './network';
3import { DEFAULT_GAS_PRICE_GWEI } from './constants';
5async function getSuggestedGasPrice(networkType) {
7 case NETWORK_TYPES.ROPSTEN:
9 case NETWORK_TYPES.OFFLINE:
10 return DEFAULT_GAS_PRICE_GWEI;
13 const response = await fetch(
14 'https://ethgasstation.info/json/ethgasAPI.json',
20 const json = await response.json();
21 return Math.min(json.fast / 10, 20); // to gwei
23 return DEFAULT_GAS_PRICE_GWEI;
28function useSuggestedGasPrice(networkType) {
29 const [gasPrice, _setGasPrice] = useState(DEFAULT_GAS_PRICE_GWEI);
33 _setGasPrice(await getSuggestedGasPrice(networkType));
40export { getSuggestedGasPrice, useSuggestedGasPrice };
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list