ReaduseQuery Curated
useCalculateFee
Quote the on-chain fee config for a given disperse batch shape (count + mode).
Import
@tokenops/sdk/fhe-disperse/reactReturn
{ data, isLoading, error, refetch }Lifecycle
ReadDescription
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.
| Property | Type | Description |
|---|---|---|
| user | Address | |
| mode | DisperseMode | |
| recipients | number | |
| totalTokens | bigint | Required for "wallet-token-fee" mode. |
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:
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.