ReaduseQuery Curated

useCalculateFee

Quote the on-chain fee config for a given disperse batch shape (count + mode).

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

Description

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.

Signature

@tokenops/sdk/fhe-disperse/react
ts
function useCalculateFee(args?: UseCalculateFeeArgs): UseQueryResult<CalculatedFee, Error>;

Parameters

Shape of the options object passed to the hook itself.

PropertyTypeDescription
userAddress
modeDisperseMode
recipientsnumber
totalTokensbigintRequired for "wallet-token-fee" mode.
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 useCalculateFee; pick another from the dropdown if you'd rather start there.

Example

@tokenops/sdk/fhe-disperse/react · @example
tsx
const { data: fee } = useCalculateFee({
  user, mode: "direct", recipients: 100,
});

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

See also

Other Read hooks in disperse: