Skip to main content
Add Vincent Policy support to your Ability by creating policy objects with parameter mappings.
Supporting a Policy doesn’t make it required - App Users choose which Policies to enable.

Policy Configuration

createVincentAbilityPolicy
function
required
Creates a policy object that maps your Ability’s parameters to the Policy’s requirements. This allows the Policy to access and validate the necessary parameters from your Ability.
import {
  createVincentAbility,
  createVincentAbilityPolicy,
  supportedPoliciesForAbility,
} from '@lit-protocol/vincent-ability-sdk';
import { bundledVincentPolicy } from '@lit-protocol/vincent-policy-spending-limit';
import { z } from 'zod';

const abilityParamsSchema = z.object({
  tokenAddress: z.string(),
  amountToSend: z.number(),
  recipientAddress: z.string(),
});

const SpendingLimitPolicy = createVincentAbilityPolicy({
  abilityParamsSchema,
  bundledVincentPolicy,
  abilityParameterMappings: {
    tokenAddress: 'tokenAddress',
    amountToSend: 'amount',
  },
});

const vincentAbility = createVincentAbility({
  // ... other ability definitions

  abilityParamsSchema,

  supportedPolicies: supportedPoliciesForAbility([SpendingLimitPolicy]),
});

How It Works

1

Import Policy

Import bundledVincentPolicy from the Policy package (e.g., @lit-protocol/vincent-policy-spending-limit)
2

Create Mapping

Use createVincentAbilityPolicy with:
  • abilityParamsSchema: Your Ability’s parameter schema
  • bundledVincentPolicy: The imported Policy
  • abilityParameterMappings: Maps your param names to Policy param names
3

Register Policy

Add to supportedPolicies using supportedPoliciesForAbility([SpendingLimitPolicy])
The SDK handles Policy execution and evaluation automatically.

Next Steps

I