Usage
Parameters
chain_token(ChainToken): Token to query (e.g.,ChainToken.USDC,ChainToken.ETH)chain(Chain): Blockchain network (e.g.,Chain.STARKNET)wallet_public_key(str, optional): Wallet address. Use this orexternal_user_idexternal_user_id(str, optional): External user ID. Use this orwallet_public_key
Return Value
Returns aGetTokenBalanceResponse object containing:
chain: Blockchain networkchain_token: Token typechain_token_address: On-chain contract address for the tokendecimals: Token decimal placesbalance: Token balance as a string
Example Implementation
Async Version
For async applications, useaget_token_balance:
Query by External User ID
You can query balance using the external user ID instead of the wallet address:Checking Multiple Token Balances
Balance Check Before Transfer
A common pattern is checking the balance before initiating a transfer:Error Handling
Related Methods
- get_wallet - Get wallet information
- transfer - Send tokens from the wallet
- create_wallet - Create a new wallet
