Skip to main content

PolicyManager

The PolicyManager class handles all agent policy operations — initialization, updates, spend tracking, whitelist construction, and policy presets.

PDA Derivation

derivePolicyAddress(owner)

Seeds: ["agent_policy", owner.toBytes()]

Fetching Policies

fetchPolicy(policyAddress)

Returns: AgentPolicyAccount | null

fetchPolicyByOwner(owner)

AgentPolicyAccount

Building Instructions

buildInitializePolicyInstruction(owner, agentSigner, config)

buildUpdatePolicyInstruction(owner, policyAddress, updates)

buildUpdateAgentSignerInstruction(owner, policyAddress, newSigner)

Rotate the agent signing key.

buildRevokeAgentAuthorityInstruction(owner, policyAddress)

Kill switch — disable the agent.

buildSetPolicyActiveInstruction(owner, policyAddress, active)

Pause or resume the agent’s policy.

buildRecordBlinkInstruction(agent, policyAddress, treasury, amount, recipient, reason)

Record a Blink generation on-chain.

Spend Tracking

getCurrentSpend(policyAddress)

getRemainingSpendCapacity(policy)

wouldExceedSpendLimit(policy, amount)

wouldExceedTxLimit(policy, amount)

Check if a single transaction exceeds the per-transaction limit.

Whitelist Construction

buildMerkleWhitelist(addresses)

Build a Merkle tree root from a list of allowed addresses.

buildBloomWhitelist(addresses, sizeBytes?, hashCount?)

Build a Bloom filter for probabilistic whitelist checking.

buildDomainWhitelist(domains)

Build a domain-prefix whitelist.

Policy Presets

Three built-in presets for common risk profiles:
Use a preset as a starting point:
Last modified on February 8, 2026