Hinkal Mobile SDK

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.

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

ParameterTypeDescription
chainIDInt64Target chain id.
userKeysSignatureStringSignature that unlocks the shielded account.
ethAddressStringThe wallet address.
resetCacheBoolRe-scan instead of using cached UTXOs.
useBlockedUtxosBoolInclude 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:

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.

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

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