The execute function contains your Ability’s core logic and runs in the Lit Action environment with access to signing capabilities. This is where the actual work happens.
A Zod schema that defines the structure of successful execution results. Include details about the completed operation, such as transaction hashes, amounts transferred, or other relevant outcomes.
A Zod schema that defines the structure of failed execution results. Include error details to help the executor understand what went wrong, including error codes, reasons, and relevant context.
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 executeSuccessSchema: z.object({ transactionHash: z.string(), policyCommitResults: z.record(z.any()).optional(), amountTransferred: z.number().optional(), gasUsed: z.number().optional(), }),});
If any unhandled error occurs during execution, the Vincent Ability SDK automatically returns a fail result with the error message.
After your ability’s execute function successfully completes, the last step should be calling the commit functions for any supported Vincent Policies that have them. These commit functions allow policies to update their internal state based on what actions your ability performed.
Your ability’s execute function should always call the commit functions for any supported Vincent Policies that have a commit function defined. Failing to do so could cause the Vincent Policies to operate incorrectly.
For our token transfer ability example, after successfully executing the transfer, we call the Vincent spending limit policy’s commit function to update the amount spent: