Policies
A policy is the fundamental unit in PolicyKit. It defines a set of rules that govern which transactions a smart account is allowed to execute.Policy Structure
Every policy contains:Metadata Fields
Fail Mode
The fail mode determines behavior when off-chain evaluation is unavailable:Rules
Rules are the building blocks of policies. Each rule defines a single constraint that transactions must satisfy.On-Chain Rules
On-chain rules are evaluated directly by the EVM, making them fully trustless: Tier 1 — Stateless (no storage required):
Tier 2 — Stateful (uses on-chain storage):
Off-Chain Rules
Off-chain rules are evaluated by Lit Protocol and can access external data: Tier 3 — Off-Chain:Policy Lifecycle
1. Build
Create a policy usingPolicyBuilder:
2. Validate
PolicyKit validates policies using Zod schemas. Thebuild() method automatically validates:
- At least one rule is defined
- Rule parameters are within valid ranges
- No conflicting rules (e.g., allow and deny for the same target)
3. Deploy
Deploying a policy involves two steps:- IPFS: The full policy JSON is pinned to IPFS
- On-chain: The policy CID, encoded rules, and configuration are registered on the
PolicyEngine
4. Evaluate
When a transaction is submitted, the policy is evaluated:- On-chain rules are checked first (fast, cheap)
- Off-chain rules are checked via Lit Protocol (if any)
- Transaction is allowed only if all rules pass
5. Update
Policies can be updated by deploying a new version. The old policy CID is replaced with the new one on-chain.6. Remove
Policies can be removed from thePolicyEngine, which stops enforcement immediately.
Policy Storage
Policies are stored in two locations:IPFS (Full Policy)
The complete policy JSON is pinned to IPFS. This includes all metadata, rule definitions, and configuration. The content-addressed nature of IPFS ensures policy integrity — the CID changes if any part of the policy changes.On-Chain (Policy Reference + Rules)
ThePolicyEngine stores:
- Policy CID (
bytes32) — Reference to the full policy on IPFS - PKP Address — The Lit Protocol PKP authorized to sign attestations
- Encoded Rules — On-chain rules in a compact binary format
- Fail Mode — Whether to block or allow when Lit is unavailable
- Attestation Requirements — Whether off-chain attestation is required

