ReaduseQuery Curated

useAirdropIsSignatureValid

Off-chain check of the signature shape before paying gas to submit it.

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

Description

Check whether an admin-issued claim authorization is valid for a specific caller, without consuming it.

The query has two distinct failure shapes that must be handled separately:

- data === false: the signature is structurally valid but fails the on-chain check — already claimed, claim window inactive, or signer lacks DEFAULT_ADMIN_ROLE. - error?.code === "TOKENOPS_INVALID_SIGNATURE": the signature bytes are structurally malformed (wrong length, invalid s-value range, unparseable). The on-chain ECDSA.recover reverts before the boolean logic runs, so this shows up on error, not on data.

const sig = useAirdropIsSignatureValid({ address, encryptedAmountHandle, signature, caller });
if (sig.error?.code === "TOKENOPS_INVALID_SIGNATURE") {
  // malformed signature bytes
} else if (sig.data === false) {
  // wrong signer, already claimed, or window closed
} else if (sig.data === true) {
  // ready to claim
}

The result is caller-specific (the on-chain check binds to msg.sender). caller defaults to the connected wallet; the query stays disabled until a caller is available, and the caller is part of the query key so cached results don't bleed across account switches.

Use this to show a pre-claim validation state in the UI before asking the user to pay gas.

Signature

@tokenops/sdk/fhe-airdrop/react
ts
function useAirdropIsSignatureValid(args: UseAirdropIsSignatureValidArgs): UseQueryResult<boolean, Error>;

Parameters

Shape of the options object passed to the hook itself.

PropertyTypeDescription
encryptedAmountHandleHexexternalEuint64 handle (as Hex) from the claim payload.
signatureHexEIP-712 admin signature over Claim(address recipient, bytes32 encryptedAmount).
callerAddressCaller address — the contract recomputes the struct hash over (msg.sender, encryptedAmount), so validity is caller-specific. Defaults to the connected wallet via wagmi's useAccount(); pass explicitly to check on behalf of another address.
Want to run a similar shape interactively? The Playground ships 8 ready presets across vesting / airdrop / disperse — deploy a manager, create a vesting, claim, and the airdrop / disperse equivalents. The deep-link above auto-selects the closest preset to useAirdropIsSignatureValid; pick another from the dropdown if you'd rather start there.

Example

components/useAirdropIsSignatureValidExample.tsx
tsx
"use client";
import { useAirdropIsSignatureValid } from "@tokenops/sdk/fhe-airdrop/react";

export function Example() {
  const { data, isLoading } = useAirdropIsSignatureValid(/* args */);

  if (isLoading) return "loading…";
  return <pre>{JSON.stringify(data, null, 2)}</pre>;
}

Auto-generated from the hook's shape (the SDK doesn't carry a TSDoc @example here yet).

See also

Other Read hooks in airdrop: