-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathget_account_balance.py
27 lines (22 loc) · 1.1 KB
/
get_account_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
import asyncio
from pytoncenter import get_client
from pytoncenter.v3.models import *
async def main():
client = get_client(version="v3", network="testnet")
my_address = "0QC8zFHM8LCMp9Xs--w3g9wmf7RwuDgJcQtV-oHZRSCqQXmw"
account = await client.get_account(GetAccountRequest(address=my_address))
jetton_wallets = await client.get_jetton_wallets(GetJettonWalletsRequest(owner_address=my_address, limit=10))
masters = await client.multicall({w.address: client.get_jetton_masters(w.jetton) for w in jetton_wallets})
print("=== Account Info ===")
print(" -", "Symbol", "TON", "Balance:", account.balance / 1e9)
print("=== Jetton Wallets ===")
for wallet in jetton_wallets:
jetton = masters.get(wallet.address, None)
if jetton is None or jetton.jetton_content is None:
continue
content = jetton.jetton_content
symbol = content.symbol if content else "unknown"
decimals = (content.decimals if content else 0) or 9
print(" -", "Symbol", symbol, "Balance", wallet.balance / 10**decimals)
if __name__ == "__main__":
asyncio.run(main())