Skip to main content

SDK Overview

The @policykit/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 "@policykit/sdk";

Components

Quick Reference

Building a Policy

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

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

Deploying a Policy

import { PolicyKit } from "@policykit/sdk";

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

Simulating a Transaction

import { PolicySimulator } from "@policykit/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)