-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcheck-balance.py
54 lines (41 loc) · 1.51 KB
/
check-balance.py
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
from web3 import Web3
RPC_URL = "https://og-testnet-evm.itrocket.net"
web3 = Web3(Web3.HTTPProvider(RPC_URL))
if not web3.is_connected():
print("❌ Unable to connect to RPC.")
exit(1)
wallet_file = "wallets.txt"
try:
with open(wallet_file, "r") as file:
wallets = [line.strip() for line in file if line.strip()]
except FileNotFoundError:
print("❌ wallets.txt file not found.")
exit(1)
if not wallets:
print("❌ The wallets.txt file does not contain valid wallet addresses.")
exit(1)
print("🔹 Checking A0GI balance...")
total_balance = 0.0
has_balance = []
no_balance = []
for idx, wallet in enumerate(wallets, start=1):
try:
checksum_wallet = web3.to_checksum_address(wallet)
balance_wei = web3.eth.get_balance(checksum_wallet)
balance_eth_decimal = web3.from_wei(balance_wei, "ether")
balance_eth = float(balance_eth_decimal)
total_balance += balance_eth
if balance_eth > 0:
has_balance.append(wallet)
else:
no_balance.append(wallet)
print(f"{idx}. 🟢 Wallet: {wallet} | Balance: {balance_eth:.6f} A0GI")
except Exception as e:
print(f"{idx}. ❌ Error checking {wallet}: {str(e)}")
print(f"\n🔹 Total A0GI balance across wallets: {total_balance:.6f} A0GI")
with open("has_balance.txt", "w") as f:
for wallet in has_balance:
f.write(wallet + "\n")
with open("no_balance.txt", "w") as f:
for wallet in no_balance:
f.write(wallet + "\n")