-
-
Save cryptostiltskin/ec78f4c624d437eee6ceb26018de3d53 to your computer and use it in GitHub Desktop.
Fetch GasPrice from eth gas station
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// in nodeJs | |
const axios = require('axios') | |
async function getCurrentGasPrices() { | |
let response = await axios.get('https://ethgasstation.info/json/ethgasAPI.json') | |
let prices = { | |
low: response.data.safeLow / 10, | |
medium: response.data.average / 10, | |
high: response.data.fast / 10 | |
} | |
console.log(`Current ETH Gas Prices (in GWEI):`) | |
console.log(`Low: ${prices.low} (transaction completes in < 30 minutes)`) | |
console.log(`Standard: ${prices.medium} (transaction completes in < 5 minutes)`) | |
console.log(`Fast: ${prices.high} (transaction completes in < 2 minutes)`) | |
return prices; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment