Skip to main content

fhe-disperse/react

Interfaces

BaseHookOptions

Defined in: fhe-disperse/react/_shared.ts:25

Common per-hook overrides — every public hook accepts these alongside its own args.

Extended by

Properties

PropertyTypeDescriptionDefined in
address?... | ...Override the on-chain singleton address. Defaults to getFheDisperseSingletonAddress keyed by chain id.fhe-disperse/react/_shared.ts:27
chainId?... | ...Override the chain id used for default address resolution. Defaults to usePublicClient().chain?.id.fhe-disperse/react/_shared.ts:29

DisperseHookOptions

Defined in: fhe-disperse/react/_shared.ts:38

Per-hook overrides for FHE-disperse hooks. The singleton has one deployed address per chain — address is optional and resolved by chain id via getFheDisperseSingletonAddress. Pass encryptor here so methods that submit encrypted inputs (useDisperse, useWithdrawTokenFee) can pick it up.

Extends

Properties

PropertyTypeDescriptionInherited fromDefined in
address?... | ...Override the on-chain singleton address. Defaults to getFheDisperseSingletonAddress keyed by chain id.BaseHookOptions.addressfhe-disperse/react/_shared.ts:27
chainId?... | ...Override the chain id used for default address resolution. Defaults to usePublicClient().chain?.id.BaseHookOptions.chainIdfhe-disperse/react/_shared.ts:29
encryptor?... | ...Lazy or eager encryptor source. Optional at hook level; required at call time for methods that submit encrypted inputs (useDisperse, useWithdrawTokenFee). Recommended in React: capture useZamaSDK() once at the top of your component and wire encryptor: () => sdk.relayer — the SDK calls this per-encryption so it picks up the live ZamaSDK instance rather than a stale capture (CLAUDE.md Pitfall #3). An eager Encryptor instance also type-checks and is appropriate for server-side or test code. The SDK does NOT call useZamaSDK() automatically — calling a React hook from inside a mutation body would violate the rules of hooks. If encryptor is omitted and a method that needs one runs, the SDK throws TokenOpsSdkError("Missing encryptor — pass ...").-fhe-disperse/react/_shared.ts:55
aclAddress?... | ...Override the FHEVM ACL address (defaults to chain-id lookup).-fhe-disperse/react/_shared.ts:57

UseApproveTokenOnWalletsArgs

Defined in: fhe-disperse/react/useApproveTokenOnWallets.ts:7

Properties

PropertyTypeDescriptionDefined in
token`0x${(...)}`ERC-7984 token to approve as operator on the caller's wallets.fhe-disperse/react/useApproveTokenOnWallets.ts:9
account?... | ... | ...Override signer account. Falls back to walletClient.account.fhe-disperse/react/useApproveTokenOnWallets.ts:11

UseCalculateFeeArgs

Defined in: fhe-disperse/react/useCalculateFee.ts:7

Common per-hook overrides — every public hook accepts these alongside its own args.

Extends

Properties

PropertyTypeDescriptionInherited fromDefined in
address?... | ...Override the on-chain singleton address. Defaults to getFheDisperseSingletonAddress keyed by chain id.BaseHookOptions.addressfhe-disperse/react/_shared.ts:27
chainId?... | ...Override the chain id used for default address resolution. Defaults to usePublicClient().chain?.id.BaseHookOptions.chainIdfhe-disperse/react/_shared.ts:29
user?... | ...--fhe-disperse/react/useCalculateFee.ts:8
mode?... | ...--fhe-disperse/react/useCalculateFee.ts:9
recipients?... | ...--fhe-disperse/react/useCalculateFee.ts:10
totalTokens?... | ...Required for "wallet-token-fee" mode.-fhe-disperse/react/useCalculateFee.ts:12

UseDisableCustomFeeArgs

Defined in: fhe-disperse/react/useDisableCustomFee.ts:7

Properties

PropertyTypeDescriptionDefined in
user`0x${(...)}`-fhe-disperse/react/useDisableCustomFee.ts:8
account?... | ... | ...Override signer account. Falls back to walletClient.account.fhe-disperse/react/useDisableCustomFee.ts:10

UseGetFeesArgs

Defined in: fhe-disperse/react/useGetFees.ts:7

Common per-hook overrides — every public hook accepts these alongside its own args.

Extends

Properties

PropertyTypeDescriptionInherited fromDefined in
address?... | ...Override the on-chain singleton address. Defaults to getFheDisperseSingletonAddress keyed by chain id.BaseHookOptions.addressfhe-disperse/react/_shared.ts:27
chainId?... | ...Override the chain id used for default address resolution. Defaults to usePublicClient().chain?.id.BaseHookOptions.chainIdfhe-disperse/react/_shared.ts:29
user?... | ...The user whose resolved fees to read. Hook is disabled until set.-fhe-disperse/react/useGetFees.ts:9

UseGetWalletsArgs

Defined in: fhe-disperse/react/useGetWallets.ts:6

Common per-hook overrides — every public hook accepts these alongside its own args.

Extends

Properties

PropertyTypeDescriptionInherited fromDefined in
address?... | ...Override the on-chain singleton address. Defaults to getFheDisperseSingletonAddress keyed by chain id.BaseHookOptions.addressfhe-disperse/react/_shared.ts:27
chainId?... | ...Override the chain id used for default address resolution. Defaults to usePublicClient().chain?.id.BaseHookOptions.chainIdfhe-disperse/react/_shared.ts:29
user?... | ...The user whose wallet pair to read. Hook is disabled until set.-fhe-disperse/react/useGetWallets.ts:8

UseGrantRoleArgs

Defined in: fhe-disperse/react/useGrantRole.ts:7

Properties

PropertyTypeDescriptionDefined in
role`0x${(...)}`-fhe-disperse/react/useGrantRole.ts:8
accountTarget`0x${(...)}`-fhe-disperse/react/useGrantRole.ts:9
account?... | ... | ...Override signer account. Falls back to walletClient.account.fhe-disperse/react/useGrantRole.ts:11

UseHasApprovedSubwalletsArgs

Defined in: fhe-disperse/react/useHasApprovedSubwallets.ts:7

Common per-hook overrides — every public hook accepts these alongside its own args.

Extends

Properties

PropertyTypeDescriptionInherited fromDefined in
address?... | ...Override the on-chain singleton address. Defaults to getFheDisperseSingletonAddress keyed by chain id.BaseHookOptions.addressfhe-disperse/react/_shared.ts:27
chainId?... | ...Override the chain id used for default address resolution. Defaults to usePublicClient().chain?.id.BaseHookOptions.chainIdfhe-disperse/react/_shared.ts:29
user?... | ...Address whose registered subwallets to check. Hook disabled until set.-fhe-disperse/react/useHasApprovedSubwallets.ts:9
token?... | ...ERC-7984 token address to check the operator approval against. Hook disabled until set.-fhe-disperse/react/useHasApprovedSubwallets.ts:11

UseHasRoleArgs

Defined in: fhe-disperse/react/useHasRole.ts:6

Common per-hook overrides — every public hook accepts these alongside its own args.

Extends

Properties

PropertyTypeDescriptionInherited fromDefined in
address?... | ...Override the on-chain singleton address. Defaults to getFheDisperseSingletonAddress keyed by chain id.BaseHookOptions.addressfhe-disperse/react/_shared.ts:27
chainId?... | ...Override the chain id used for default address resolution. Defaults to usePublicClient().chain?.id.BaseHookOptions.chainIdfhe-disperse/react/_shared.ts:29
role?... | ...--fhe-disperse/react/useHasRole.ts:7
account?... | ...The address to check role membership for. Hook disabled until set.-fhe-disperse/react/useHasRole.ts:9

UseIsRegisteredArgs

Defined in: fhe-disperse/react/useIsRegistered.ts:6

React/wagmi hooks for @tokenops/sdk/fhe-disperse.

Every public method on the headless ConfidentialDisperseClient is wrapped as a hook here. Hooks compose with wagmi (usePublicClient, useWalletClient) and TanStack Query (useQuery, useMutation) — no extra provider needed beyond the standard wagmi <WagmiProvider> + <QueryClientProvider>.

The singleton address is resolved per-chain via getFheDisperseSingletonAddress. Pass address to DisperseHookOptions to override (e.g. for forks or redeployments).

Encryptor. For methods that submit encrypted inputs (useDisperse, useWithdrawTokenFee), pass an explicit encryptor source (eager Encryptor or () => Encryptor | undefined). useZamaSDK() returns ZamaSDK; the encrypt-capable interface lives on .relayer. Wire it as a lazy factory so the SDK picks up the live React context at submit time (CLAUDE.md Pitfall #3):

import { useZamaSDK } from "@zama-fhe/react-sdk";

function Component() {
const zamaSDK = useZamaSDK();
const disperse = useDisperse({ encryptor: () => zamaSDK.relayer });
...
}

@zama-fhe/react-sdk is an OPTIONAL peer dep — install it explicitly (pnpm add @zama-fhe/react-sdk) for FHE flows. The hook surface here never imports it at top level; consumers without FHE pay no cost.

Mutations do NOT auto-invalidate read queries — that's a consumer decision. Each mutation's TSDoc documents the recommended queryClient.invalidateQueries.

Extends

Properties

PropertyTypeDescriptionInherited fromDefined in
address?... | ...Override the on-chain singleton address. Defaults to getFheDisperseSingletonAddress keyed by chain id.BaseHookOptions.addressfhe-disperse/react/_shared.ts:27
chainId?... | ...Override the chain id used for default address resolution. Defaults to usePublicClient().chain?.id.BaseHookOptions.chainIdfhe-disperse/react/_shared.ts:29
user?... | ...The user to check registration for. Hook is disabled until set.-fhe-disperse/react/useIsRegistered.ts:8

UsePauseArgs

Defined in: fhe-disperse/react/usePause.ts:7

Properties

PropertyTypeDescriptionDefined in
account?... | ... | ...Override signer account. Falls back to walletClient.account.fhe-disperse/react/usePause.ts:9

UsePredictWalletsArgs

Defined in: fhe-disperse/react/usePredictWallets.ts:6

Common per-hook overrides — every public hook accepts these alongside its own args.

Extends

Properties

PropertyTypeDescriptionInherited fromDefined in
address?... | ...Override the on-chain singleton address. Defaults to getFheDisperseSingletonAddress keyed by chain id.BaseHookOptions.addressfhe-disperse/react/_shared.ts:27
chainId?... | ...Override the chain id used for default address resolution. Defaults to usePublicClient().chain?.id.BaseHookOptions.chainIdfhe-disperse/react/_shared.ts:29
user?... | ...The user whose wallet pair to predict. Hook is disabled until set.-fhe-disperse/react/usePredictWallets.ts:8

UsePreflightDisperseArgs

Defined in: fhe-disperse/react/usePreflightDisperse.ts:7

Common per-hook overrides — every public hook accepts these alongside its own args.

Extends

Properties

PropertyTypeDescriptionInherited fromDefined in
address?... | ...Override the on-chain singleton address. Defaults to getFheDisperseSingletonAddress keyed by chain id.BaseHookOptions.addressfhe-disperse/react/_shared.ts:27
chainId?... | ...Override the chain id used for default address resolution. Defaults to usePublicClient().chain?.id.BaseHookOptions.chainIdfhe-disperse/react/_shared.ts:29
user?... | ...--fhe-disperse/react/usePreflightDisperse.ts:8
token?... | ...--fhe-disperse/react/usePreflightDisperse.ts:9
recipients?... | ...--fhe-disperse/react/usePreflightDisperse.ts:10
amounts?... | ...--fhe-disperse/react/usePreflightDisperse.ts:11
mode?... | ...--fhe-disperse/react/usePreflightDisperse.ts:12

UseRecoverERC20FromWalletsArgs

Defined in: fhe-disperse/react/useRecoverERC20FromWallets.ts:7

Properties

PropertyTypeDescriptionDefined in
token`0x${(...)}`ERC-20 token to recover from the caller's wallets.fhe-disperse/react/useRecoverERC20FromWallets.ts:9
to`0x${(...)}`Address to receive the recovered tokens.fhe-disperse/react/useRecoverERC20FromWallets.ts:11
account?... | ... | ...Override signer account. Falls back to walletClient.account.fhe-disperse/react/useRecoverERC20FromWallets.ts:13

UseRecoverFromWalletsArgs

Defined in: fhe-disperse/react/useRecoverFromWallets.ts:7

Properties

PropertyTypeDescriptionDefined in
token`0x${(...)}`ERC-7984 token to recover from the caller's wallets.fhe-disperse/react/useRecoverFromWallets.ts:9
to`0x${(...)}`Address to receive the recovered tokens.fhe-disperse/react/useRecoverFromWallets.ts:11
account?... | ... | ...Override signer account. Falls back to walletClient.account.fhe-disperse/react/useRecoverFromWallets.ts:13

UseRegisterArgs

Defined in: fhe-disperse/react/useRegister.ts:8

Properties

PropertyTypeDescriptionDefined in
token`0x${(...)}`ERC-7984 token to approve the new subwallets for.fhe-disperse/react/useRegister.ts:10
account?... | ... | ...Override signer account. Falls back to walletClient.account.fhe-disperse/react/useRegister.ts:12

UseRescueConfidentialTokensArgs

Defined in: fhe-disperse/react/useRescueConfidentialTokens.ts:7

Properties

PropertyTypeDescriptionDefined in
token`0x${(...)}`ERC-7984 token to rescue.fhe-disperse/react/useRescueConfidentialTokens.ts:9
to`0x${(...)}`Recipient of the rescued tokens.fhe-disperse/react/useRescueConfidentialTokens.ts:11
account?... | ... | ...Override signer account. Falls back to walletClient.account.fhe-disperse/react/useRescueConfidentialTokens.ts:13

UseRescueERC20Args

Defined in: fhe-disperse/react/useRescueERC20.ts:7

Properties

PropertyTypeDescriptionDefined in
token`0x${(...)}`ERC-20 token to rescue.fhe-disperse/react/useRescueERC20.ts:9
to`0x${(...)}`Recipient of the rescued tokens.fhe-disperse/react/useRescueERC20.ts:11
account?... | ... | ...Override signer account. Falls back to walletClient.account.fhe-disperse/react/useRescueERC20.ts:13

UseRevokeRoleArgs

Defined in: fhe-disperse/react/useRevokeRole.ts:7

Properties

PropertyTypeDescriptionDefined in
role`0x${(...)}`-fhe-disperse/react/useRevokeRole.ts:8
accountTarget`0x${(...)}`-fhe-disperse/react/useRevokeRole.ts:9
account?... | ... | ...Override signer account. Falls back to walletClient.account.fhe-disperse/react/useRevokeRole.ts:11

UseRevokeTokenOnWalletsArgs

Defined in: fhe-disperse/react/useRevokeTokenOnWallets.ts:7

Properties

PropertyTypeDescriptionDefined in
token`0x${(...)}`ERC-7984 token to revoke operator approval on.fhe-disperse/react/useRevokeTokenOnWallets.ts:9
account?... | ... | ...Override signer account. Falls back to walletClient.account.fhe-disperse/react/useRevokeTokenOnWallets.ts:11

UseSetCustomFeeArgs

Defined in: fhe-disperse/react/useSetCustomFee.ts:7

Properties

PropertyTypeDescriptionDefined in
user`0x${(...)}`-fhe-disperse/react/useSetCustomFee.ts:8
gasFeebigintPer-user gas fee override in wei.fhe-disperse/react/useSetCustomFee.ts:10
tokenFeenumberPer-user token fee override in BPS.fhe-disperse/react/useSetCustomFee.ts:12
account?... | ... | ...Override signer account. Falls back to walletClient.account.fhe-disperse/react/useSetCustomFee.ts:14

UseSetFeeConfigArgs

Defined in: fhe-disperse/react/useSetFeeConfig.ts:8

Properties

PropertyTypeDescriptionDefined in
configFeeConfig-fhe-disperse/react/useSetFeeConfig.ts:9
account?... | ... | ...Override signer account. Falls back to walletClient.account.fhe-disperse/react/useSetFeeConfig.ts:11

UseSetMaxBatchSizeDirectArgs

Defined in: fhe-disperse/react/useSetMaxBatchSizeDirect.ts:7

Properties

PropertyTypeDescriptionDefined in
sizebigintMax recipients in a single "direct" mode call. 0n = no limit.fhe-disperse/react/useSetMaxBatchSizeDirect.ts:9
account?... | ... | ...Override signer account. Falls back to walletClient.account.fhe-disperse/react/useSetMaxBatchSizeDirect.ts:11

UseSetMaxBatchSizeHoldingArgs

Defined in: fhe-disperse/react/useSetMaxBatchSizeHolding.ts:7

Properties

PropertyTypeDescriptionDefined in
sizebigintMax recipients in a single "wallet" mode call. 0n = no limit.fhe-disperse/react/useSetMaxBatchSizeHolding.ts:9
account?... | ... | ...Override signer account. Falls back to walletClient.account.fhe-disperse/react/useSetMaxBatchSizeHolding.ts:11

UseSetMaxBatchSizeTokenFeeArgs

Defined in: fhe-disperse/react/useSetMaxBatchSizeTokenFee.ts:7

Properties

PropertyTypeDescriptionDefined in
sizebigintMax recipients in a single "wallet-token-fee" mode call. 0n = no limit.fhe-disperse/react/useSetMaxBatchSizeTokenFee.ts:9
account?... | ... | ...Override signer account. Falls back to walletClient.account.fhe-disperse/react/useSetMaxBatchSizeTokenFee.ts:11

UseUnpauseArgs

Defined in: fhe-disperse/react/useUnpause.ts:7

Properties

PropertyTypeDescriptionDefined in
account?... | ... | ...Override signer account. Falls back to walletClient.account.fhe-disperse/react/useUnpause.ts:9

UseWithdrawGasFeeArgs

Defined in: fhe-disperse/react/useWithdrawGasFee.ts:7

Properties

PropertyTypeDescriptionDefined in
to`0x${(...)}`Recipient of the withdrawn ETH.fhe-disperse/react/useWithdrawGasFee.ts:9
amountbigintAmount in wei to withdraw. The contract does not interpret 0n as "drain" — passing 0n succeeds with no ETH movement. Read the singleton balance with publicClient.getBalance(singleton) to drain.fhe-disperse/react/useWithdrawGasFee.ts:15
account?... | ... | ...Override signer account. Falls back to walletClient.account.fhe-disperse/react/useWithdrawGasFee.ts:17

UseWithdrawTokenFeePlaintextArgs

Defined in: fhe-disperse/react/useWithdrawTokenFee.ts:19

Plaintext path: SDK encrypts amount before submission.

Extends

  • WithdrawTokenFeeCommon

Properties

PropertyTypeDescriptionInherited fromDefined in
token`0x${(...)}`ERC-7984 token whose accumulated fee reserve to withdraw from.WithdrawTokenFeeCommon.tokenfhe-disperse/react/useWithdrawTokenFee.ts:11
to`0x${(...)}`Recipient of the withdrawn confidential tokens.WithdrawTokenFeeCommon.tofhe-disperse/react/useWithdrawTokenFee.ts:13
account?... | ... | ...Override signer account. Falls back to walletClient.account.WithdrawTokenFeeCommon.accountfhe-disperse/react/useWithdrawTokenFee.ts:15
amountbigintPlaintext amount to withdraw. SDK encrypts via encryptor (or hook-level).-fhe-disperse/react/useWithdrawTokenFee.ts:21
encryptor?... | ...Optional per-call encryptor override. Accepts an eager Encryptor or a lazy `() => Encryptorundefined factory — same shape as the hook-level [DisperseHookOptions](#dispersehookoptions).encryptor`.-
encryptedInput?undefined--fhe-disperse/react/useWithdrawTokenFee.ts:28

UseWithdrawTokenFeePreEncryptedArgs

Defined in: fhe-disperse/react/useWithdrawTokenFee.ts:32

Pre-encrypted path: caller already produced the EncryptedInput.

Extends

  • WithdrawTokenFeeCommon

Properties

PropertyTypeDescriptionInherited fromDefined in
token`0x${(...)}`ERC-7984 token whose accumulated fee reserve to withdraw from.WithdrawTokenFeeCommon.tokenfhe-disperse/react/useWithdrawTokenFee.ts:11
to`0x${(...)}`Recipient of the withdrawn confidential tokens.WithdrawTokenFeeCommon.tofhe-disperse/react/useWithdrawTokenFee.ts:13
account?... | ... | ...Override signer account. Falls back to walletClient.account.WithdrawTokenFeeCommon.accountfhe-disperse/react/useWithdrawTokenFee.ts:15
encryptedInputEncryptedInputPre-encrypted input — skips SDK-side encryption.-fhe-disperse/react/useWithdrawTokenFee.ts:34
amount?undefined--fhe-disperse/react/useWithdrawTokenFee.ts:35
encryptor?undefined--fhe-disperse/react/useWithdrawTokenFee.ts:36

Type Aliases

UseWithdrawTokenFeeArgs

type UseWithdrawTokenFeeArgs = ... | ...;

Defined in: fhe-disperse/react/useWithdrawTokenFee.ts:45

Mirrors the headless withdrawTokenFee invariant: exactly one of amount (plaintext, SDK encrypts) or encryptedInput (pre-encrypted). The discriminated union surfaces that requirement at compile time instead of as a runtime InvalidArgumentError.

Variables

FHE_DISPERSE_KEY

const FHE_DISPERSE_KEY: "tokenops-sdk";

Defined in: fhe-disperse/react/_shared.ts:61

Stable query-key prefix for every hook in this subpath.


FHE_DISPERSE_NAMESPACE

const FHE_DISPERSE_NAMESPACE: "fhe-disperse";

Defined in: fhe-disperse/react/_shared.ts:62


useGetEncryptedFeeReserve

const useGetEncryptedFeeReserve: (options) => ... = useAccessEncryptedFeeReserve;

Defined in: fhe-disperse/react/useAccessEncryptedFeeReserve.ts:51

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.

Parameters

ParameterType
options...

Returns

...

Example

const view = useAccessEncryptedFeeReserve();
view.mutate({ token });
// view.data → { handle: "0x...", hash: "0x..." }

Deprecated

Renamed to useAccessEncryptedFeeReserve to mirror the contract function and signal that this is a mutation (not a query). The old name remains as a re-export and will be removed in the next major.

Functions

useAccessEncryptedFeeReserve()

function useAccessEncryptedFeeReserve(options?): UseMutationResult<..., ..., ...>;

Defined in: fhe-disperse/react/useAccessEncryptedFeeReserve.ts:32

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.

Parameters

ParameterType
optionsDisperseHookOptions

Returns

UseMutationResult<..., ..., ...>

Example

const view = useAccessEncryptedFeeReserve();
view.mutate({ token });
// view.data → { handle: "0x...", hash: "0x..." }

useApproveTokenOnWallets()

function useApproveTokenOnWallets(options?): UseMutationResult<..., ..., ...>;

Defined in: fhe-disperse/react/useApproveTokenOnWallets.ts:29

Approve the caller's existing registered wallets as ERC-7984 operators for token. Required for wallet-mode disperses on a token different from the one passed at registration.

Prerequisite: call useRegister first — this hook reverts with UserNotRegistered if the caller has no wallet pair on the singleton.

After success, invalidate useHasApprovedSubwallets({ user, token }).

Parameters

ParameterType
optionsDisperseHookOptions

Returns

UseMutationResult<..., ..., ...>

Example

const approve = useApproveTokenOnWallets();
approve.mutate({ token });

useBatchDiscloseHandlesToParty()

function useBatchDiscloseHandlesToParty(options?): UseMutationResult<..., ..., ...>;

Defined in: fhe-disperse/react/useBatchDiscloseHandlesToParty.ts:19

Batch variant of useDiscloseHandleToParty — atomically grant party persistent ACL on all handles. Reverts on the first handle that fails caller-ACL or contract-ACL checks.

Returns { hash, discloser, party, disclosedHandles } parsed from the HandlesDisclosedToParty event.

Parameters

ParameterType
optionsDisperseHookOptions

Returns

UseMutationResult<..., ..., ...>

Example

const batchDisclose = useBatchDiscloseHandlesToParty();
batchDisclose.mutate({ handles, party: accountingAddress });

useCalculateFee()

function useCalculateFee(args?): UseQueryResult<..., ...>;

Defined in: fhe-disperse/react/useCalculateFee.ts:29

Compute the exact fee for a disperse call before submitting — reads live fee data via getFees(user) and applies the mode-specific formula.

  • "wallet" / "direct": ethValue = recipients * gasFeeWei, no token fee.
  • "wallet-token-fee": ethValue = 0n, tokenFeeAmount = totalTokens * tokenFeeBps / 10_000n.

Hook is disabled until user, mode, and recipients are set.

Parameters

ParameterType
argsUseCalculateFeeArgs

Returns

UseQueryResult<..., ...>

Example

const { data: fee } = useCalculateFee({
user, mode: "direct", recipients: 100,
});

useDeploymentBlockNumber()

function useDeploymentBlockNumber(options?): UseQueryResult<..., ...>;

Defined in: fhe-disperse/react/useDeploymentBlockNumber.ts:13

Read the block number at which the singleton was deployed — useful as the fromBlock argument to getLogs when subscribing to events.

Parameters

ParameterType
optionsBaseHookOptions

Returns

UseQueryResult<..., ...>

Example

const { data: deployBlock } = useDeploymentBlockNumber();
publicClient.getLogs({ fromBlock: deployBlock, ... });

useDisableCustomFee()

function useDisableCustomFee(options?): UseMutationResult<..., ..., ...>;

Defined in: fhe-disperse/react/useDisableCustomFee.ts:24

Admin: remove a per-user fee override, falling back to the global defaults. Reverts with CustomFeeNotSet if no override exists. Requires FEE_MANAGER_ROLE.

After success, invalidate useGetFees({ user }).

Parameters

ParameterType
optionsDisperseHookOptions

Returns

UseMutationResult<..., ..., ...>

Example

const disableCustomFee = useDisableCustomFee();
disableCustomFee.mutate({ user });

useDiscloseHandleToParty()

function useDiscloseHandleToParty(options?): UseMutationResult<..., ..., ...>;

Defined in: fhe-disperse/react/useDiscloseHandleToParty.ts:23

Grant party persistent FHE ACL on a single handle. Caller must already hold ACL on the handle; FHEVM ACL is append-only — the grant cannot be revoked once committed.

Common use: a fee-collector who decrypted the reserve handle via useGetEncryptedFeeReserve wants to delegate ongoing decrypt access to a downstream accounting service.

Returns { hash, discloser, party, disclosedHandles } parsed from the HandlesDisclosedToParty event.

Parameters

ParameterType
optionsDisperseHookOptions

Returns

UseMutationResult<..., ..., ...>

Example

const disclose = useDiscloseHandleToParty();
disclose.mutate({ handle, party: accountingAddress });

useDisperse()

function useDisperse(options?): UseMutationResult<..., ..., ...>;

Defined in: fhe-disperse/react/useDisperse.ts:31

Disperse confidential tokens to multiple recipients. The SDK validates inputs, computes the wallet-mode subtotal split, encrypts all amounts + subtotals in a single proof batch, computes msg.value for gas-fee modes, and dispatches to the correct contract entry point based on mode.

Encryptor resolution. The hook-level encryptor (from DisperseHookOptions) is forwarded lazily to the SDK client. If missing when the mutation runs, the SDK throws Missing encryptor — pass encryptor… verbatim. Capture useZamaSDK() once at the top of your component and forward () => zamaSDK.relayer — never () => useZamaSDK().relayer inline (calls a React hook inside a mutation body, violating the rules of hooks; see CLAUDE.md Pitfall #3).

After success, invalidate useGetFees, useHasApprovedSubwallets, and any downstream token-balance queries owned by the consumer.

Parameters

ParameterType
optionsDisperseHookOptions

Returns

UseMutationResult<..., ..., ...>

Example

function Component() {
const zamaSDK = useZamaSDK();
const disperse = useDisperse({ encryptor: () => zamaSDK.relayer });
disperse.mutate({ token, mode: "direct", recipients, amounts });
}

useGetBatchLimits()

function useGetBatchLimits(options?): UseQueryResult<..., ...>;

Defined in: fhe-disperse/react/useGetBatchLimits.ts:14

Read the maximum batch size for each of the three disperse modes ("wallet", "direct", "wallet-token-fee"). 0n means no limit.

Parameters

ParameterType
optionsBaseHookOptions

Returns

UseQueryResult<..., ...>

Example

const { data: limits } = useGetBatchLimits();
// limits → { holding, direct, tokenFee }

useGetFeeConfig()

function useGetFeeConfig(options?): UseQueryResult<..., ...>;

Defined in: fhe-disperse/react/useGetFeeConfig.ts:17

Read the on-chain global fee configuration (feeConfig getter).

Returns the FeeConfig struct the contract stores — pass the result straight back to useSetFeeConfig to flip one toggle without re-stating the others.

Parameters

ParameterType
optionsBaseHookOptions

Returns

UseQueryResult<..., ...>

Example

const { data: cfg } = useGetFeeConfig();
// cfg → { gasFeeEnabled, tokenFeeEnabled, defaultGasFee, defaultTokenFee }

useGetFees()

function useGetFees(args?): UseQueryResult<..., ...>;

Defined in: fhe-disperse/react/useGetFees.ts:22

Read consolidated fee information for user — combines per-user resolved fees (getFeeAmounts) with the global feeConfig toggles in one read.

UI code calls this to render the fee panel before the user submits.

Parameters

ParameterType
argsUseGetFeesArgs

Returns

UseQueryResult<..., ...>

Example

const { data: fees } = useGetFees({ user });
// fees → { isCustom, gasFeeWei, tokenFeeBps, gasFeeEnabled, tokenFeeEnabled }

useGetWallets()

function useGetWallets(args?): UseQueryResult<..., ...>;

Defined in: fhe-disperse/react/useGetWallets.ts:22

Read the on-chain wallet pair for a registered user.

Returns null if the user is not registered. For unregistered users, call usePredictWallets to get the deterministic addresses they would receive after register().

Parameters

ParameterType
argsUseGetWalletsArgs

Returns

UseQueryResult<..., ...>

Example

const { data: wallets } = useGetWallets({ user });
if (wallets) { ... wallets[0], wallets[1] ... }

useGrantRole()

function useGrantRole(options?): UseMutationResult<..., ..., ...>;

Defined in: fhe-disperse/react/useGrantRole.ts:28

AccessControl: grant role to accountTarget on the singleton. Caller must hold the role's admin role (typically DEFAULT_ADMIN_ROLE, i.e. the all-zero hash). Non-zero role hashes are keccak256(toBytes("<NAME>")).

After success, invalidate useHasRole({ role, account: accountTarget }).

Parameters

ParameterType
optionsDisperseHookOptions

Returns

UseMutationResult<..., ..., ...>

Example

import { keccak256, toBytes } from "viem";
const FEE_MANAGER_ROLE = keccak256(toBytes("FEE_MANAGER_ROLE"));
const grant = useGrantRole();
grant.mutate({ role: FEE_MANAGER_ROLE, accountTarget: opsAddress });

useHasApprovedSubwallets()

function useHasApprovedSubwallets(args?): UseQueryResult<..., ...>;

Defined in: fhe-disperse/react/useHasApprovedSubwallets.ts:28

Check whether a user's registered subwallets have approved the singleton as an ERC-7984 operator for token. Both must return true before a wallet-mode disperse will succeed.

Returns { wallet0: false, wallet1: false, both: false } if the user is not yet registered — for pre-registration approvals, use usePredictWallets and call isOperator(predicted, singleton) on the token directly.

Parameters

ParameterType
argsUseHasApprovedSubwalletsArgs

Returns

UseQueryResult<..., ...>

Example

const { data: approvals } = useHasApprovedSubwallets({ user, token });
if (!approvals?.both) { /* prompt user to approve */ }

useHasRole()

function useHasRole(args?): UseQueryResult<..., ...>;

Defined in: fhe-disperse/react/useHasRole.ts:25

Read AccessControl: is account a member of role on the singleton?

DisperseConfidential defines DEFAULT_ADMIN_ROLE (the all-zero hash), FEE_MANAGER_ROLE, FEE_COLLECTOR_ROLE, and PAUSER_ROLE. The non-zero role hashes are keccak256(toBytes("<ROLE_NAME>")) — compute them at the call site (the SDK does not export them as named constants).

Parameters

ParameterType
argsUseHasRoleArgs

Returns

UseQueryResult<..., ...>

Example

import { keccak256, toBytes } from "viem";
const FEE_MANAGER_ROLE = keccak256(toBytes("FEE_MANAGER_ROLE"));
const { data: isManager } = useHasRole({ role: FEE_MANAGER_ROLE, account: user });

useIsPaused()

function useIsPaused(options?): UseQueryResult<..., ...>;

Defined in: fhe-disperse/react/useIsPaused.ts:13

Read the singleton's paused flag. When true, all disperse operations revert until a PAUSER_ROLE member calls unpause().

Parameters

ParameterType
optionsBaseHookOptions

Returns

UseQueryResult<..., ...>

Example

const { data: paused } = useIsPaused();
if (paused) { /* disable submit button */ }

useIsRegistered()

function useIsRegistered(args?): UseQueryResult<..., ...>;

Defined in: fhe-disperse/react/useIsRegistered.ts:18

Check whether a user has already called register(token) and has a deployed wallet pair on the singleton.

Parameters

ParameterType
argsUseIsRegisteredArgs

Returns

UseQueryResult<..., ...>

Example

const { data: isRegistered } = useIsRegistered({ user });

usePause()

function usePause(options?): UseMutationResult<..., ..., ...>;

Defined in: fhe-disperse/react/usePause.ts:22

Admin: pause all disperse operations on the singleton. Requires PAUSER_ROLE.

After success, invalidate useIsPaused.

Parameters

ParameterType
optionsDisperseHookOptions

Returns

UseMutationResult<..., ..., ...>

Example

const pause = usePause();
pause.mutate({});

usePredictWallets()

function usePredictWallets(args?): UseQueryResult<..., ...>;

Defined in: fhe-disperse/react/usePredictWallets.ts:22

Deterministically predict the wallet addresses a user would get after calling register(), without requiring the user to be registered.

Use this to compute the addresses that need ERC-7984 operator approval before the user calls register() — set approvals on the predicted addresses first so the first disperse works without a follow-up tx.

Parameters

ParameterType
argsUsePredictWalletsArgs

Returns

UseQueryResult<..., ...>

Example

const { data: predicted } = usePredictWallets({ user });

usePreflightDisperse()

function usePreflightDisperse(args?): UseQueryResult<..., ...>;

Defined in: fhe-disperse/react/usePreflightDisperse.ts:40

Comprehensive pre-flight report — one call gives a UI everything it needs to render a "ready to disperse" checklist: registration state, wallet approvals, fee preview, batch-limit check, per-recipient validation, pre-computed wallet-mode subtotals, and a ready flag plus structured blockers list.

Hook is disabled until user, token, recipients, amounts, and mode are all set.

For live dashboards, set refetchInterval so the report stays current as the user toggles approvals in a wallet UI:

const preflight = usePreflightDisperse({ user, token, recipients, amounts, mode });
// pass through TanStack Query options via queryClient.setQueryDefaults or a
// wrapping useQuery, e.g. refetchInterval: 5_000.

Parameters

ParameterType
argsUsePreflightDisperseArgs

Returns

UseQueryResult<..., ...>

Example

const { data: report } = usePreflightDisperse({
user, token, recipients, amounts, mode: "direct",
});
if (report?.ready) { /* enable submit */ }

useRecoverERC20FromWallets()

function useRecoverERC20FromWallets(options?): UseMutationResult<..., ..., ...>;

Defined in: fhe-disperse/react/useRecoverERC20FromWallets.ts:25

Recover ERC-20 tokens accidentally sent to the caller's registered wallets. Mirrors useRecoverFromWallets but for plain (non-confidential) ERC-20 balances stranded in the subwallets.

Parameters

ParameterType
optionsDisperseHookOptions

Returns

UseMutationResult<..., ..., ...>

Example

const recover = useRecoverERC20FromWallets();
recover.mutate({ token, to: address });

useRecoverFromWallets()

function useRecoverFromWallets(options?): UseMutationResult<..., ..., ...>;

Defined in: fhe-disperse/react/useRecoverFromWallets.ts:25

Recover residual confidential ERC-7984 tokens from the caller's registered wallets to to. Useful after a wallet-mode disperse where subtotals were inflated and tokens remain locked in the subwallets.

Parameters

ParameterType
optionsDisperseHookOptions

Returns

UseMutationResult<..., ..., ...>

Example

const recover = useRecoverFromWallets();
recover.mutate({ token, to: address });

useRegister()

function useRegister(options?): UseMutationResult<..., ..., ...>;

Defined in: fhe-disperse/react/useRegister.ts:44

Deploy the caller's dedicated wallet pair via register(token) and parse the resulting UserRegistered event to return both subwallet addresses.

Can only be called once per user — subsequent calls revert with UserAlreadyRegistered. Use useIsRegistered to gate this in your UI.

Throws DisperseSubwalletNotFoundError if the receipt has no UserRegistered event from the singleton — typically means the tx reverted silently or you're reading the wrong singleton address.

After success, invalidate every disperse query for this user:

const queryClient = useQueryClient();
const register = useRegister();
register.mutate({ token }, {
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ["tokenops-sdk", "fhe-disperse"] });
},
});

