1import { NETWORK_TYPES } from './network';
2import { DEFAULT_GAS_PRICE_GWEI } from './constants';
4export default async function getSuggestedGasPrice(networkType) {
6 case NETWORK_TYPES.ROPSTEN:
8 case NETWORK_TYPES.OFFLINE:
9 return DEFAULT_GAS_PRICE_GWEI;
10 case NETWORK_TYPES.LOCAL:
13 const response = await fetch(
14 'https://ethgasstation.info/json/ethgasAPI.json',
21 const json = await response.json();
23 // ethgasstation returns values in floating point, one order of magitude
24 // more than gwei. see: https://docs.ethgasstation.info
25 const suggestedGasPrice = Math.ceil(json.fast / 10); // to gwei
27 // we don't want to charge users more than our default 20 gwei
28 return Math.min(suggestedGasPrice, DEFAULT_GAS_PRICE_GWEI);
30 return DEFAULT_GAS_PRICE_GWEI;
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