Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.polygon.technology/llms.txt

Use this file to discover all available pages before exploring further.

Use client.indexer for wallet balance reads. Requests use the project access key configured on OMSClient, and balance amounts are returned as raw base-unit strings.

Get Token Balances

import com.omsclient.kotlin_sdk.Network

val walletAddress = requireNotNull(client.wallet.walletAddress) {
    "No wallet selected"
}

val result = client.indexer.getTokenBalances(
    network = Network.POLYGON,
    contractAddress = "0xTokenContract",
    walletAddress = walletAddress,
    includeMetadata = true,
)

for (balance in result.balances) {
    println("${balance.contractAddress}: ${balance.balance}")
}
Parameters
ParameterTypeDescription
networkNetworkSupported SDK network, such as Network.POLYGON or Network.AMOY.
contractAddressString?Optional token contract address filter. Omit it to query balances across contracts.
walletAddressStringWallet address to inspect. This can be the active embedded wallet or any wallet address.
includeMetadataBooleanWhether token metadata should be included in the response.
pageTokenBalancesPageRequestOptional pagination request. Defaults to page 0 with up to 40 entries.
Returns getTokenBalances returns TokenBalancesResult.
FieldTypeDescription
statusIntHTTP status code from the balance response.
pageTokenBalancesPage?Pagination metadata from the balance response.
balancesList<TokenBalance>Balances returned for the wallet.

Get Native Token Balance

val nativeBalance = client.indexer.getNativeTokenBalance(
    network = Network.AMOY,
    walletAddress = walletAddress,
)

println(nativeBalance?.balance)
Parameters
ParameterTypeDescription
networkNetworkSupported SDK network, such as Network.POLYGON or Network.AMOY.
walletAddressStringWallet address to inspect.
Returns getNativeTokenBalance returns TokenBalance?. It returns null when the response does not include a native balance.

Token Balance Shape

Each TokenBalance can include:
FieldTypeDescription
contractTypeString?Token contract type, such as ERC20, ERC721, or NATIVE.
contractAddressString?Token contract address. Native token balances do not include a contract address.
accountAddressString?Wallet address queried.
tokenIdString?Token ID for token types that use IDs.
balanceString?Raw base-unit balance as a string.
blockHashString?Block hash for the balance snapshot.
blockNumberLong?Block number for the balance snapshot.
chainIdLong?Numeric chain ID.