> ## 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 SDK balances and history

> Query EVM balances and history or Solana balances for any address without a wallet session.

`omsWallet.indexer` is read-only. It accepts any wallet address and does not require authentication, a completed wallet session, or the currently selected address.

Indexer methods are `suspend` functions. Amounts are raw base-unit strings.

## Query balances

Pass explicit networks when you know which chains to query:

```kotlin theme={null}
import technology.polygon.omswallet.Network

val result = omsWallet.indexer.getBalances(
    walletAddress = "0x1111111111111111111111111111111111111111",
    networks = listOf(Network.POLYGON),
)

result.nativeBalances.forEach { balance ->
    println("${balance.symbol}: ${balance.balance}")
}

result.balances.forEach { balance ->
    println("${balance.contractAddress}: ${balance.balance}")
}
```

`TokenBalancesResult` exposes native assets as `List<NativeTokenBalance>` and contract assets as `List<ContractTokenBalance>`. Contract balances include their contract address and token ID. Price, contract, and token metadata is nullable when unavailable. Use the [public API reference](/wallets/sdk/kotlin/api-reference) when you need every response field.

Use `formatUnits(balance.balance.toBigInteger(), decimals)` with the token's actual decimals when presenting a balance. The helper removes trailing fractional zeros.

## Query Solana balances

Use `getSolanaBalances` for native SOL and fungible SPL-token balances. Omitting `networks` queries both Solana Mainnet and Devnet.

```kotlin theme={null}
import technology.polygon.omswallet.SolanaNetwork

val result = omsWallet.indexer.getSolanaBalances(
    walletAddress = "vn3YnndV3gGu7DrHSQAPfywmba7QPq18SvA7PSiytAV",
    networks = listOf(SolanaNetwork.Mainnet, SolanaNetwork.Devnet),
)

result.balances.forEach(::println)
result.errors.forEach { error ->
    println("${error.network}: ${error.reason}")
}
```

Filter fungible tokens with `mintAddresses` or `excludedMintAddresses`, and use `omitNativeBalances` when native SOL is not needed. Individual network failures appear in `errors` without discarding balances returned by another requested network.

The SDK does not expose Solana transaction history. `getTransactionHistory` is for EVM networks.

## Query transaction history

```kotlin theme={null}
import technology.polygon.omswallet.Network

val history = omsWallet.indexer.getTransactionHistory(
    walletAddress = "0x1111111111111111111111111111111111111111",
    networks = listOf(Network.POLYGON),
)

history.transactions.forEach { transaction ->
    println("${transaction.txnHash}: ${transaction.timestamp}")
}
```

`TransactionHistoryResult.transactions` is `List<Transaction>`. Each transaction includes its chain, hash, block position, timestamp, and transfers. The OMS transaction ID and transfer metadata are optional.

## Choose networks

When `networks` is non-empty, the SDK sends those chain IDs. When it is empty, `networkType` controls the group and defaults to `IndexerNetworkType.MAINNETS`.

```kotlin theme={null}
import technology.polygon.omswallet.models.IndexerNetworkType

val result = omsWallet.indexer.getBalances(
    walletAddress = "0x1111111111111111111111111111111111111111",
    networkType = IndexerNetworkType.ALL,
)
```

Use `MAINNETS`, `TESTNETS`, or `ALL`. See [Networks](/wallets/sdk/kotlin/networks-and-reference) for the explicit `Network` registry.

## Filter and paginate balances

Apply filters only after the basic query works:

```kotlin theme={null}
import technology.polygon.omswallet.Network
import technology.polygon.omswallet.models.ContractVerificationStatus
import technology.polygon.omswallet.models.TokenBalancesPageRequest

val result = omsWallet.indexer.getBalances(
    walletAddress = "0x1111111111111111111111111111111111111111",
    networks = listOf(Network.POLYGON),
    contractAddresses = listOf("0x2222222222222222222222222222222222222222"),
    contractStatus = ContractVerificationStatus.VERIFIED,
    includeMetadata = true,
    page = TokenBalancesPageRequest(page = 0, pageSize = 40),
)

if (result.page?.more == true) {
    val nextPage = result.page.page + 1
}
```

Balance queries can also filter by `tokenIds`, omit price data with `omitPrices`, or disable metadata with `includeMetadata = false`.

Increment the page number while `result.page?.more` is `true`.

## Filter transaction history

History filters include contract addresses, transaction hashes, OMS meta-transaction IDs, block range, and token ID:

```kotlin theme={null}
import technology.polygon.omswallet.Network
import technology.polygon.omswallet.models.TokenBalancesPageRequest

val history = omsWallet.indexer.getTransactionHistory(
    walletAddress = "0x1111111111111111111111111111111111111111",
    networks = listOf(Network.POLYGON),
    metaTransactionIds = listOf("txn-id-from-send-transaction"),
    fromBlock = 60_000_000,
    includeMetadata = false,
    page = TokenBalancesPageRequest(page = 0, pageSize = 40),
)
```

Use `metadataOptions` only when you need verified-only, unverified-only, or included-contract metadata behavior. It affects metadata enrichment, not the address being queried.