Parameters

ParameterType
optionsDisperseHookOptions

Returns

UseMutationResult<..., ..., ...>

Example

const register = useRegister();
register.mutate({ token });
// register.data → { hash, wallets: [wallet0, wallet1] }

useRescueConfidentialTokens()

function useRescueConfidentialTokens(options?): UseMutationResult<..., ..., ...>;

Defined in: fhe-disperse/react/useRescueConfidentialTokens.ts:25

Admin: rescue accidentally-sent ERC-7984 confidential tokens from the singleton contract itself (NOT the per-user subwallets — for those, use useRecoverFromWallets). Requires WITHDRAWER_ROLE.

Parameters

ParameterType
optionsDisperseHookOptions

Returns

UseMutationResult<..., ..., ...>

Example

const rescue = useRescueConfidentialTokens();
rescue.mutate({ token, to: treasury });

useRescueERC20()

function useRescueERC20(options?): UseMutationResult<..., ..., ...>;

Defined in: fhe-disperse/react/useRescueERC20.ts:25

Admin: rescue accidentally-sent ERC-20 tokens from the singleton contract itself (NOT the per-user subwallets — for those, use useRecoverERC20FromWallets). Requires WITHDRAWER_ROLE.

Parameters

ParameterType
optionsDisperseHookOptions

Returns

UseMutationResult<..., ..., ...>

Example

const rescue = useRescueERC20();
rescue.mutate({ token, to: treasury });

useRevokeRole()

function useRevokeRole(options?): UseMutationResult<..., ..., ...>;

Defined in: fhe-disperse/react/useRevokeRole.ts:28

AccessControl: revoke role from accountTarget on the singleton. Caller must hold the role's admin role (typically DEFAULT_ADMIN_ROLE, i.e. the all-zero hash). Non-zero role hashes are keccak256(toBytes("<NAME>")).

After success, invalidate useHasRole({ role, account: accountTarget }).

Parameters

ParameterType
optionsDisperseHookOptions

Returns

UseMutationResult<..., ..., ...>

Example

import { keccak256, toBytes } from "viem";
const FEE_MANAGER_ROLE = keccak256(toBytes("FEE_MANAGER_ROLE"));
const revoke = useRevokeRole();
revoke.mutate({ role: FEE_MANAGER_ROLE, accountTarget: opsAddress });

useRevokeTokenOnWallets()

function useRevokeTokenOnWallets(options?): UseMutationResult<..., ..., ...>;

Defined in: fhe-disperse/react/useRevokeTokenOnWallets.ts:28

Revoke the operator approval on token for the caller's registered wallets. Re-approve later with useApproveTokenOnWallets.

