> For the complete documentation index, see [llms.txt](https://hinkal-team.gitbook.io/hinkal/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hinkal-team.gitbook.io/hinkal/hinkal-mobile-sdk/ios/guides/balances.md).

# Balances

Read the private balance for the connected identity, and check for funds stuck in unspendable UTXOs.

### Private Balance

SDK calls take an `NSError` out-parameter, wrapped here with the `call` helper from Getting Started.

```swift
let balanceJSON = try call {
    hinkal.getTotalBalance(
        chainId,
        userKeysSignature: signature,
        ethAddress: address,
        resetCache: false,
        useBlockedUtxos: false,
        error: &$0
    )
}
```

The result is JSON with the balance per token. Pass `resetCache: true` to re-scan on-chain instead of using cached UTXOs - do this after a deposit, withdrawal, or transfer.

### Parameters

| Parameter           | Type     | Description                                    |
| ------------------- | -------- | ---------------------------------------------- |
| `chainID`           | `Int64`  | Target chain id.                               |
| `userKeysSignature` | `String` | Signature that unlocks the shielded account.   |
| `ethAddress`        | `String` | The wallet address.                            |
| `resetCache`        | `Bool`   | Re-scan instead of using cached UTXOs.         |
| `useBlockedUtxos`   | `Bool`   | Include UTXOs blocked by scheduled operations. |

### Stuck balances

Funds can be stuck in UTXOs that normal operations cannot spend (for example after an interrupted deposit-and-withdraw). Check them, then recover with `withdrawStuckUtxos`:

```swift
let stuckJSON = try call { hinkal.getStuckShieldedBalances(chainId, userKeysSignature: signature, ethAddress: address, error: &$0) }
let recoverTx = try call { hinkal.withdrawStuckUtxos(chainId, tokenAddr: tokenAddress, recipientAddress: recipientPublicAddress, error: &$0) }
```

### Best Practices

#### 1. Cache and refresh deliberately

Read with `resetCache: false` for normal UI reads; pass `resetCache: true` only after a deposit, withdrawal, transfer, or swap.

```swift
let fresh = try call { hinkal.getTotalBalance(chainId, userKeysSignature: signature,
    ethAddress: address, resetCache: true, useBlockedUtxos: false, error: &$0) }
```

#### 2. Check stuck funds when a balance looks low

```swift
let stuck = try call { hinkal.getStuckShieldedBalances(chainId, userKeysSignature: signature, ethAddress: address, error: &$0) }
```
