> ## Documentation Index
> Fetch the complete documentation index at: https://trust-link-tsn.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Read a TIN balance

> Load wallet-authorized TIN balances from finalized Solana history and display exact token amounts.

Use `loadTinOwnerBalanceV1` to build the connected owner's balance view. The SDK validates the TIP registry account, unlocks the owner's encrypted seed locally with wallet approval, and reconstructs balances from finalized TCAP activity.

## Before you start

* Build the [workspace SDK](https://trust-link-tsn.mintlify.site/sdk/getting-started.md) and connect the wallet that owns the registered TIN. The wallet must support `signMessage`.
* Configure a Solana RPC for the selected TSN deployment with access to finalized accounts, address signature history and raw transactions.
* Supply an authenticated `TinOwnerIdentityClient` or the `registry`, `programId` and `displayName` from your verified owner context. The SDK checks registry ownership, the registered wallet commitment and the current GPRU keys on chain.

An identity client implements `post(path, body)` for `/owner-tin-identity-challenge` and `/owner-tin-identity`. The XP reference application serves those routes under `/api/tsn/sdk`, with the active wallet session and CSRF headers. They belong to the application backend. The one-time lookup signature goes to that service, while the reusable seed-access signature and decrypted seed stay on the device. [Owner balance API](https://trust-link-tsn.mintlify.site/api-reference/sdk/modules/tin-owner-balance.md)

## Load and display the balance

Copy the example into your app and call it when the owner opens or refreshes the balance view. [TypeScript example](https://github.com/bigdreamsweb3/trustlink-pay/blob/main/tsn-protocol/tsn-docs/sdk/examples/tin-balance.ts)

```ts theme={null}
import { Connection } from "@solana/web3.js";
import type { TinBalanceWallet, TinOwnerIdentityClient } from "@trustlink/tsn-sdk/tin-owner-balance";
import { readOwnerTinBalance } from "./tin-balance.js";

export async function loadBalancePanel(input: {
  rpcUrl: string;
  tin: string;
  wallet: TinBalanceWallet;
  identityClient: TinOwnerIdentityClient;
  signal?: AbortSignal;
}) {
  return readOwnerTinBalance({
    connection: new Connection(input.rpcUrl, "finalized"),
    tin: input.tin,
    ownerWallet: input.wallet,
    identityClient: input.identityClient,
    cacheAuthorization: true,
    signal: input.signal,
  });
}
```

Render one row per `tokenBalances` entry, using its `mint`, `decimals` and the example's `displayBalance`. The SDK returns `balanceBaseUnits` as a decimal string. Format it with integer arithmetic to preserve precision. The remaining response fields are `latestGlobalSequence`, `latestOwnerSequence` and `actionCount`.

On a cold session the wallet can prompt for identity lookup and local seed access. The opted-in cache reuses the verified identity context and seed-access signature in device memory. It clears on wallet disconnect or account change when the adapter exposes those events. Call `clearTinOwnerBalanceAccessV1(wallet)` at application logout. [Access and cache functions](https://trust-link-tsn.mintlify.site/api-reference/sdk/modules/tin-owner-balance.md)

## Handle unavailable history

Show an empty balance view only after a successful read returns an empty `tokenBalances` array. If the call rejects, show **Balance unavailable**. An interrupted RPC scan, unsupported receipt, invalid owner context or changing shared root can all prevent recovery. Refresh against a current finalized snapshot after the error, or use an RPC with complete history for the deployment.

The current reader bounds its scan to 100 pages of up to 100 address signatures and validates that the decoded credit and TIN-to-TIN transitions reach the finalized root in order. If it cannot reconstruct that history within the bound, the read fails. [Chain history API](https://trust-link-tsn.mintlify.site/api-reference/sdk/modules/gpru-chain-history.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.