Prerequisite: the caller must already be registered via useRegister.

After success, invalidate useHasApprovedSubwallets({ user, token }).

Parameters

ParameterType
optionsDisperseHookOptions

Returns

UseMutationResult<..., ..., ...>

Example

const revoke = useRevokeTokenOnWallets();
revoke.mutate({ token });

useSetCustomFee()

function useSetCustomFee(options?): UseMutationResult<..., ..., ...>;

Defined in: fhe-disperse/react/useSetCustomFee.ts:28

Admin: install a per-user fee override (gas fee in wei, token fee in BPS). Takes precedence over the global defaultGasFee / defaultTokenFee for the targeted user. Requires FEE_MANAGER_ROLE.

After success, invalidate useGetFees({ user }).

Parameters

ParameterType
optionsDisperseHookOptions

Returns

UseMutationResult<..., ..., ...>

Example

const setCustomFee = useSetCustomFee();
setCustomFee.mutate({ user, gasFee: 5_000_000_000_000_000n, tokenFee: 25 });

useSetFeeConfig()

function useSetFeeConfig(options?): UseMutationResult<..., ..., ...>;

Defined in: fhe-disperse/react/useSetFeeConfig.ts:27

Admin: update the global fee configuration — enable/disable gas and token fees, set the defaults. Requires FEE_MANAGER_ROLE.

After success, invalidate useGetFees for every user and any UI panels showing the global config.

Parameters

ParameterType
optionsDisperseHookOptions

Returns

UseMutationResult<..., ..., ...>

Example

const setFeeConfig = useSetFeeConfig();
setFeeConfig.mutate({
config: { gasFeeEnabled: true, tokenFeeEnabled: false, defaultGasFee: 10_000_000_000_000_000n, defaultTokenFee: 0 },
});

useSetMaxBatchSizeDirect()

function useSetMaxBatchSizeDirect(options?): UseMutationResult<..., ..., ...>;

Defined in: fhe-disperse/react/useSetMaxBatchSizeDirect.ts:24

Admin: set the maximum batch size for "direct" mode disperses. 0n = no limit. Requires DEFAULT_ADMIN_ROLE.

After success, invalidate useGetBatchLimits.

Parameters

ParameterType
optionsDisperseHookOptions

Returns

UseMutationResult<..., ..., ...>

Example

const setLimit = useSetMaxBatchSizeDirect();
setLimit.mutate({ size: 128n });

useSetMaxBatchSizeHolding()

function useSetMaxBatchSizeHolding(options?): UseMutationResult<..., ..., ...>;

Defined in: fhe-disperse/react/useSetMaxBatchSizeHolding.ts:24

