2.0 RC docsView 1.x docs
v2.0.0-rc.1 release candidate
The API is frozen and later candidates carry fixes only, except the receipt-free and Safe create surface of /fhe-airdrop, which is @beta. Published on the next dist-tag; latest stays on 1.6.0 until 2.0.0.
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.

Amount units: TokenOps confidential (ERC-7984) tokens use a 6-decimals convention (1 token = 1_000_000 base units), not the 18 decimals typical of ERC-20. Amount parameters are base units of the token's actual decimals: for the CTTT test token (6 decimals) 1_000_000n = 1 CTTT, while the transparent TTT test token uses 18 decimals. totalTokens follows this convention.

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 12 ready presets across vesting / airdrop / disperse / faucet — deploy a manager, create a vesting, claim, and run the product 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 2.0: