Created
June 3, 2018 21:00
-
-
Save jordanmack/844e918de74675179fc3933e04604ef0 to your computer and use it in GitHub Desktop.
A simple Python script to determine the Ethereum gas price that should be used by utilizing the EthGasStation.info API. I use this in simple automation scripts and find it to be more reliable for predicting a safe gas price during congested periods.
This file contains hidden or 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
#!/usr/bin/env python3 | |
import json | |
import math | |
import requests | |
DEFAULT = 15 | |
MODIFIER = 2 | |
try: | |
url = "https://ethgasstation.info/json/ethgasAPI.json" | |
r = requests.get(url, timeout=10) | |
j = json.loads(r.content.decode("utf-8")) | |
g = math.ceil(j["safeLow"] / 10) + MODIFIER | |
print(g) | |
except: | |
print(DEFAULT) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment