useCalculateFee
Quote the on-chain fee config for a given disperse batch shape (count + mode).
@tokenops/sdk/fhe-disperse/react{ data, isLoading, error, refetch }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
function useCalculateFee(args?: UseCalculateFeeArgs): UseQueryResult<CalculatedFee, Error>;Parameters
Shape of the options object passed to the hook itself.
| Property | Type | Description |
|---|---|---|
| user | Address | |
| mode | DisperseMode | |
| recipients | number | |
| totalTokens | bigint | Required for "wallet-token-fee" mode. |
Example
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:
useIsRegisteredHas this deployer already called register?useGetWalletsRead the deployer's two registered subwallet addresses.useGetFeesRead consolidated fee information for user — combines per-user resolved fees (getFeeAmounts) with the global feeConfig toggles in one read.useGetFeeConfigRead the singleton's { gasFeeEnabled, tokenFeeEnabled, defaultGasFee, defaultTokenFee } fee config.