> ## 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 balance data with the React Native OMS Wallet SDK.

Use the React Native SDK balance helpers after `configure`. Requests use the project access key configured for the SDK, and balance amounts are returned as raw base-unit strings.

## Get Token Balances

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

const walletAddress = await getWalletAddress()

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

const result = await getTokenBalances({
  chainId: '137',
  contractAddress: '0xTokenContract',
  walletAddress,
  includeMetadata: true,
})

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

**Parameters**

| Parameter         | Type                   | Description                                                                              |
| ----------------- | ---------------------- | ---------------------------------------------------------------------------------------- |
| `chainId`         | `string`               | EVM chain ID as a string.                                                                |
| `contractAddress` | `string`               | Token contract address to query.                                                         |
| `walletAddress`   | `string`               | Wallet address to inspect. This can be the active embedded wallet or any wallet address. |
| `includeMetadata` | `boolean` or undefined | Whether token metadata should be included in the response. Defaults to `false`.          |

**Returns**

`getTokenBalances` returns `Promise<OmsTokenBalancesResult>`.

| Field      | Type                                | Description                                    |
| ---------- | ----------------------------------- | ---------------------------------------------- |
| `status`   | `number`                            | HTTP status code from the balance response.    |
| `page`     | `OmsTokenBalancesPage` or undefined | Pagination metadata from the balance response. |
| `balances` | `OmsTokenBalance[]`                 | Balances returned for the wallet.              |

## Get Native Token Balance

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

const nativeBalance = await getNativeTokenBalance({
  chainId: '80002',
  walletAddress,
})

console.log(nativeBalance?.balance)
```

**Parameters**

| Parameter       | Type     | Description                |
| --------------- | -------- | -------------------------- |
| `chainId`       | `string` | EVM chain ID as a string.  |
| `walletAddress` | `string` | Wallet address to inspect. |

**Returns**

`getNativeTokenBalance` returns `Promise<OmsTokenBalance | null>`.

It returns `null` when the response does not include a native balance.

## 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.                                           |
| `balance`         | `string` or `null` | Raw base-unit balance as a string.                                               |
| `blockHash`       | `string` or `null` | Block hash for the balance snapshot.                                             |
| `blockNumber`     | `number` or `null` | Block number for the balance snapshot.                                           |
| `chainId`         | `number` or `null` | Numeric chain ID.                                                                |
