smartpolicy
v0.2.0Runtime authorization for AI agents and smart contracts via an immutable on-chain policy registry
These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.
policy_check
THE canonical SmartPolicy question: may `subject` perform `action` under policy `policyId`? Returns allowed (boolean) plus the reasons. Maps 1:1 to PolicyRegistry.isAllowed — a protected contract gives the identical answer on-chain. Free.
| Parameter | Type | Description |
|---|---|---|
action * | string | Action name (e.g. "withdraw") or 0x-prefixed bytes32. Names are keccak256-hashed, matching keccak256("withdraw") in the protected contract. |
policyId * | Policy ID as decimal string or integer | |
subject * | string |
policy_get
Read a policy: owner, expiry, active/locked state, membership mode, member count, metadata URI. Free.
| Parameter | Type | Description |
|---|---|---|
policyId * | Policy ID as decimal string or integer |
grant_issue
Issue a short-lived single-use EIP-712 grant authorizing `subject` to perform `action` under `policyId`, redeemable ONLY at the `target` contract. The subject must pass policy_check first; the policy must list this server's issuer address (grant_issuer_info) via addIssuer. Pass the result to target's PolicyGate.withGrant function. Verify with grant_verify before broadcasting.
| Parameter | Type | Description |
|---|---|---|
action * | string | Action name (e.g. "withdraw") or 0x-prefixed bytes32. Names are keccak256-hashed, matching keccak256("withdraw") in the protected contract. |
policyId * | Policy ID as decimal string or integer | |
subject * | string | |
target * | the contract that will consume the grant (the integrator/gate); only it may redeem | |
context | string | Optional bytes32 binding the gated call's parameters. Set to keccak256(abi.encode(...)) of the exact parameters the caller must use (e.g. the recipient and amount for a transfer); the on-chain gate re… |
ttlSeconds | integer | Requested grant lifetime in seconds; clamped to the server's maxGrantTtlSeconds (see grant_issuer_info) |
grant_issuer_info
This server's grant-issuer address (authorize it on a policy via addIssuer) and limits.
policy_fees
Current protocol fees in wei (read live). createPolicy needs exactly creationFee as msg.value; every other write needs exactly updateFee. Read this before building any write tx — wrong value reverts.
grant_verify
Pre-flight a grant before broadcasting: checks the on-chain GrantVerifier for validity (signature, validity window, issuer authorization, policy active) and whether the nonce is already used. Returns {valid, nonceUsed}. Note: does NOT check subject==caller or target — the gate enforces those on redemption.
| Parameter | Type | Description |
|---|---|---|
grant * | object | the grant object exactly as returned by grant_issue |
signature * | string |
policy_create
Build the unsigned transaction that creates a new policy. Returns {to, value, data} for YOUR wallet to sign and submit — the submitting address becomes the policy owner. `value` is the protocol creation fee in wei.
| Parameter | Type | Description |
|---|---|---|
expiresAt | integer | unix seconds; 0 = never expires |
metadataHash | string | optional keccak256 of the metadata document — on-chain tamper-evidence for the URI's content |
metadataURI | string | optional metadata pointer, informational only; prefer ipfs:// (content-immutable) |
openMembership | boolean | true: every address counts as a member |
transferable | boolean | true: ownership can be transferred later |
policy_update
Build the unsigned transaction for a policy rule change (submit from the owner or an admin wallet; `value` is the protocol update fee in wei). Operations: addMembers, removeMembers, setActionRule (UNSET|MEMBERS|ANYONE|NOBODY), addIssuer, removeIssuer, addAdmin, removeAdmin, setExpiry.
| Parameter | Type | Description |
|---|---|---|
operation * | ||
policyId * | Policy ID as decimal string or integer |