Skip to content

Instantly share code, notes, and snippets.

@hexonaut
Created April 7, 2021 16:55
Show Gist options
  • Save hexonaut/882ced4020036344600ad413ad516f9b to your computer and use it in GitHub Desktop.
Save hexonaut/882ced4020036344600ad413ad516f9b to your computer and use it in GitHub Desktop.
gp() {
if [ $# -eq 0 ]
then
echo Gas price is $(echo $ETH_GAS_PRICE / 1000000000 | bc) Gwei
return
elif [ "$1" = "fast" ]
then
GAS_GWEI=$(curl -s "https://api.etherscan.io/api?module=gastracker&action=gasoracle&apikey=APIKEY" | jq -r .result.FastGasPrice)
elif [ "$1" = "trade" ]
then
FAST_GAS=$(curl -s "https://api.etherscan.io/api?module=gastracker&action=gasoracle&apikey=APIKEY" | jq -r .result.FastGasPrice)
GAS_GWEI=$(echo "$FAST_GAS + 10" | bc)
else
GAS_GWEI=$1
fi
export ETH_GAS_PRICE=${GAS_GWEI}000000000
echo Setting gas to $GAS_GWEI GWei
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment