> ## Documentation Index
> Fetch the complete documentation index at: https://docs.chipipay.com/llms.txt
> Use this file to discover all available pages before exploring further.

# getTokenBalance

> Fetches the on-chain token balance for a wallet on Starknet.

## Usage

```typescript theme={null}
const balance = await sdk.getTokenBalance(
  {
    chainToken: ChainToken.USDC,
    chain: Chain.STARKNET,
    walletPublicKey: "0x...",
  },
  bearerToken,
);
```

## Parameters

| Parameter         | Type         | Required | Description                                             |
| ----------------- | ------------ | -------- | ------------------------------------------------------- |
| `chainToken`      | `ChainToken` | Yes      | Token identifier (e.g. `"USDC"`)                        |
| `chain`           | `Chain`      | Yes      | Blockchain network. Use `Chain.STARKNET`                |
| `walletPublicKey` | `string`     | No       | Wallet address. Use this or `externalUserId`            |
| `externalUserId`  | `string`     | No       | External user ID. Use this or `walletPublicKey`         |
| `bearerToken`     | `string`     | No       | JWT token. Falls back to `apiSecretKey` if not provided |

## Return Value

Returns a `Promise<GetTokenBalanceResponse>` with the balance data.

## Example

```typescript theme={null}
import { ChipiServerSDK, Chain, ChainToken } from "@chipi-stack/backend";

const sdk = new ChipiServerSDK({
  apiPublicKey: process.env.CHIPI_PUBLIC_KEY!,
  apiSecretKey: process.env.CHIPI_SECRET_KEY!,
});

const balance = await sdk.getTokenBalance(
  {
    chainToken: ChainToken.USDC,
    chain: Chain.STARKNET,
    walletPublicKey: "0x04...abc",
  },
  bearerToken,
);

console.log("Balance:", balance);
```
