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

> Query native balances, contract token balances, and transaction history for any address.

`omsWallet.indexer` is read-only. It accepts any wallet address and does not require authentication or an active wallet session.

## Query balances

Choose explicit SDK networks for predictable scope.

```swift theme={null}
let address = "0x1111111111111111111111111111111111111111"

let result = try await omsWallet.indexer.getBalances(
    GetBalancesParams(
        walletAddress: address,
        networks: [.polygon, .polygonAmoy]
    )
)

for balance in result.nativeBalances {
    print(balance.chainId, balance.symbol, balance.balance)
}

for balance in result.balances {
    print(balance.chainId, balance.contractAddress, balance.tokenId, balance.balance)
}
```

Amounts are raw base-unit strings. Use `try formatUnits(value: balance.balance, decimals: decimals)` with the token's actual decimals for display. `result.nativeBalances` is `[NativeTokenBalance]`; `result.balances` is `[ContractTokenBalance]`.

Contract balances include their contract address and token ID. Price, contract, and token metadata is optional even when requested. Use the [public API reference](/wallets/sdk/swift/api-reference) when you need every response field.

`includeMetadata` defaults to `true`. Set it to `false` when you only need balance data.

## Query transaction history

```swift theme={null}
let history = try await omsWallet.indexer.getTransactionHistory(
    GetTransactionHistoryParams(
        walletAddress: address,
        networks: [.polygonAmoy]
    )
)

for transaction in history.transactions {
    print(transaction.txnHash)
    print(transaction.blockNumber, transaction.timestamp)

    for transfer in transaction.transfers {
        print(transfer.from, transfer.to, transfer.amounts)
    }
}
```

Each transaction includes its chain, hash, block position, timestamp, and transfers. The OMS transaction ID and transfer metadata are optional.

## Set network scope

When `networks` is nonempty, the SDK sends those chain IDs and ignores `networkType`. When `networks` is omitted or empty, `networkType` defaults to `.mainnets`.

Use `.testnets` or `.all` when you want a registry-wide group instead of explicit networks.

```swift theme={null}
let result = try await omsWallet.indexer.getBalances(
    GetBalancesParams(
        walletAddress: address,
        networkType: .testnets,
        includeMetadata: false
    )
)
```

## Filter results

Balance queries can filter by contract addresses, token IDs, and `ContractVerificationStatus`. History queries can filter by contract addresses, transaction hashes, OMS meta-transaction IDs, block range, and token ID.

```swift theme={null}
let history = try await omsWallet.indexer.getTransactionHistory(
    GetTransactionHistoryParams(
        walletAddress: address,
        networks: [.polygon],
        contractAddresses: [
            "0x2222222222222222222222222222222222222222"
        ],
        fromBlock: 60_000_000,
        includeMetadata: false,
        omitPrices: true
    )
)
```

Empty filter arrays are omitted from the request.

## Paginate

Requests default to page `0` with page size `40`. Supply `TokenBalancesPageRequest` when your UI needs another page or cursor.

```swift theme={null}
let result = try await omsWallet.indexer.getBalances(
    GetBalancesParams(
        walletAddress: address,
        networks: [.polygon],
        page: TokenBalancesPageRequest(
            page: 0,
            pageSize: 100
        )
    )
)

if result.page?.more == true {
    print("More balances are available")
}
```

Apply the same page request to transaction history when that result set needs pagination.
