-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathetherscan_tracker.py
More file actions
45 lines (37 loc) · 1.36 KB
/
etherscan_tracker.py
File metadata and controls
45 lines (37 loc) · 1.36 KB
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
36
37
38
39
40
41
42
43
44
45
import requests
from datetime import datetime
ETHERSCAN_API = "Your_Api_Key_Here"
def get_transactions(address, limit=5):
print(f"\n=== TRANSACTION TRACKER ===")
print(f"Update : {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}")
print(f"Wallet : {address[:10]}...{address[-6:]}\n")
url = "https://api.etherscan.io/api"
params = {
"module": "account",
"action": "txlist",
"address": address,
"startblock": 0,
"endblock": 99999999,
"page": 1,
"offset": limit,
"sort": "desc",
"apikey": ETHERSCAN_API
}
response = requests.get(url, params=params)
data = response.json()
if data['status'] == '1':
txs = data['result']
print(f"Ditemukan {len(txs)} transaksi terbaru:\n")
for tx in txs:
nilai_eth = int(tx['value']) / 10**18
arah = "SEND →" if tx['from'].lower() == address.lower() else "← RECEIVE"
timestamp = datetime.fromtimestamp(int(tx['timeStamp']))
print(f"TX Hash : {tx['hash'][:20]}...")
print(f"Arah : {arah}")
print(f"Nilai : {nilai_eth:.6f} ETH")
print(f"Waktu : {timestamp}")
print("-" * 45)
else:
print("Tidak ada data atau API error")
# Wallet Vitalik
get_transactions("0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045", limit=5)