You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
873 B
25 lines
873 B
from pysui import SuiConfig, SyncClient
|
|
from pysui.sui.sui_types.scalars import SuiString
|
|
from pysui.sui.sui_clients.common import SuiRpcResult
|
|
|
|
private_key = "suiprivkey1qrtls98pk6frpzzuajf5a53klnhd0hdtx6fwwrk65ghregk5np4j2yehv7y" # 替换为你的私钥
|
|
sui_config = SuiConfig.user_config(
|
|
rpc_url="https://fullnode.testnet.sui.io:443", # SUI 测试网节点地址
|
|
prv_keys=[private_key] # 添加私钥
|
|
)
|
|
|
|
client = SyncClient(sui_config)
|
|
|
|
# 获取当前活跃地址
|
|
address = sui_config.active_address
|
|
print(f"Active Address: {address}")
|
|
|
|
# 使用 sui_getBalance RPC 方法查询余额
|
|
response: SuiRpcResult = client._client.balance(SuiString(address))
|
|
|
|
if response.is_ok():
|
|
balance_data = response.result_data
|
|
total_balance = balance_data.get("totalBalance", 0)
|
|
print(f"Balance: {total_balance} MIST")
|
|
else:
|
|
print(f"Error: {response.error}")
|
|
|