---
id: HS0089
title: "Confidential transfer state reader"
url: https://carbium.sh/library/howsolana/confidential-transfer-state-reader
collection: How to use Solana
category: Token-2022
revision: 1
updated: 2026-11-22
author: Carbium
code: MIT (LICENSE in the zip); text: all rights reserved, Carbium Corporation
---

# Confidential transfer state reader

One TypeScript file reads a Token-2022 mint's confidential transfer settings, then checks token accounts from the mint's newest transaction for the account extension. It prints flags, counters and ciphertext sizes, and it needs no private key and no proof.

## What the mint shows

A Token-2022 mint can carry a confidential transfer extension. Anyone can read it, because it sits in the mint's own account data next to the supply and the authorities. Ask `getAccountInfo` for the mint with `jsonParsed` encoding and the node decodes each extension into a named object. The file needs no byte offsets of its own, so there is no layout to get wrong.

Three settings matter. The authority is the address allowed to change the configuration and to approve accounts, and it can be empty. The auto-approve flag says whether a new token account may use confidential transfers at once, or waits for the authority to approve it. The auditor key is an ElGamal public key, or nothing. When one is set, each confidential transfer carries an extra ciphertext of its amount under that key, so the holder of the matching secret key can read amounts that the public cannot.

A mint with no such extension simply lacks it in its extension list, and the file says so and stops. A mint owned by the classic token program cannot carry extensions at all, so its list is empty for the same reason.

## What each token account shows

A token account of that mint holds confidential transfer state only after its owner configured it, which is a separate instruction from creating the account. The state is another extension in the account data, and `getMultipleAccounts` with `jsonParsed` returns it the same way as the mint's.

| Field | What it tells you |
|---|---|
| approved | The confidential transfer authority, or the auto-approve flag, cleared this account for confidential use. |
| allowConfidentialCredits | Whether confidential transfers may arrive. |
| allowNonConfidentialCredits | Whether ordinary, visible transfers may still arrive. |
| pendingBalanceCreditCounter | How many incoming confidential credits wait to be applied. |
| maximumPendingBalanceCreditCounter | The ceiling the owner set for that counter. |
| availableBalance | A 64-byte ElGamal ciphertext of the spendable confidential balance. |
| pendingBalanceLo, pendingBalanceHi | Ciphertexts of incoming amounts, split into a low and a high part. |
| decryptableAvailableBalance | A 36-byte AES ciphertext the owner uses to read their own balance quickly. |

The pending counter explains a common surprise. Incoming confidential transfers land in the pending balance, and the owner has to apply them before they can be spent. A counter above zero means credits are waiting. A counter that has reached its maximum means further confidential credits to the account will be refused until the owner applies what is pending.

## What stays unreadable

The ciphertext fields come back as base64 text. Decoded, they are bytes with no amount in them. Turning `availableBalance` into a number takes the owner's ElGamal secret key, and the AES ciphertext takes the owner's AES key. Nothing on chain and nothing in an RPC reply hands either key to a reader, and this file never asks for one.

Much stays visible anyway. A transfer is still a transaction: its signature, the token accounts it names and the program it calls are public. The visible `amount` field of the token account stays public too, and it covers only the part of the balance that is not confidential.

> A visible balance of zero does not mean an empty account. Funds held in the confidential balance do not show up in `amount`.

## Running it

Install `@solana/kit` at 8.6.0, export `CARBIUM_KEY` and run the file with Node 24. The mint address is an optional first argument and defaults to PayPal USD, a Token-2022 stablecoin mint.

`main.ts` (run: `node main.ts [mint-address]`)

