-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgas_tracker.py
More file actions
35 lines (30 loc) · 1010 Bytes
/
gas_tracker.py
File metadata and controls
35 lines (30 loc) · 1010 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import requests
from datetime import datetime
import time
ETHERSCAN_API = "Your_Api_Key_here"
def get_gas_price():
url = "https://api.etherscan.io/v2/api"
params = {
"chainid": 1,
"module": "gastracker",
"action": "gasoracle",
"apikey": ETHERSCAN_API
}
response = requests.get(url, params=params)
data = response.json()
if data['status'] == '1':
result = data['result']
print(f"\n=== GAS FEE TRACKER ===")
print(f"Update : {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}\n")
print(f"🟢 Slow : {result['SafeGasPrice']} Gwei")
print(f"🟡 Normal : {result['ProposeGasPrice']} Gwei")
print(f"🔴 Fast : {result['FastGasPrice']} Gwei")
print(f"\nBase Fee : {result['suggestBaseFee']} Gwei")
print("-" * 30)
else:
print(f"Error: {data['message']}")
# Auto refresh setiap 30 detik
while True:
get_gas_price()
print("Refresh dalam 30 detik...")
time.sleep(30)