Skip to main content
Define the structure and validation for your Ability’s input parameters using Zod schemas.

Ability Input Parameters

The abilityParamsSchema defines what parameters executors must provide to your Ability. These should include parameters required for your Ability’s core functionality, and parameters required by any Vincent Policies your Ability supports.

Schema Parameters

abilityParamsSchema
ZodSchema
required
A Zod schema object that defines the structure and validation rules for your Ability’s input parameters. This schema is used to validate the abilityParams passed to both precheck and execute functions.
import { createVincentAbility } from '@lit-protocol/vincent-ability-sdk';
import { z } from 'zod';

const abilityParamsSchema = z.object({
  // Core ability parameters
  tokenAddress: z.string().regex(/^0x[a-fA-F0-9]{40}$/, "Invalid Ethereum address"),
  amountToSend: z.number().positive("Amount must be positive"),
  recipientAddress: z.string().regex(/^0x[a-fA-F0-9]{40}$/, "Invalid recipient address"),

  // Optional parameters
  gasLimit: z.number().optional(),
  customData: z.string().optional(),
});

const vincentAbility = createVincentAbility({
  // ... other configuration
  abilityParamsSchema,
});
The tokenAddress and amountToSend parameters serve dual purposes: they’re used by your Ability to execute the transfer, and they’re also mapped to a spending limit Policy if supported. See Supporting Policies for parameter mapping details.

Schema Validation Tips

Use Descriptive Validation

Add custom error messages to help developers understand requirements

Consider Policy Needs

Include parameters required by your supported Policies

Common Validation Patterns

  • Ethereum Addresses
  • Token Amounts
address: z.string().regex(/^0x[a-fA-F0-9]{40}$/, "Invalid Ethereum address")

Best Practices

  1. Keep It Simple - Only require parameters you actually need for execution
  2. Provide Clear Errors - Use custom error messages that help developers fix issues
  3. Consider Future Needs - Make optional parameters for features you might add later
  4. Document Complex Logic - Use comments to explain conditional validation rules

Next Steps

I