Skip to content

Policies (SDK)

This page is the type-level reference. For the conceptual overview, see Concepts → Policies.

Types

type SpendPolicy = {
  type: "spend";
  token: string;            // "USDC", "ETH", or contract address
  amount: number;           // Decimal in token units
  period: "daily" | "weekly" | "monthly";
};
 
type ContractPolicy = {
  type: "contract";
  whitelist: string[];      // ENS names or 0x addresses
};
 
type ExpiresPolicy = {
  type: "expires";
  at: string;               // ISO date or Unix timestamp
};
 
type RatePolicy = {
  type: "rate";
  count: number;
  period: "hourly" | "daily";
};
 
type Policy =
  | SpendPolicy
  | ContractPolicy
  | ExpiresPolicy
  | RatePolicy;

Examples

Spending limit

const policy = {
  type: "spend",
  token: "USDC",
  amount: 100,
  period: "weekly",
} satisfies Policy;

Contract whitelist

const policy = {
  type: "contract",
  whitelist: ["uniswap.eth", "0x1f9840a85d5af5bf1d1762f925bdaddc4201f984"],
} satisfies Policy;

Expiry

const policy = {
  type: "expires",
  at: "2026-08-01T00:00:00Z",
} satisfies Policy;

Rate limit

const policy = {
  type: "rate",
  count: 10,
  period: "hourly",
} satisfies Policy;

Validation

Invalid policies throw at createAgent time, before any onchain work. Common rejections:

  • amount is non-positive
  • whitelist is empty
  • at is in the past
  • period is not in the allowed enum