Skip to main content

PolicyKit

PolicyKit is a decentralized policies-as-code SDK that enables composable, enforceable policies for smart account transactions. It supports both on-chain and off-chain evaluation, giving developers a powerful framework to define and enforce transaction rules.

Why PolicyKit?

Smart accounts and AI agents need guardrails. Whether you’re building a DeFi application, a DAO treasury, or an AI-powered wallet, you need a way to enforce rules on transactions before they execute. PolicyKit provides:

Policies as Code

Define policies programmatically using a fluent TypeScript API. Version control, test, and deploy policies like any other code.

Three-Tier Evaluation

On-chain stateless rules, on-chain stateful rules, and off-chain rules via Lit Protocol for maximum flexibility.

Non-Custodial

Account owners maintain full control. Policies are enforced without requiring custody of private keys.

ERC-7579 Compatible

Integrates seamlessly with the smart account module standard for broad wallet compatibility.

How It Works

  1. Define policies using the PolicyBuilder fluent API
  2. Store policies on IPFS for decentralized, tamper-proof storage
  3. Deploy on-chain rules to the PolicyEngine smart contract
  4. Evaluate transactions against your policy — on-chain and off-chain
  5. Enforce rules automatically before transactions execute

Quick Example

import { PolicyBuilder } from "@policykit/sdk";
import { parseEther } from "viem";

const policy = new PolicyBuilder("my-treasury-policy")
  .allowTargets(["0xUniswapRouter", "0xAavePool"])
  .maxValue(parseEther("10"))
  .spendLimit("0xUSDC", parseEther("50000"), 86400) // 50k USDC per day
  .cooldown(300) // 5 min between transactions
  .maxSlippageBps(50) // 0.5% max slippage
  .requireSimulation(true)
  .setFailMode("closed")
  .build();

Packages

PackageDescription
@policykit/sdkCore TypeScript SDK with PolicyBuilder, clients, and utilities
@policykit/cliCommand-line tool for policy management
@policykit/contractsSolidity smart contracts for on-chain enforcement
@policykit/lit-actionsLit Protocol actions for off-chain evaluation

Get Started