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

# React Native Balances & History

> Read wallet balances and transaction history with the React Native OMS Wallet SDK.

Use `oms.indexer` to read balances and transaction history after creating `OMSClient`. Requests use the publishable key configured for the client, and token amounts are returned as raw base-unit strings.

Pass explicit SDK `OmsNetwork` values with `networks`, or omit `networks` and use `networkType`. When both are omitted, `networkType` defaults to `MAINNETS`.

## Get Balances

```typescript theme={null}
import { formatUnits } from '@0xsequence/oms-react-native-sdk'

const walletAddress = await oms.wallet.getWalletAddress()

if (!walletAddress) {
  throw new Error('No active wallet session')
}

const polygon = oms.supportedNetworks.find((network) => network.chainId === '137')

const result = await oms.indexer.getBalances({
  walletAddress,
  networks: polygon ? [polygon] : undefined,
  contractAddresses: ['0x2222222222222222222222222222222222222222'],
  includeMetadata: true,
})

for (const balance of result.nativeBalances) {
  console.log(balance.symbol, formatUnits(balance.balance ?? '0', 18))
}

for (const balance of result.balances) {
  const decimals = balance.contractInfo?.decimals ?? 18
  console.log(balance.contractAddress, formatUnits(balance.balance ?? '0', decimals))
}
```

**Parameters**

| Parameter           | Type                                                        | Description                                                                                   |
| ------------------- | ----------------------------------------------------------- | --------------------------------------------------------------------------------------------- |
| `walletAddress`     | `string`                                                    | Wallet address to inspect. This can be the active wallet or any wallet address.               |
| `networks`          | `OmsNetwork[]` or undefined                                 | Explicit networks to query. Use values from `oms.supportedNetworks`.                          |
| `networkType`       | `'MAINNETS'`, `'TESTNETS'`, `'ALL'`, or undefined           | Network group to query when `networks` is omitted. Defaults to `MAINNETS`.                    |
| `contractAddresses` | `string[]` or undefined                                     | Optional token contract addresses to query. Omit it to query balances across token contracts. |
| `includeMetadata`   | `boolean` or undefined                                      | Whether token metadata should be included in the response. Defaults to `true`.                |
| `omitPrices`        | `boolean`, `null`, or undefined                             | Whether price fields should be omitted.                                                       |
| `tokenIds`          | `string[]` or undefined                                     | Optional token IDs to filter by.                                                              |
| `contractStatus`    | `'VERIFIED'`, `'UNVERIFIED'`, `'ALL'`, `null`, or undefined | Contract verification status filter.                                                          |
| `page.page`         | `number` or undefined                                       | Optional page number. Defaults to `0` when `page` is omitted.                                 |
| `page.pageSize`     | `number` or undefined                                       | Optional page size. Defaults to the SDK response default when omitted.                        |

**Returns**

`oms.indexer.getBalances` returns `Promise<OmsBalancesResult>`.

| Field            | Type                                         | Description                                      |
| ---------------- | -------------------------------------------- | ------------------------------------------------ |
| `status`         | `number`                                     | HTTP status code from the balance response.      |
| `page`           | `OmsTokenBalancesPage`, `null`, or undefined | Pagination metadata from the balance response.   |
| `nativeBalances` | `OmsTokenBalance[]`                          | Native token balances returned for the wallet.   |
| `balances`       | `OmsTokenBalance[]`                          | Token contract balances returned for the wallet. |

## Get Transaction History

```typescript theme={null}
const walletAddress = await oms.wallet.getWalletAddress()

if (!walletAddress) {
  throw new Error('No active wallet session')
}

const amoy = oms.supportedNetworks.find((network) => network.chainId === '80002')

const result = await oms.indexer.getTransactionHistory({
  walletAddress,
  networks: amoy ? [amoy] : undefined,
  includeMetadata: true,
  page: {
    page: 0,
    pageSize: 25,
  },
})

for (const transaction of result.transactions) {
  console.log(transaction.txnHash, transaction.timestamp)
}
```

**Parameters**

