> ## 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.

# Kotlin Balances & History

> Read wallet balance data with the Kotlin OMS Wallet SDK.

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

```kotlin theme={null}
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**

| Parameter         | Type                       | Description                                                                                   |
| ----------------- | -------------------------- | --------------------------------------------------------------------------------------------- |
| `network`         | `Network`                  | Supported SDK network, such as `Network.POLYGON` or `Network.AMOY`.                           |
| `contractAddress` | `String?`                  | Optional token contract address filter. Omit it to query balances across contracts.           |
| `walletAddress`   | `String`                   | Wallet address to inspect. This can be the active non-custodial wallet or any wallet address. |
| `includeMetadata` | `Boolean`                  | Whether token metadata should be included in the response.                                    |
| `page`            | `TokenBalancesPageRequest` | Optional pagination request. Defaults to page `0` with up to `40` entries.                    |

**Returns**

`getTokenBalances` returns `TokenBalancesResult`.

| Field      | Type                 | Description                                    |
| ---------- | -------------------- | ---------------------------------------------- |
| `status`   | `Int`                | HTTP status code from the balance response.    |
| `page`     | `TokenBalancesPage?` | Pagination metadata from the balance response. |
| `balances` | `List<TokenBalance>` | Balances returned for the wallet.              |

## Get Native Token Balance

```kotlin theme={null}
val nativeBalance = client.indexer.getNativeTokenBalance(
    network = Network.AMOY,
    walletAddress = walletAddress,
)

println(nativeBalance?.balance)
```

**Parameters**

| Parameter       | Type      | Description                                                         |
| --------------- | --------- | ------------------------------------------------------------------- |
| `network`       | `Network` | Supported SDK network, such as `Network.POLYGON` or `Network.AMOY`. |
| `walletAddress` | `String`  | Wallet 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:

| Field             | Type      | Description                                                                      |
| ----------------- | --------- | -------------------------------------------------------------------------------- |
| `contractType`    | `String?` | Token contract type, such as ERC20, ERC721, or `NATIVE`.                         |
| `contractAddress` | `String?` | Token contract address. Native token balances do not include a contract address. |
| `accountAddress`  | `String?` | Wallet address queried.                                                          |
| `tokenId`         | `String?` | Token ID for token types that use IDs.                                           |
| `balance`         | `String?` | Raw base-unit balance as a string.                                               |
| `blockHash`       | `String?` | Block hash for the balance snapshot.                                             |
| `blockNumber`     | `Long?`   | Block number for the balance snapshot.                                           |
| `chainId`         | `Long?`   | Numeric chain ID.                                                                |
