Policy-Enforced Agent Accounts
A draft ERC, with a live reference implementation: anyone can check from the chain alone whether an agent's account is protected by a policy signer, which policy is active, why something was refused, and whether a decision receipt is genuine.
Why
Apps, wallets, lenders and marketplaces that deal with an agent have no common way to see whether its account is protected, what limits apply, or whether a looser policy is about to take effect. This standard is a read and evidence layer on top of whatever enforces: an external co-signer like Palisec, an account module, a guard. It does not define how a policy is evaluated.
Reference implementation (live)
| Registry (mainnet 4663) | 0x20D6B38B47F7cb765A2318a1f318ed54a6f87e92 · source verified, no owner, no upgrade path, holds no funds |
| ERC-165 interface id | 0xcc16d336 |
| Deployment | Deterministic deployer 0x4e59b448…956C, salt keccak256("policy-enforced-accounts registry v1") |
| Demo account | 0x9aEC761B2F0FdA08C683e8388478C9A2F7C9170c (Palisec smart account, holder mandate) |
| Client library | policy-enforced-accounts (TypeScript, viem; CC0) |
| Test vectors | vectors.json, checked in TypeScript and Solidity |
| Independent read test | independent-read.mjs: no Palisec API, no keys |
Interface
A reader calls supportsInterface(0xcc16d336) on the account. If the account does not serve the interface, the reader asks the registry. Existing accounts such as Safes opt in by calling declare(policySigner, publisher, receiptSigner) themselves. After that, only their declared publisher can post their commitments, and nobody can write another account's data.
IPolicyEnforcedAccount.sol
interface IPolicyEnforcedAccount { // ERC-165 id 0xcc16d336
struct Signers { address policySigner; address publisher; address receiptSigner; uint64 since; }
struct PolicyCommitment { bytes32 policyHash; uint64 version; uint64 effectiveAt; string policyURI; string schemaURI; }
function policySigner(address account) external view returns (Signers memory);
function signersAt(address account, uint64 timestamp) external view returns (Signers memory);
function policyOf(address account) external view returns (PolicyCommitment memory);
function pendingPolicyOf(address account) external view returns (bool exists, PolicyCommitment memory);
function mandateOf(address account) external view returns (string memory mandateURI, bytes32 configHash);
function isStopped(address account) external view returns (bool);
event SignersDeclared(address indexed account, address policySigner, address publisher, address receiptSigner);
event PolicyActivated(address indexed account, bytes32 indexed policyHash, uint64 version, uint64 effectiveAt, string policyURI, string schemaURI);
event PolicyPending(address indexed account, bytes32 indexed policyHash, uint64 version, uint64 effectiveAt, string policyURI, string schemaURI);
event PolicyCancelled(address indexed account, bytes32 indexed policyHash, uint64 version, string reason);
event EmergencyStop(address indexed account, string reason);
event EmergencyStopLifted(address indexed account);
event MandateSet(address indexed account, string mandateURI, bytes32 configHash);
}- policyHash is keccak256 of the policy document's RFC 8785 canonical JSON. If
policyURIis set, anyone can fetch the document and check it. - A pending loosening is public with its
effectiveAt, and the registry switches to it by time alone, so readers are right even if the publisher is late. - Publisher and receipt keys are separate from the co-signer: neither can move funds.
Reason codes
ASCII identifiers right-padded to bytes32. The list is append-only, and an identifier is never reused. Vendor codes go in a separate detailCode, for example palisec:PS_BUDGET_001.
| Code | Meaning |
|---|---|
TARGET_NOT_ALLOWED | The target address is not allowed by the policy. |
METHOD_NOT_ALLOWED | The function (selector) is not allowed on this target. |
DENY_RULE | An explicit deny rule matched. |
OVER_TX_CAP | The transaction exceeds the per-transaction cap. |
OVER_BUDGET | The transaction exceeds the rolling or cumulative budget. |
OVER_LIMIT | A value limit (per-transaction or budget) is exceeded; the enforcer does not distinguish which. |
RATE_LIMITED | Too many requests in the policy's window. |
COOLDOWN_OR_LOOP | The same intent or calldata was repeated within the cooldown. |
REPLAY | The request or authorization was already used, or has expired. |
PAUSED | The agent or account is paused, or the emergency stop is engaged. |
HUMAN_APPROVAL_REQUIRED | A human approver must approve this exact operation first. |
ASSET_UNSAFE | Simulation shows an unsafe asset outcome (honeypot, tax, unexpected balance change). |
APPROVAL_RISK | An unlimited or oversized token approval to a spender that is not allowed. |
SIMULATION_UNAVAILABLE | The required simulation could not run. |
FEE_UNAVAILABLE | The fee could not be estimated or is invalid. |
POLICY_UNAVAILABLE | No valid active policy. |
STATE_UNAVAILABLE | The enforcer's authoritative state could not be read. |
DEPENDENCY_UNAVAILABLE | An external dependency the policy requires could not be read. |
NOT_RECOVERABLE | The policy requires a recovery setup the account does not meet. |
WRONG_CHAIN | The chain or its infrastructure is not available for this request. |
ATTESTATION_FAILED | The signer's attestation could not be verified. |
UNAUTHORIZED | The requester is not authenticated or not allowed to ask. |
INVALID_REQUEST | The request is malformed. |
OTHER | Another reason; see the detail code. |
Decision receipts
Every recorded Palisec decision for an opted-in account returns a receipt field (dry runs do not): an EIP-712 signature by the account's declared receipt signer, bound to the exact intent, the policy hash and an expiry. Verify it against the registry, not against Palisec.
Receipt (EIP-712)
EIP712Domain { name: "PolicyDecisionReceipt", version: "1", chainId, verifyingContract: <registry> }
Decision(address account, bytes32 intentHash, uint8 decision, bytes32 reasonCode, bytes32 detailCode,
bytes32 policyHash, uint64 policyVersion, uint64 issuedAt, uint64 expiresAt, bytes32 decisionId)
decision: 0 ALLOW · 1 DENY · 2 REVIEW
intentHash = keccak256(abi.encode(
keccak256("Intent(uint256 chainId,address account,address target,uint256 value,bytes32 dataHash)"),
chainId, account, target, value, keccak256(data)))Read any account
read.mjs
npm install policy-enforced-accounts viem
import { createPublicClient, http } from "viem";
import { REGISTRY_ADDRESSES, fetchPolicy, readAccount, verifyReceipt } from "policy-enforced-accounts";
const client = createPublicClient({ transport: http("https://rpc.mainnet.chain.robinhood.com") });
const s = await readAccount(client, "0x9aEC761B2F0FdA08C683e8388478C9A2F7C9170c", REGISTRY_ADDRESSES[4663]);
console.log(s.enforced, s.policySigner, s.policy?.policyHash, s.pending?.effectiveAt);
console.log((await fetchPolicy(s.policy)).matches); // the document matches the on-chain hash
console.log((await verifyReceipt(client, receipt)).valid); // a decision receipt, checked against the chain