| Parameter                          | Type                                              | Description                                                                           |
| ---------------------------------- | ------------------------------------------------- | ------------------------------------------------------------------------------------- |
| `walletAddress`                    | `string`                                          | Wallet address to inspect. This can be the active wallet or any wallet address.       |
| `networks`                         | `OmsNetwork[]` or undefined                       | Explicit networks to query. Use values from `oms.supportedNetworks`.                  |
| `networkType`                      | `'MAINNETS'`, `'TESTNETS'`, `'ALL'`, or undefined | Network group to query when `networks` is omitted. Defaults to `MAINNETS`.            |
| `contractAddresses`                | `string[]` or undefined                           | Optional token contract addresses to filter by.                                       |
| `transactionHashes`                | `string[]` or undefined                           | Optional on-chain transaction hashes to filter by.                                    |
| `metaTransactionIds`               | `string[]` or undefined                           | Optional wallet transaction ID filters, such as `txnId` returned by transaction APIs. |
| `fromBlock`                        | `number`, `null`, or undefined                    | Optional lower block number bound.                                                    |
| `toBlock`                          | `number`, `null`, or undefined                    | Optional upper block number bound.                                                    |
| `tokenId`                          | `string`, `null`, or undefined                    | Optional token ID filter.                                                             |
| `includeMetadata`                  | `boolean` or undefined                            | Whether token metadata should be included in the response. Defaults to `true`.        |
| `omitPrices`                       | `boolean`, `null`, or undefined                   | Whether price fields should be omitted.                                               |
| `metadataOptions.verifiedOnly`     | `boolean` or undefined                            | Include metadata only for verified contracts.                                         |
| `metadataOptions.unverifiedOnly`   | `boolean` or undefined                            | Include metadata only for unverified contracts.                                       |
| `metadataOptions.includeContracts` | `string[]` or undefined                           | Contract addresses for metadata inclusion.                                            |
| `page.page`                        | `number` or undefined                             | Optional page number. Defaults to `0` when `page` is omitted.                         |
| `page.pageSize`                    | `number` or undefined                             | Optional page size. Defaults to the SDK response default when omitted.                |

**Returns**

`oms.indexer.getTransactionHistory` returns `Promise<OmsTransactionHistoryResult>`.

| Field          | Type                                         | Description                                                |
| -------------- | -------------------------------------------- | ---------------------------------------------------------- |
| `status`       | `number`                                     | HTTP status code from the transaction-history response.    |
| `page`         | `OmsTokenBalancesPage`, `null`, or undefined | Pagination metadata from the transaction-history response. |
| `transactions` | `OmsTransaction[]`                           | Transactions returned for the wallet.                      |

## Token Balance Shape

Each `OmsTokenBalance` can include:

| Field                | Type                                         | Description                                                                      |
| -------------------- | -------------------------------------------- | -------------------------------------------------------------------------------- |
| `contractType`       | `string` or `null`                           | Token contract type, such as ERC20, ERC721, or `NATIVE`.                         |
| `contractAddress`    | `string` or `null`                           | Token contract address. Native token balances do not include a contract address. |
| `accountAddress`     | `string` or `null`                           | Wallet address queried.                                                          |
| `tokenId`            | `string` or `null`                           | Token ID for token types that use IDs.                                           |
| `name`               | `string`, `null`, or undefined               | Token name.                                                                      |
| `symbol`             | `string`, `null`, or undefined               | Token symbol.                                                                    |
| `balance`            | `string` or `null`                           | Raw base-unit balance as a string.                                               |
| `balanceUSD`         | `string`, `null`, or undefined               | Balance value in USD when prices are included.                                   |
| `priceUSD`           | `string`, `null`, or undefined               | Token price in USD when prices are included.                                     |
| `priceUpdatedAt`     | `string`, `null`, or undefined               | Timestamp for the price.                                                         |
| `blockHash`          | `string` or `null`                           | Block hash for the balance snapshot.                                             |
| `blockNumber`        | `number`, `null`, or undefined               | Block number for the balance snapshot.                                           |
| `chainId`            | `number`, `null`, or undefined               | Numeric chain ID.                                                                |
| `uniqueCollectibles` | `string`, `null`, or undefined               | Unique collectible count for NFT summary rows.                                   |
| `isSummary`          | `boolean`, `null`, or undefined              | Whether the row summarizes a set of balances.                                    |
| `contractInfo`       | `OmsTokenContractInfo`, `null`, or undefined | Token contract metadata when requested and available.                            |
| `tokenMetadata`      | `OmsTokenMetadata`, `null`, or undefined     | Token metadata when requested and available.                                     |

## Transaction Shape

Each `OmsTransaction` can include:

| Field         | Type                                             | Description                                  |
| ------------- | ------------------------------------------------ | -------------------------------------------- |
| `txnHash`     | `string` or `null`                               | On-chain transaction hash.                   |
| `blockNumber` | `number` or `null`                               | Block number.                                |
| `blockHash`   | `string` or `null`                               | Block hash.                                  |
| `chainId`     | `number` or `null`                               | Numeric chain ID.                            |
| `metaTxnId`   | `string`, `null`, or undefined                   | Wallet transaction ID when available.        |
| `transfers`   | `OmsTransactionTransfer[]`, `null`, or undefined | Token transfers included in the transaction. |
| `timestamp`   | `string`, `null`, or undefined                   | Transaction timestamp.                       |
