useCreateAndFundConfidentialAirdrop
Single-flow helper: deploy + fund in one bundle.
@tokenops/sdk/fhe-airdrop/react{ mutate, mutateAsync, isPending, error, data }Description
Deploy AND fund a new airdrop clone in a single transaction. The SDK
encrypts the plaintext amount into an externalEuint64 and submits it
with an input proof — callers never handle ciphertext.
Encryptor resolution. The hook-level encryptor (from
FactoryHookOptions) is forwarded lazily to the SDK client. You can
also pass encryptor per-mutation via args.encryptor to override it. If
neither is present, the SDK throws Missing encryptor — pass encryptor…
verbatim.
Prerequisites: caller must have set the factory as an operator on the
token: token.setOperator(factoryAddress, deadline).
After success, invalidate factory queries that depend on per-creator state:
function Component() {
const queryClient = useQueryClient();
const zamaSDK = useZamaSDK();
const create = useCreateAndFundConfidentialAirdrop({ encryptor: () => zamaSDK.relayer });
create.mutate(args, {
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ["tokenops-sdk", "fhe-airdrop"] });
},
});
}Signature
function useCreateAndFundConfidentialAirdrop(options?: FactoryHookOptions): UseMutationResult<CreateAirdropResult, Error, CreateAndFundAirdropArgs>;Parameters
Shape of the object you pass to .mutate(args) is the SDK type CreateAndFundAirdropArgs. Inspect the type for the full shape (discriminated unions collapse to a tagged variant at call time).
Example
"use client";
import { useCreateAndFundConfidentialAirdrop } from "@tokenops/sdk/fhe-airdrop/react";
export function Example() {
const { mutate, isPending } = useCreateAndFundConfidentialAirdrop();
return (
<button disabled={isPending} onClick={() => mutate(/* args */)}>
{isPending ? "Sending…" : "CreateAndFundConfidentialAirdrop"}
</button>
);
}Auto-generated from the hook's shape (the SDK doesn't carry a TSDoc @example here yet).
Errors
This mutation can reject with SDK-level, product-level, or viem-passthrough errors. Product classes carry the offending value as fields — render them inline instead of a generic "transaction failed." See Airdrop › Errors for the per-class recovery table.
Invalidation recipe
After this mutation succeeds, invalidate the queries it affects so consumer UI re-fetches fresh state. The SDK never auto-invalidates — that's a consumer decision (different apps cache different shapes).
import { useQueryClient } from "@tanstack/react-query";
const queryClient = useQueryClient();
const createAndFundConfidentialAirdrop = useCreateAndFundConfidentialAirdrop(/* options */);
createAndFundConfidentialAirdrop.mutate(args, {
onSuccess() {
// Coarse invalidation: refresh every cached read on this product surface.
queryClient.invalidateQueries({
queryKey: ["tokenops-sdk", "fhe-airdrop"],
});
},
});See also
Other Setup · deploy hooks in airdrop:
useCreateConfidentialAirdropAndGetAddressDeploy an airdrop + wait for receipt + return the clone address.useCreateConfidentialAirdropDeploy an airdrop clone for a token + admin + claim window.useCreateAndFundConfidentialAirdropAndGetAddressSame as useCreateAndFundConfidentialAirdrop but returns the clone address.