Admin: set the maximum batch size for "wallet" mode disperses. 0n = no limit. Requires DEFAULT_ADMIN_ROLE.

After success, invalidate useGetBatchLimits.

Parameters

ParameterType
optionsDisperseHookOptions

Returns

UseMutationResult<..., ..., ...>

Example

const setLimit = useSetMaxBatchSizeHolding();
setLimit.mutate({ size: 256n });

useSetMaxBatchSizeTokenFee()

function useSetMaxBatchSizeTokenFee(options?): UseMutationResult<..., ..., ...>;

Defined in: fhe-disperse/react/useSetMaxBatchSizeTokenFee.ts:24

Admin: set the maximum batch size for "wallet-token-fee" mode disperses. 0n = no limit. Requires DEFAULT_ADMIN_ROLE.

After success, invalidate useGetBatchLimits.

Parameters

ParameterType
optionsDisperseHookOptions

Returns

UseMutationResult<..., ..., ...>

Example

const setLimit = useSetMaxBatchSizeTokenFee();
setLimit.mutate({ size: 64n });

useUnpause()

function useUnpause(options?): UseMutationResult<..., ..., ...>;

Defined in: fhe-disperse/react/useUnpause.ts:21

Admin: unpause the singleton. Requires PAUSER_ROLE.

