Skip to main content

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 or external_user_id
  • external_user_id (str, optional): External user ID. Use this or wallet_public_key

Return Value

Returns a GetTokenBalanceResponse object containing:
  • chain: Blockchain network
  • chain_token: Token type
  • chain_token_address: On-chain contract address for the token
  • decimals: Token decimal places
  • balance: Token balance as a string

Example Implementation

Async Version

For async applications, use aget_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