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

# Swift Balances & History

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

Use `oms.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

```swift theme={null}
let result = try await oms.indexer.getTokenBalances(
    network: .polygon,
    contractAddress: "0xTokenContract",
    walletAddress: oms.wallet.walletAddress,
    includeMetadata: true
)

for balance in result.balances {
    let displayBalance = try formatUnits(value: balance.balance ?? "0", decimals: 6)
    print(balance.contractAddress ?? "", displayBalance)
}
```

**Parameters**

| Parameter         | Type      | Description                                                                                   |
| ----------------- | --------- | --------------------------------------------------------------------------------------------- |
| `network`         | `Network` | Supported SDK network, such as `.polygon` or `.polygonAmoy`.                                  |
| `contractAddress` | `String`  | Token contract address to query.                                                              |
| `walletAddress`   | `String`  | Wallet address to inspect. This can be the active non-custodial wallet or any wallet address. |
| `includeMetadata` | `Bool`    | Whether token metadata should be included in the response.                                    |

**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` | `[TokenBalance]`     | Balances returned for the wallet and contract. |

## Get Native Token Balance

```swift theme={null}
let nativeBalance = try await oms.indexer.getNativeTokenBalance(
    network: .polygonAmoy,
    walletAddress: oms.wallet.walletAddress
)

print(nativeBalance?.balance ?? "0")
```

**Parameters**

| Parameter       | Type      | Description                                                  |
| --------------- | --------- | ------------------------------------------------------------ |
| `network`       | `Network` | Supported SDK network, such as `.polygon` or `.polygonAmoy`. |
| `walletAddress` | `String`  | Wallet address to inspect.                                   |

**Returns**

`getNativeTokenBalance` returns `TokenBalance?`.

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

## Token Balance Shape

Each `TokenBalance` may 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`     | `Int64?`  | Block number for the balance snapshot.                                           |
| `chainId`         | `Int64?`  | Numeric chain ID.                                                                |
