Recipe · Operations

Gas + custom fee plumbing

Manager clones charge either gas-side or token-side fees. ClaimArgs is a discriminated union, pass the matching branch or get ContractRevertError.

1. Resolve fee posture#

Each manager carries its own fee posture (set at factory creation or overridden via setCustomFee). Read it once per manager, the result is cacheable per-clone.

components/Claim.tsx
ts
import { useManagerFeeInfo } from "@tokenops/sdk/fhe-vesting/react";

const { data: feeInfo } = useManagerFeeInfo({ address: managerAddress });

// feeInfo → { feeType: "Gas" | "DistributionToken", fee: bigint }

2. Submit the matching branch#

Gas fees attach as value on the tx. Token fees are themselves encrypted, generate the fee handle alongside the claim amount via the encryptor.

components/Claim.tsx
ts
import { FeeType } from "@tokenops/sdk/fhe-vesting";
import { useClaim } from "@tokenops/sdk/fhe-vesting/react";

const claim = useClaim({ address: managerAddress });

claim.mutate(
  feeInfo.feeType === FeeType.Gas
    ? { kind: FeeType.Gas, vestingId, value: feeInfo.fee }
    : { kind: FeeType.DistributionToken, vestingId, encryptedFeeHandle },
);

Quote-before-claim#

Render the fee inline so users know what they're paying. The story flow on /stories/vesting demonstrates this, the claim button surfaces the cost in the same row.

See also