The precheck function runs locally to validate that execution won’t fail when the execute function is called. Since executing uses the Lit network (which costs time and money), precheck should validate everything possible to prevent failures.
The Vincent Ability SDK runs Policy prechecks first. Your precheck only runs if all Policies return allow.
A Zod schema that defines the structure of successful precheck results. Include details that help the executor understand why the precheck passed, such as current balances and estimated costs.
A Zod schema that defines the structure of failed precheck results. Include details that help the executor understand why the precheck failed, such as error reasons and relevant values.
Success Schema
Failure Schema
Copy
Ask AI
import { createVincentAbility } from '@lit-protocol/vincent-ability-sdk';import { z } from 'zod';const vincentAbility = createVincentAbility({ // ... other ability definitions precheckSuccessSchema: z.object({ erc20TokenBalance: z.number(), nativeTokenBalance: z.number(), estimatedGas: z.number(), }),});
If any unhandled error occurs during precheck, the Vincent Ability SDK automatically returns a fail result with the error message.