After success, invalidate useIsPaused.

Parameters

ParameterType
optionsDisperseHookOptions

Returns

UseMutationResult<..., ..., ...>

Example

const unpause = useUnpause();
unpause.mutate({});

useWalletImplementation()

function useWalletImplementation(options?): UseQueryResult<..., ...>;

Defined in: fhe-disperse/react/useWalletImplementation.ts:14

Read the WALLET_IMPLEMENTATION address — the singleton clones this deterministically (Clones.cloneDeterministic) for each registered user to derive their wallet pair.

Parameters

ParameterType
optionsBaseHookOptions

Returns

UseQueryResult<..., ...>

Example

const { data: impl } = useWalletImplementation();

useWithdrawGasFee()

function useWithdrawGasFee(options?): UseMutationResult<..., ..., ...>;

Defined in: fhe-disperse/react/useWithdrawGasFee.ts:30

Fee-collector: withdraw amount wei of accumulated ETH gas fees from the singleton to to. There is no "drain" sentinel — amount: 0n is a no-op that emits a zero-value GasFeeWithdrawn event. Requires FEE_COLLECTOR_ROLE.

Parameters

ParameterType
optionsDisperseHookOptions

Returns

UseMutationResult<..., ..., ...>

Example

const withdraw = useWithdrawGasFee();
withdraw.mutate({ to: collectorAddress, amount: 0n });

