| title | Query Keys |
|---|---|
| description | Reference for the zamaQueryKeys factory used for manual React Query cache control. |
The zamaQueryKeys object is a factory for React Query cache keys. Use it to invalidate, prefetch, or remove cached data manually.
Mutations auto-invalidate related caches, so you only need zamaQueryKeys for advanced cache control.
import { zamaQueryKeys } from "@zama-fhe/react-sdk";import { useQueryClient } from "@tanstack/react-query";
import { zamaQueryKeys } from "@zama-fhe/react-sdk";
const queryClient = useQueryClient();
// Invalidate all balances
queryClient.invalidateQueries({ queryKey: zamaQueryKeys.confidentialBalance.all });
// Invalidate one token's balances
queryClient.invalidateQueries({
queryKey: zamaQueryKeys.confidentialBalance.token("0xToken"),
});
// Invalidate a specific owner's balance
queryClient.invalidateQueries({
queryKey: zamaQueryKeys.confidentialBalance.owner("0xToken", "0xOwner"),
});Single-token decrypted balance.
| Key | Scope |
|---|---|
.all |
All decrypted balances |
.token(addr) |
All balances for one token |
.owner(addr, owner) |
One owner's balance for one token |
Multi-token batch balances.
| Key | Scope |
|---|---|
.all |
All batch balance queries |
.tokens(addrs, owner) |
Batch query for specific tokens and owner |
Single-token encrypted handle (pre-decryption).
| Key | Scope |
|---|---|
.all |
All handles |
.token(addr) |
Handles for one token |
.owner(addr, owner) |
One owner's handle for one token |
Multi-token batch handles.
| Key | Scope |
|---|---|
.all |
All batch handle queries |
.tokens(addrs, owner) |
Batch query for specific tokens and owner |
User decryption queries (used by useUserDecrypt).
| Key | Scope |
|---|---|
.all |
All decryption queries |
.handle(handle, contract?) |
Single handle (used internally by the cache) |
.batch(handles[], account) |
Batch decrypt for a specific requester |
Session signature status.
| Key | Scope |
|---|---|
.all |
All session-allowed queries |
ERC-20 allowance of the underlying token for the wrapper.
| Key | Scope |
|---|---|
.all |
All allowance queries |
.token(addr) |
Allowances for one token |
.scope(addr, owner, wrapper) |
Specific owner-wrapper pair |
Classified activity feed.
| Key | Scope |
|---|---|
.all |
All feed queries |
.token(addr) |
Feed for one token |
.scope(addr, userAddress, logsKey, decrypt) |
Fully scoped feed query |
Fee queries.
| Key | Scope |
|---|---|
.shieldFee(feeManager, amount?, from?, to?) |
Shield fee estimate |
.unshieldFee(feeManager, amount?, from?, to?) |
Unshield fee estimate |
.batchTransferFee(feeManager) |
Batch transfer fee |
.feeRecipient(feeManager) |
Fee recipient address |
On-chain wrappers registry queries.
| Key | Scope |
|---|---|
.all |
All registry queries |
.chainId() |
Chain ID resolution |
.tokenPairs(registryAddr) |
All pairs for a registry |
.tokenPairsLength(registryAddr) |
Pair count |
.tokenPairsSlice(registryAddr, from, to) |
Index-based slice |
.tokenPair(registryAddr, index) |
Single pair by index |
.confidentialTokenAddress(registryAddr, tokenAddr) |
Forward lookup (plain → confidential) |
.tokenAddress(registryAddr, confidentialAddr) |
Reverse lookup (confidential → plain) |
.isConfidentialTokenValid(registryAddr, confidentialAddr) |
Validity check |
.listPairs(registryAddr, page, pageSize, metadata) |
Paginated listing |
// After a transfer made outside the SDK
queryClient.invalidateQueries({
queryKey: zamaQueryKeys.confidentialBalance.token("0xToken"),
});queryClient.prefetchQuery({
queryKey: zamaQueryKeys.confidentialBalance.owner("0xToken", "0xOwner"),
queryFn: () => fetchBalance("0xToken", "0xOwner"),
});queryClient.removeQueries({ queryKey: zamaQueryKeys.confidentialBalance.all });
queryClient.removeQueries({ queryKey: zamaQueryKeys.confidentialHandle.all });
queryClient.removeQueries({ queryKey: zamaQueryKeys.decryption.all });- ZamaProvider — provider setup and hook overview
useConfidentialBalance— the hook whose cache these keys control