ReaduseQuery

useConfidentialBalance

Read the encrypted confidential balance handle (euint64 ciphertext) for account — defaults to the connected wallet.

Import
@tokenops/sdk/testnet-faucet/react
Return
{ data, isLoading, error, refetch }
Lifecycle
Read

Query Key

Faucet read hooks use the public constants TESTNET_FAUCET_KEY and TESTNET_FAUCET_NAMESPACE. The method segment for this hook is confidentialBalanceOf.

@tokenops/sdk/testnet-faucet/react
ts
queryKey: [
  "tokenops-sdk", // TESTNET_FAUCET_KEY
  "testnet-faucet", // TESTNET_FAUCET_NAMESPACE
  "confidentialBalanceOf",
  chainId ?? null,
  address ? address.toLowerCase() : null,
  // hook-specific args normalized: bigint -> decimal string, 0x strings -> lowercase
];

Description

Read the encrypted confidential balance handle (euint64 ciphertext) for account — defaults to the connected wallet.

Returns the bytes32 handle. The account holds persistent ACL on its own balance, so pass this handle — with the CTTT contract address and the account's signer — to the Zama relayer's userDecrypt to obtain the plaintext. The SDK is the producer side only.

Signature

@tokenops/sdk/testnet-faucet/react
ts
function useConfidentialBalance(args?: UseConfidentialBalanceArgs): UseQueryResult<Hex, Error>;

Parameters

Shape of the options object passed to the hook itself.

PropertyTypeDescription
accountAddressAccount whose confidential balance handle to read. Defaults to the connected wallet (useAccount().address). The hook stays disabled until an account is available.
Want to run a similar shape interactively? The Playground ships 8 ready presets across vesting / airdrop / disperse — deploy a manager, create a vesting, claim, and the airdrop / disperse equivalents. The deep-link above auto-selects the closest preset to useConfidentialBalance; pick another from the dropdown if you'd rather start there.

Example

@tokenops/sdk/testnet-faucet/react · @example
tsx
const { data: handle } = useConfidentialBalance(); // my own balance handle

Pulled directly from the hook's TSDoc block — the same snippet your IDE shows on hover.

See also

Other Read hooks in testnet faucet: