-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwhale_alert.py
More file actions
73 lines (61 loc) · 2.12 KB
/
whale_alert.py
File metadata and controls
73 lines (61 loc) · 2.12 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import requests
import time
from datetime import datetime
# Config — isi dengan data kamu
ETHERSCAN_API = "Your_Api_Key_here"
TELEGRAM_TOKEN = "Your_Api_Key_Here"
CHAT_ID = "Your_Chat_ID"
MIN_ETH = 100 # alert kalau transaksi > 100 ETH
def send_telegram(pesan):
url = f"https://api.telegram.org/bot{TELEGRAM_TOKEN}/sendMessage"
params = {
"chat_id": CHAT_ID,
"text": pesan,
"parse_mode": "Markdown"
}
requests.post(url, params=params)
def get_latest_txs():
url = "https://api.etherscan.io/v2/api"
params = {
"chainid": 1,
"module": "account",
"action": "txlist",
"address": "0x00000000219ab540356cBB839Cbe05303d7705Fa", # ETH2 deposit contract
"startblock": 0,
"endblock": 99999999,
"page": 1,
"offset": 20,
"sort": "desc",
"apikey": ETHERSCAN_API
}
response = requests.get(url, params=params)
return response.json().get('result', [])
def check_whales():
print(f"\n🐋 WHALE ALERT BOT RUNNING")
print(f"Monitoring transaksi > {MIN_ETH} ETH")
print(f"Update: {datetime.now().strftime('%H:%M:%S')}\n")
txs = get_latest_txs()
whale_count = 0
for tx in txs:
nilai_eth = int(tx['value']) / 10**18
if nilai_eth >= MIN_ETH:
whale_count += 1
arah = "📤 SEND" if tx['from'] else "📥 RECEIVE"
timestamp = datetime.fromtimestamp(int(tx['timeStamp']))
pesan = (
f"🐋 *WHALE ALERT!*\n\n"
f"💰 Amount: `{nilai_eth:.2f} ETH`\n"
f"📤 From: `{tx['from'][:10]}...`\n"
f"📥 To: `{tx['to'][:10]}...`\n"
f"🕐 Time: `{timestamp}`\n"
f"🔗 TX: `{tx['hash'][:20]}...`"
)
print(f"🐋 WHALE FOUND: {nilai_eth:.2f} ETH")
send_telegram(pesan)
if whale_count == 0:
print("Tidak ada whale transaction ditemukan")
print(f"\nRefresh dalam 60 detik...")
# Run setiap 60 detik
while True:
check_whales()
time.sleep(60)