Disperse · Flows

The four disperse flows.

The singleton + per-user wallet-pair architecture collapses every disperse campaign to these four paths. Each carries the hooks, the recipe, and the story chapter that demos it end-to-end.

  1. 1

    Register (one-time per user)

    Operator calls register(token) on the disperse singleton. Singleton deploys a deterministic wallet pair (wallet0 + wallet1) via CREATE2: predictable addresses, no per-recipient deploy.

    1. useRegister({ token }) — submits the registration tx
    2. Singleton clones WALLET_IMPLEMENTATION twice (wallet0 + wallet1) under deterministic salts
    3. useGetWallets({ user }) returns the deployed pair
  2. 2

    Approve the wallet pair

    ERC-7984 operator authorization is the pre-step for any flow that pulls funds. register() approves the pair for its token; wallet-mode disperses pull the batch through wallet0/wallet1 at send time.

    1. setOperator (re-exported from @tokenops/sdk/fhe-disperse) for ERC-7984 operator grants
    2. useApproveTokenOnWallets({ token }) approves the registered pair for additional tokens
    3. Verify with useHasApprovedSubwallets({ user, token })
  3. 3

    Disperse to N recipients

    One call, N transfers. SDK builds the encrypted batch input proof; singleton verifies + atomically transfers to every recipient, splitting wallet-mode batches across wallet0/wallet1.

    1. usePreflightDisperse({ user, token, recipients, amounts, mode }) returns the full PreflightReport
    2. useDisperse.mutate({ token, mode, recipients, amounts }) encrypts the batch in one input proof, submits
    3. Receipt's WalletDistribution / DirectDistribution events list per-recipient handles
  4. 4

    Recover + fee management

    Pull funds back from a subwallet after a campaign closes; admin pause/unpause; fee withdrawal.

    1. useRecoverFromWallets({ token, to }) returns residual balance to your EOA
    2. Fee-collector flow: useWithdrawTokenFee / useWithdrawGasFee
    3. usePause / useUnpause for incident response