-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcheck_balance.py
More file actions
39 lines (28 loc) · 980 Bytes
/
check_balance.py
File metadata and controls
39 lines (28 loc) · 980 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
36
37
38
39
"""
檢查錢包餘額的簡單腳本
"""
import asyncio
from config import load_config
from wallet_manager import WalletManager
from solana.rpc.async_api import AsyncClient
async def main():
# 載入配置
config = load_config()
# 初始化 RPC 客戶端
client = AsyncClient(config.rpc_endpoint)
# 初始化錢包管理器
wallet_manager = WalletManager(config.wallet_private_keys)
for i, wallet in enumerate(wallet_manager, 1):
print(f"\n{'='*60}")
print(f"錢包 {i}: {wallet.address}")
print(f"{'='*60}")
# 獲取 SOL 餘額
sol_balance = await wallet.get_sol_balance(client)
print(f"SOL 餘額: {sol_balance:.9f} SOL")
# 獲取 USDC 餘額
usdc_balance = await wallet.get_usdc_balance(client, config.usdc_mint)
print(f"USDC 餘額: {usdc_balance:.6f} USDC")
print(f"{'='*60}\n")
await client.close()
if __name__ == "__main__":
asyncio.run(main())