useWithdrawTokenFee()

function useWithdrawTokenFee(options?): UseMutationResult<..., ..., ...>;

Defined in: fhe-disperse/react/useWithdrawTokenFee.ts:78

Fee-collector: withdraw accumulated encrypted token fees. Pass either a plaintext amount (SDK encrypts) or a pre-encrypted encryptedInput — never both. The contract caps the withdrawal at the available reserve via FHE.min.

Returns { hash, transferredHandle } parsed from the TokenFeeWithdrawn event. The handle is decryptable by the caller via Zama's userDecrypt and reveals the actual transferred amount, which may be less than the requested amount when the reserve was lower.

Encryptor resolution (plaintext path only). Pass encryptor per-call, or supply it at hook construction via DisperseHookOptions.encryptor. If neither is present, the SDK throws Missing encryptor — pass encryptor… verbatim.

Requires FEE_COLLECTOR_ROLE.

Parameters

ParameterType
optionsDisperseHookOptions

Returns

UseMutationResult<..., ..., ...>

Examples

function Component() {
const zamaSDK = useZamaSDK();
const withdraw = useWithdrawTokenFee({ encryptor: () => zamaSDK.relayer });
withdraw.mutate({ token, to: collector, amount: 1_000_000n });
}
// Pre-encrypted path — no encryptor needed at call time.
withdraw.mutate({ token, to: collector, encryptedInput });