```ts
// HS0089 · Confidential transfer state reader
// https://carbium.sh/library/howsolana/confidential-transfer-state-reader
// Copyright (c) Carbium Corporation. MIT License (LICENSE). Keep this notice.
// SPDX-License-Identifier: MIT

import {
  address,
  createDefaultRpcTransport,
  createSolanaRpcFromTransport,
} from "@solana/kit";
import { Buffer } from "node:buffer";

const key = process.env.CARBIUM_KEY;
if (!key) {
  console.error("Set CARBIUM_KEY to your Carbium API key.");
  process.exit(1);
}
const url = process.env.CARBIUM_RPC_URL ?? "https://services.carbium.sh";
const rpc = createSolanaRpcFromTransport(
  createDefaultRpcTransport({ url, headers: { "x-api-key": key } }),
);

type Ext = { extension: string; state: Record<string, unknown> };
type Data = { parsed?: { info?: { extensions?: Ext[] } } } | undefined;
// jsonParsed decodes extensions on the node: no byte offsets in this file.
const ext = (data: unknown, name: string) =>
  (data as Data)?.parsed?.info?.extensions?.find((e) => e.extension === name)?.state;
const size = (b64: unknown) => (typeof b64 === "string" ? Buffer.from(b64, "base64").length : "n/a");

const mint = address(process.argv[2] ?? "2b1kV6DkPAnxd5ixfnxCpjxmKwqjjaYmCZfHsFu24GXo");
const { value: mintInfo } = await rpc
  .getAccountInfo(mint, { encoding: "jsonParsed", commitment: "confirmed" })
  .send();
const cfg = ext(mintInfo?.data, "confidentialTransferMint");
if (!cfg) {
  console.log(`${mint}: no confidentialTransferMint extension`);
  process.exit(0);
}
console.log(`mint ${mint}`);
console.log(`authority=${cfg.authority ?? "none"} autoApprove=${cfg.autoApproveNewAccounts} auditorKey=${cfg.auditorElgamalPubkey ?? "none"}`);

// Token accounts of this mint, from the newest transaction that yields some.
type Tx = {
  transaction: { message: { accountKeys: { pubkey: string }[] } };
  meta: { postTokenBalances?: { accountIndex: number; mint: string }[] } | null;
};
const sigs = await rpc.getSignaturesForAddress(mint, { limit: 5, commitment: "confirmed" }).send();
const holders = new Set<string>();
for (const { signature } of sigs) {
  try {
    const tx = (await rpc
      .getTransaction(signature, { encoding: "jsonParsed", maxSupportedTransactionVersion: 1, commitment: "confirmed" })
      .send()) as unknown as Tx | null;
    if (!tx) {
      console.log(`${signature}: null (below the ledger floor)`);
      continue;
    }
    const keys = tx.transaction.message.accountKeys.map((k) => k.pubkey);
    for (const b of tx.meta?.postTokenBalances ?? []) {
      if (b.mint === mint) holders.add(keys[b.accountIndex]);
    }
  } catch (e) {
    console.log(`${signature}: ${e instanceof Error ? e.message : e}`);
  }
  if (holders.size > 0) break;
}
const list = [...holders].slice(0, 100).map((a) => address(a));
if (list.length === 0) {
  console.log("no token accounts found in the newest transactions");
  process.exit(0);
}

const { value } = await rpc
  .getMultipleAccounts(list, { encoding: "jsonParsed", commitment: "confirmed" })
  .send();
value.forEach((acc, i) => {
  const s = ext(acc?.data, "confidentialTransferAccount");
  if (!s) {
    console.log(`${list[i]}: not configured for confidential transfers`);
    return;
  }
  console.log(`${list[i]}: approved=${s.approved} confidentialCredits=${s.allowConfidentialCredits} plainCredits=${s.allowNonConfidentialCredits}`);
  console.log(`  pendingCounter=${s.pendingBalanceCreditCounter}/${s.maximumPendingBalanceCreditCounter} availableBalance=${size(s.availableBalance)} bytes (ciphertext)`);
});
```

