useGetEncryptedFeeReserve
MUTATION — submits a transaction (costs gas). Mirrors the on-chain accessEncryptedFeeReserve(token) function: grants the caller persistent decrypt access to the encrypted token fee reserve as an euint64 handle.
@tokenops/sdk/fhe-disperse/react{ mutate, mutateAsync, isPending, error, data }Description
MUTATION — submits a transaction (costs gas). Mirrors the on-chain
accessEncryptedFeeReserve(token) function: grants the caller persistent
decrypt access to the encrypted token fee reserve as an euint64 handle.
The handle is granted persistent ACL on-chain via
FHE.allow(handle, msg.sender); the SDK extracts it from the receipt's
ACL.Allowed event (NOT from simulation — that returns a divergent,
ACL-less handle; see CLAUDE.md Pitfall #1).
Pass data.handle to the Zama relayer's userDecrypt to obtain the
plaintext reserve amount.
Throws `DisperseEncryptedReserveNotGrantedError` when no ACL event is found — typically means the reserve is uninitialised (no fees accrued for this token yet). The SDK does not silently return a zero handle because Zama's relayer cannot decrypt an uninitialised handle.
Requires FEE_COLLECTOR_ROLE or DEFAULT_ADMIN_ROLE on the singleton.
Example
const view = useAccessEncryptedFeeReserve();
view.mutate({ token });
// view.data → { handle: "0x...", hash: "0x..." }Pulled directly from the hook's TSDoc block — the same snippet your IDE shows on hover.
Errors
This mutation can reject with SDK-level, product-level, or viem-passthrough errors. Product classes carry the offending value as fields — render them inline instead of a generic "transaction failed." See Disperse › Errors for the per-class recovery table.
Invalidation recipe
After this mutation succeeds, invalidate the queries it affects so consumer UI re-fetches fresh state. The SDK never auto-invalidates — that's a consumer decision (different apps cache different shapes).
import { useQueryClient } from "@tanstack/react-query";
const queryClient = useQueryClient();
const getEncryptedFeeReserve = useGetEncryptedFeeReserve(/* options */);
getEncryptedFeeReserve.mutate(args, {
onSuccess() {
// Coarse invalidation: refresh every cached read on this product surface.
queryClient.invalidateQueries({
queryKey: ["tokenops-sdk", "fhe-disperse"],
});
},
});See also
Other Encrypted read hooks in disperse: