Skip to main content

SDK Overview

The @policy-kit/sdk package is the primary interface for building, deploying, and managing policies. It provides a collection of clients and utilities that work together.

Package Exports

import {
  // Builders
  PolicyBuilder,

  // High-level client
  PolicyKit,

  // Low-level clients
  PolicyEngineClient,
  IPFSClient,
  LitClient,

  // Testing
  PolicySimulator,

  // Encoding
  PolicyEncoder,

  // Types
  Policy,
  OnChainRule,
  OffChainRule,
  FailMode,
  RuleType,
  EvaluationReport,
} from "@policy-kit/sdk";

Components

PolicyBuilder

Fluent API for constructing policies with compile-time validation.

PolicyKit Client

High-level client that orchestrates deployment and management.

Policy Simulator

Local evaluation engine for testing policies without deploying.

IPFS Client

Pin and retrieve policy documents from IPFS.

Lit Client

Integration with Lit Protocol for off-chain rule evaluation.

Quick Reference

Building a Policy

import { PolicyBuilder } from "@policy-kit/sdk";

const policy = new PolicyBuilder("my-policy")
  .allowTargets(["0x..."])
  .maxValue(parseEther("1"))
  .setFailMode("closed")
  .build();

Deploying a Policy

import { PolicyKit } from "@policy-kit/sdk";

const pk = new PolicyKit({ publicClient, walletClient, engineAddress, ipfsBackends });
const result = await pk.deployPolicy(policy);

Simulating a Transaction

import { PolicySimulator } from "@policy-kit/sdk";

const simulator = new PolicySimulator();
const report = await simulator.evaluate(policy, txParams);

Dependencies

DependencyPurpose
viemEthereum client, ABI encoding, type utilities
zodRuntime schema validation for policies
@lit-protocol/*Lit Protocol integration (peer dependency)