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

usePreflightDisperse

Dry-run validator — checks operator + balance + paused state before broadcasting.

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

Description

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 and input-proof cap check, per-recipient validation, pre-computed wallet-mode subtotals, and a ready flag plus typed blockerErrors.

Hook is disabled until user, token, recipients, amounts, and mode are all 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. Pass amounts[] in the same units you will pass to useDisperse so the report reflects the real call. The query key holds a salted keccak256 digest of amounts, never the plaintext values. The salt is drawn once per page or process by design, so a key built during SSR never matches the client's and a key from a persisted cache never matches the next session's: a preflight result is not restored through hydration or a cache persister, and always runs fresh.

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,
  query: { refetchInterval: 5_000 },
});

Signature

@tokenops/sdk/fhe-disperse/react
ts
function usePreflightDisperse(args?: UsePreflightDisperseArgs): UseQueryResult<PreflightReport, Error>;

Parameters

Shape of the options object passed to the hook itself.

PropertyTypeDescription
userAddress
tokenAddress
recipientsAddress[]
amountsbigint[]
modeDisperseMode
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 usePreflightDisperse; pick another from the dropdown if you'd rather start there.

Example

@tokenops/sdk/fhe-disperse/react · @example
tsx
const { data: report } = usePreflightDisperse({
  user, token, recipients, amounts, mode: "direct",
});
if (report?.ready) { /* enable submit *\/ }

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: