Skip to content

Instantly share code, notes, and snippets.

@protortyp
Last active January 7, 2021 07:12
Show Gist options
  • Save protortyp/62754ad1ac7e93907a8ed3c4e78ccb44 to your computer and use it in GitHub Desktop.
Save protortyp/62754ad1ac7e93907a8ed3c4e78ccb44 to your computer and use it in GitHub Desktop.
Super simple ethereum gas price script
#!/bin/bash
URL1="https://ethgasstation.info/api/ethgasAPI.json"
URL2="https://www.gasnow.org/api/v1/gas/price"
# gas stuff
RES1=$(curl -s $URL1)
RES2=$(curl -k -s $URL2)
fastest1=$(echo $RES1 | jq ".fastest")
fastestwait1=$(echo $RES1 | jq ".fastestWait")
fast1=$(echo $RES1 | jq ".fast")
fast2=$(echo $RES2 | jq ".data.top50")
fastwait1=$(echo $RES1 | jq ".fastWait")
avg1=$(echo $RES1 | jq ".average")
avg2=$(echo $RES2 | jq ".data.top200")
avgwait1=$(echo $RES1 | jq ".avgWait")
slow1=$(echo $RES1 | jq ".safeLow")
slow2=$(echo $RES2 | jq ".data.top400")
slowwait1=$(echo $RES1 | jq ".safeLowWait")
blocknum=$(echo $RES1 | jq ".blockNum")
echo "Tx Speed Gas Needed Expected Wait Mempool Data"
echo "--------+----------+-------------+------------"
printf 'Fastest: %4s GWei %6s Blocks\n' $(expr $fastest1 / 10) $fastestwait1
printf 'Fast: %4s GWei %6s Blocks %6s GWei\n' $(expr $fast1 / 10) $fastwait1 $(expr $fast2 / 1000000000)
printf 'Average: %4s GWei %6s Blocks %6s GWei\n' $(expr $avg1 / 10) $avgwait1 $(expr $avg2 / 1000000000)
printf 'Slow: %4s GWei %6s Blocks %6s GWei\n' $(expr $slow1 / 10) $slowwait1 $(expr $slow2 / 1000000000)
echo "----------------------------------------------"
printf 'Current Block: %18s\n' $blocknum
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment