Balance Tools
These tools allow you to query the balance of addresses on the Somnia network, including native SST/SOMI tokens and ERC20 tokens.
get_balance
Section titled “get_balance”Gets the SST (native token) balance of an address.
Parameters:
network
(optional): Network name or chain ID (defaults to Somnia testnet)address
: The address to check balance for
Example:
{ "network": "Somnia Testnet", "address": "0x1234567890123456789012345678901234567890"}
Response: Returns an object with address, network, balance in wei, and formatted SST balance.
Example Prompt:
What is the SST balance of address 0x1234567890123456789012345678901234567890?
get_erc20_balance
Section titled “get_erc20_balance”Gets the balance of an ERC20 token for a specific address.
Parameters:
network
(optional): Network name or chain ID (defaults to Somnia testnet)tokenAddress
: The ERC20 token contract addressaddress
: The address to check balance for
Example:
{ "network": "Somnia Testnet", "tokenAddress": "0xabcdef1234567890abcdef1234567890abcdef12", "address": "0x1234567890123456789012345678901234567890"}
Response: Returns raw balance, formatted balance, and token information (symbol, decimals).
Example Prompt:
Get the balance of ERC20 token 0xabcdef1234567890abcdef1234567890abcdef12 for address 0x1234567890123456789012345678901234567890.
get_token_balance_erc20
Section titled “get_token_balance_erc20”Alternative tool for getting ERC20 token balance (same as get_erc20_balance).
Parameters:
network
(optional): Network name or chain ID (defaults to Somnia testnet)tokenAddress
: The ERC20 token contract addressaddress
: The address to check balance for
Example:
{ "network": "Somnia Testnet", "tokenAddress": "0xabcdef1234567890abcdef1234567890abcdef12", "address": "0x1234567890123456789012345678901234567890"}
Response: Returns balance information with raw and formatted values.
Example Prompt:
Check the ERC20 token balance for address 0x1234567890123456789012345678901234567890 on token 0xabcdef1234567890abcdef1234567890abcdef12.
get_nft_balance
Section titled “get_nft_balance”Gets the NFT (ERC721) balance for an address.
Parameters:
network
(optional): Network name or chain ID (defaults to Somnia testnet)tokenAddress
: The NFT contract addressaddress
: The address to check balance for
Example:
{ "network": "Somnia Testnet", "tokenAddress": "0xabcdef1234567890abcdef1234567890abcdef12", "address": "0x1234567890123456789012345678901234567890"}
Response: Returns the number of NFTs owned by the address in the collection.
Example Prompt:
How many NFTs does address 0x1234567890123456789012345678901234567890 own in collection 0xabcdef1234567890abcdef1234567890abcdef12?
Error Handling
Section titled “Error Handling”Balance tools may return errors if:
- The address format is invalid
- The token contract doesn’t exist or isn’t an ERC20/ERC721
- Network connection issues occur
- The address has no balance (returns 0, not an error)