The first read is `getAccountInfo` on the mint, which costs 10 cells like any [account read](https://carbium.sh/docs/rpc). The file looks for the `confidentialTransferMint` entry in the decoded extension list and prints its three settings.

To find token accounts of the mint without scanning anything, it takes the newest signatures that name the mint through `getSignaturesForAddress` (50 cells) and reads them one at a time with `getTransaction` (50 cells each) until one yields token balances for that mint. Each entry in `postTokenBalances` carries an account index, and the index points into the transaction's account keys. Those keys are the token accounts.

The transaction call passes `maxSupportedTransactionVersion: 1`. Mainnet carries v1 transactions, and without that value, or with 0, the node answers -32015 for one. The signature list also reaches below the validator's ledger floor, so `getTransaction` can return null for an older signature it lists. The file prints that and moves to the next signature. A failure on one transaction does not end the run.

The accounts then go to one `getMultipleAccounts` call, cut to 100 pubkeys, since below Pro the 1024-cell burst caps a call at 100 and each pubkey costs 10 cells. A 100-pubkey call costs 1000 cells, or 1001 over a 4 KiB body. Every read in the file passes `commitment: "confirmed"`, which is also what `@solana/kit` fills in when a call leaves it out.

## Where it ends

This file answers one question: what does the chain show about a mint's confidential transfer setup and the accounts using it. It gives no amounts. The balances are ciphertexts, and reading them needs the owner's secret keys, which a state reader has no business holding.

It builds no proofs and sends no transfers. A confidential transfer carries zero-knowledge proofs, checked on chain by a separate proof program, and producing them is the heavy part of the job. The maintained proof generators are Rust crates, and JavaScript coverage of that step is thin. Before you plan a JS client that sends confidential transfers, check what your library version covers today. Reading configuration, flags and ciphertexts works with any plain RPC client, as above.

It also samples. The accounts come from the newest transaction that touches the mint, so they show how a few recent holders are set up and say nothing about the whole supply. A full holder list needs an index of your own, and Carbium does not serve `getTokenLargestAccounts`: it answers -32601.

## When it goes wrong

| What goes wrong | What to do |
|---|---|
| The run prints that the mint has no confidentialTransferMint extension. | The mint does not use the extension. Check which program owns it: a classic token program mint carries no extensions. Pass a Token-2022 mint that enabled confidential transfers. |
| Error -32015 from `getTransaction`. | The transaction is v1 and the call left out `maxSupportedTransactionVersion` or sent 0. Send 1 with the encoding, as the file does. |
| `getTransaction` returns null for a signature the list just gave you. | The signature list reaches below the validator's ledger floor, so the transaction body may be gone. Skip it and try a newer signature, as the loop does. |
| An account of a confidential-transfer mint prints no extension. | The mint enables the feature, but each owner configures their own account. An account that was never configured has no state to show. This is a valid result. |
| A getMultipleAccounts call over 100 pubkeys is refused below the Pro plan. | The 1024-cell burst caps a call at 100 pubkeys there. Send chunks of at most 100. |
| Error -32601 on a holder-listing call. | The method is not served. Do not retry it. Take accounts from transactions as the file does, or build your own index. |

## Questions

### Can I read someone's confidential balance with this?

No. The balance is a ciphertext that only the owner's keys open. The file prints its decoded size so you can see that it is present and well-formed, and no more.

### Does the auditor key let a reader see balances?

The auditor key lets whoever holds its secret half read the amounts attached to confidential transfers. A reader who has only the public key learns that an auditor exists and nothing about any amount.

### What does auto-approve set to false change?

A new account can configure confidential transfers but stays unapproved until the confidential transfer authority approves it. The `approved` field on the account shows which state it is in.

### Do I need a signer or a private key for any of this?

No. Every call is a read. The Carbium key only identifies your account to the RPC.

## Related

- [Token account layout decoder](https://carbium.sh/library/howsolana/token-account-layout-decoder) (How to use Solana, HS0021)
- [Token authority screening](https://carbium.sh/library/usecase/token-authority-screening) (Use cases, UC0009)
- [carbium.sh/docs/rpc](https://carbium.sh/docs/rpc)
- [carbium.sh/docs/auth](https://carbium.sh/docs/auth)
- [carbium.sh/docs/limits](https://carbium.sh/docs/limits)
- [carbium.sh/docs/errors](https://carbium.sh/docs/errors)
