Alert Source Discuss
⚠️ Draft Standards Track: ERC

ERC-8226: Regulated Agent Mandate

A compliance delegation layer for AI agents operating on tokenized regulated assets.

Authors Ludovico Rossi (@ludovicor-eth) <ludovico@brickken.com>, Dario Lo Buglio (@xaler5) <dario@brickken.com>, Thamer Dridi (@thamerdridi) <thamer@brickken.com>, Nabil El Alami Khalifi (@nabil-brickken) <nabil@brickken.com>
Created 2026-04-12
Discussion Link https://ethereum-magicians.org/t/erc-8226-regulated-agent-mandate/28208
Requires EIP-165, EIP-712, EIP-1271

Abstract

This standard defines a compliance delegation layer for AI agents operating on tokenized regulated assets. It specifies how a verified principal can delegate scoped, time-bounded, and financially limited authority to an on-chain agent, and how a regulated token, or the principal’s own account, verifies the mandate on each agent-initiated action.

Regulated Agent Mandate Standard, or RAMS, is agnostic to the agent identity system, the token standard, and the token compliance framework. It works with any agent identity system (such as ERC-8004), any token standard (ERC-20, ERC-721, ERC-1155), and any regulated token standard (such as ERC-7943 or ERC-3643).

Motivation

The market for tokenized real-world assets is entering a phase of institutional adoption. Platforms operating under regulatory frameworks are starting to support programmable, agent-driven portfolio management on regulated instruments. AI agents that can autonomously execute securities transactions are no longer theoretical; they are being built now, without a standard that makes their operation legally defensible.

An agent purchasing a tokenized fund unit on behalf of an investor must satisfy three conditions that no existing standard addresses jointly:

  1. The principal on whose behalf the agent acts must be a verified, Know Your Customer (KYC)-cleared legal identity, not merely an Ethereum address.
  2. The mandate granted to the agent must be legally traceable, time-bounded, and financially capped, analogous to a power of attorney in traditional finance.
  3. The asset contract must validate the mandate atomically at execution time, without relying on off-chain coordination.

Regulated token standards such as ERC-7943 and ERC-3643 govern who may hold or transact a token, but neither defines an agent delegation model. Agent identity standards such as ERC-8004 provide agent discovery and trust signals but no mandate framework, and general-purpose agent authorization standards do not address regulated assets. RAMS defines the delegation interface, the compliance provider model, and the integration pattern with regulated token contracts.

The compliance responsibilities across the three layers are as follows:

Layer Responsibility Standard
Token compliance Investor eligibility on this specific asset Token compliance framework (e.g., ERC-7943, ERC-3643)
Mandate compliance Agent authority from this principal for this scope This ERC
Agent identity Agent exists and is registered Agent registry (e.g., ERC-8004)

Specification

The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “NOT RECOMMENDED”, “MAY”, and “OPTIONAL” in this document are to be interpreted as described in RFC 2119 and RFC 8174.

The registry MUST implement ERC-165 and return true for the IAgentMandate interface ID, 0x5aa4c7e4. A compliance provider MUST implement ERC-165 and return true for the IComplianceProvider interface ID, 0xfa2a39b3. An IAgentExecutor does not need ERC-165.

Revert conditions in this standard are normative. Except for MandateBlocked, the error selectors that signal them are implementation-defined.

RAMS defines three interfaces. IAgentExecutor is OPTIONAL. Implementations SHOULD deploy each interface as a separate contract, so that the party behind each contract governs it independently. A single party MAY combine IComplianceProvider and IAgentMandate in one contract. An IAgentExecutor is always a separate contract, because it runs as the principal’s account or for one principal only.

Interface Role Deployed by
IComplianceProvider Verifies principal eligibility (identity + compliance) Compliance provider or platform
IAgentMandate Mandate lifecycle, execution recording, freeze, and views Registry admin
IAgentExecutor (OPTIONAL) Forwards agent calls from the principal’s account, and measures and records their flows Shared EIP-7702 delegate code, or the principal (module or standalone executor)

RAMS-aware regulated token contracts consult the RAMS registry on each function they let an agent perform for a holder. An IAgentExecutor consults it on each call it forwards.

IComplianceProvider

IComplianceProvider is implemented by a compliance provider or platform (for example, a KYC provider or an on-chain identity registry adapter). Its address is supplied by the principal at mandate grant time via the complianceProvider field of IAgentMandate.grantMandate. A single IComplianceProvider instance MAY serve multiple mandates across multiple principals.

The compliance provider manages principal eligibility: granting, revoking, and checking whether a principal is eligible.

checkPrincipal MUST return a reason code and an expiry timestamp with the eligibility result. It MUST verify that identityRef resolves to a valid, unrevoked attestation of principal, and return eligible == false if it does not.

grantPrincipal MUST emit PrincipalGranted and revokePrincipal MUST emit PrincipalRevoked, so eligibility changes are reconstructible from logs.

A principal’s compliance window is the period during which checkPrincipal reports that principal eligible, bounded by expiresAt, where expiresAt == 0 denotes an unbounded window. The registry reads expiresAt only in grantMandate and extendMandate, where it bounds validUntil under it, and does not re-read it while a mandate is live. A provider therefore SHOULD NOT shorten the compliance window of a principal that stays eligible: it SHOULD NOT move expiresAt earlier, or change it from 0 to a timestamp, because 0 means no end. It MAY extend the window. To shorten it, the provider SHOULD call revokePrincipal first and then grant again, so the change emits PrincipalRevoked and is not applied silently to mandates already granted.

A future revision of this standard adds new ReasonCode values at the end, without renumbering. OTHER is reserved for conditions not listed and MUST NOT stand in for a listed code. A provider that cannot evaluate a check MUST revert rather than return eligible == false, so a failed evaluation is never reported as ineligibility. When checkPrincipal returns eligible == true, expiresAt MUST be 0 or a timestamp that is not in the past.

interface IComplianceProvider is IERC165 {
    enum ReasonCode {
        COMPLIANT,             // 0
        KYC_EXPIRED,           // 1
        AML_FLAG,              // 2
        NOT_ACCREDITED,        // 3
        NOT_QUALIFIED,         // 4
        JURISDICTION_BLOCKED,  // 5
        IDENTITY_NOT_FOUND,    // 6
        ATTESTATION_REVOKED,   // 7
        OTHER                  // 8
    }

    /// @notice Emitted when a principal is granted eligibility.
    event PrincipalGranted(
        address indexed principal,
        bytes32 indexed identityRef
    );

    /// @notice Emitted when a previously eligible principal is revoked.
    event PrincipalRevoked(
        address indexed principal,
        bytes32 indexed identityRef,
        ReasonCode reason
    );

    /// @notice Grants eligibility to a principal.
    /// @param principal The on-chain address of the principal.
    /// @param identityRef An off-chain identity reference (e.g., keccak256 of a Decentralized Identifier (DID) or attestation ID).
    /// @param expiresAt Unix timestamp at which the eligibility ends. 0 means no expiry.
    function grantPrincipal(address principal, bytes32 identityRef, uint48 expiresAt) external;

    /// @notice Revokes a principal's eligibility.
    /// @param principal The on-chain address of the principal.
    /// @param reason The reason for revocation.
    function revokePrincipal(address principal, ReasonCode reason) external;

    /// @notice Returns eligibility of a principal.
    /// @param principal The on-chain address of the principal.
    /// @param identityRef An off-chain identity reference (e.g., keccak256 of a Decentralized Identifier (DID) or attestation ID).
    /// @return eligible True if the principal is compliant.
    /// @return reason Reason code. MUST be COMPLIANT when eligible is true.
    /// @return expiresAt Unix timestamp at which the eligibility ends. 0 means no expiry when eligible is true; when eligible is false the value carries no meaning, so consumers MUST read eligible and reason first.
    function checkPrincipal(address principal, bytes32 identityRef)
        external view returns (bool eligible, ReasonCode reason, uint48 expiresAt);
}

An IComplianceProvider implementation MAY delegate identity verification to on-chain identity standards, Ethereum Attestation Service (EAS) attestations, or any other identity backend. The interface is agnostic to the source.

IAgentMandate

IAgentMandate is implemented by the RAMS registry, a single contract deployed by a registry admin (for example, a platform or a regulated entity). Principals interact with this contract to grant, extend, and revoke mandates. Any contract in the agent’s execution path calls canExecute to verify the mandate and recordExecution to record use.

Mandate storage is keyed by (agent, principal, target). The target is the contract the agent calls: a token, a pool, a router, or any other contract. Each (agent, principal, target) triple has at most one active mandate at any given time. A mandate is active when it exists, is not revoked, and has not expired. An agent MAY hold mandates on several targets for the same principal, one per target, each with its own actions, limits, validity and revocation.

The scope of a mandate has two parts:

  1. Actions: Each action is a bytes32 label with a list of constraints. Only the actions in the mandate’s actions list can execute. Any other action fails with ACTION_NOT_ENABLED.
  2. Limits: Each limit is a budget on one asset. Its direction is OUTFLOW or INFLOW, and a mandate MAY hold one of each for the same asset. A limit has maxTransactionValue, a rate limit (capacity, refillAmount, refillPeriod and available), maxCumulativeValue and cumulativeUsed. All amounts are in the asset’s base unit, and refillPeriod is in seconds. All the actions of a mandate share its limits.

A constraint is a rule on one argument of the call:

  • index: the position of the 32-byte word after the selector. Word i starts at byte 4 + 32 * i.
  • check: EQUALS, NOT_EQUALS, AT_MOST or AT_LEAST. AT_MOST and AT_LEAST compare as uint256.
  • value: the value the word is compared with.

Every constraint of an action MUST pass, except that several EQUALS constraints on the same index form an allowlist, where one match is sufficient. A constraint MUST fail if its word is not fully inside the calldata. For a dynamic argument (bytes, string, arrays), the word holds the offset to the data, not the data.

The limits bound what the agent moves. An OUTFLOW limit caps what leaves the principal’s account. An INFLOW limit caps what enters it.

Each execution has a list of flows: (asset, direction, amount) entries. The list MUST NOT repeat the same asset and direction. For each flow:

  • An amount of 0 always passes, and needs no limit.
  • A non-zero amount MUST fail with NO_LIMIT when the mandate has no limit with the same asset and direction.
  • A non-zero amount MUST NOT exceed maxTransactionValue, and MUST NOT take cumulativeUsed above maxCumulativeValue. A cap set to type(uint256).max is not checked.
  • A non-zero amount MUST NOT exceed the current available amount of the rate limit, defined below. A capacity set to type(uint256).max is not checked.

The rate limit is a budget that refills over time. capacity is the most it holds. It refills by refillAmount every refillPeriod, in proportion to the time elapsed, and it never refills above capacity. A refillAmount of 0 means it never refills. The registry keeps a refill time for each limit, refilledAt. At time now, the current available amount is:

min(capacity, available + (now - refilledAt) * refillAmount / refillPeriod)

When refillAmount is 0 or now is not after refilledAt, it is available. This computation MUST NOT revert on overflow. A refill that does not fit in a uint256 is larger than capacity - available, so the current available amount is then capacity.

maxCumulativeValue caps the total over the life of the mandate and never refills. The rate limit caps how much moves at once and how fast it moves after that.

These checks apply to the flows that the caller passes. A token gate passes the amount of each call, so a non-zero amount on an asset with no limit fails. An executor measures only the assets that the mandate limits, so it never passes a flow for any other asset.

Amounts are in the asset’s base unit: the token amount for ERC-20 and ERC-1155, and a token count for ERC-721. RAMS limits the quantity moved, not specific token identifiers.

Freezing MUST be restricted to authorized enforcer roles defined by the implementation’s access control, and the enforcer address MUST be recorded in the AgentFrozen and PrincipalFrozen events. A freeze halts evaluation but MUST NOT revoke: revocation stays with the principal, and an enforcer MUST be able to lift a freeze it applied. freezeAgent halts every mandate held by that agent; freezePrincipal halts every mandate granted by that principal, including mandates granted while the freeze is in place, so no enumeration of the principal’s agents is required. An address that holds the admin role MUST NOT hold the enforcer role.

A principal MAY approve operators with setOperator. An approved operator has the powers of the principal over its mandates: it MAY call grantMandate, revokeMandate, extendMandate and updateRateLimit directly, or sign them. An operator MUST NOT set operators. Only the principal can approve an operator, directly or by signature. An enforcer MAY also call setOperator directly, but only to remove an operator.

recordExecution MUST only be callable by an authorized recorder: the mandate’s target, the principal’s account, or an address granted the recorder role by the implementation’s access control. Arbitrary callers MUST be rejected. When the caller is the target, it MUST pass its own address as target, so a token MUST NOT record against the mandate of another target. recordExecution MUST apply every check of canExecute, with the same data and flows, and revert with MandateBlocked(reason) if any fails, where reason is the first failing check, so a caller that relies on recordExecution alone still gets the reason. It then adds each flow to the cumulativeUsed of its limit. When the rate limit of the limit is checked, it also sets available to the current available amount minus the flow. It MUST advance refilledAt only by the time that the refilled amount represents, rounded up, so the leftover time carries over to the next call. When refillAmount is not 0, it MUST set refilledAt to the current time when the current available amount equals capacity. cumulativeUsed and the rate limit MUST NOT reset on extendMandate. cumulativeUsed sums the recorded flows, so it reflects what the recorders reported, not net tokens moved outside the recorded calls.

Revocation MUST NOT delete the mandate record: revokeMandate sets revoked to true and leaves the record in place.

Implementations and integrators MUST NOT use metadata for enforcement decisions.

grantMandate MUST emit MandateGranted, one ActionEnabled per enabled action and one LimitSet per limit, revokeMandate MUST emit MandateRevoked, extendMandate MUST emit MandateExtended, updateRateLimit MUST emit LimitSet with the limit after the update, setOperator MUST emit OperatorSet, recordExecution MUST emit one ExecutionRecorded per non-zero flow, freezeAgent and unfreezeAgent MUST emit AgentFrozen and AgentUnfrozen, and freezePrincipal and unfreezePrincipal MUST emit PrincipalFrozen and PrincipalUnfrozen. Nothing is emitted for the actions and limits a new mandate clears, so consumers reading logs MUST treat MandateGranted as resetting the actions and limits of the (agent, principal, target) triple. A LimitSet from updateRateLimit replaces the limit with the same asset and direction.

Signed lifecycle operations

grantMandate, revokeMandate, extendMandate and updateRateLimit MAY be called directly by the principal or an approved operator (msg.sender), or by any submitter providing a signature of the principal or of an approved operator over an EIP-712 typed message. setOperator accepts the same calls from the principal only. An enforcer can also call it directly, but only to remove an operator. Implementations MUST verify principal signatures using ERC-1271-compatible verification: ECDSA for an account with no code, and ERC-1271 for an account with code, such as a multisig, a DAO or an EIP-7702-delegated account. A delegated account’s code MUST implement isValidSignature for the principal to keep signing. The signed message does not name the signer, so an operator signature is verified by ECDSA recovery. An operator that is a contract calls directly.

The typed-data domain separator follows EIP-712 with name = "RAMS", version = "1", current chainId, and verifyingContract set to the RAMS registry address. Implementations MUST track a nonce per principal (nonces[principal]). Every signed operation, including one an operator signs, MUST include the current nonce, and the implementation MUST increment it when it accepts the signature. Implementations MUST revert a signed call if block.timestamp > deadline or if the signer is neither the principal nor, where allowed, an approved operator of the principal. A direct call uses no nonce and ignores deadline.

The normative EIP-712 typehashes are:

bytes32 constant GRANT_MANDATE_TYPEHASH = keccak256(
    "GrantMandate(address agent,uint48 validFrom,uint48 validUntil,"
    "address principal,address complianceProvider,bytes32 identityRef,"
    "address target,Action[] actions,Limit[] limits,bytes32 metadata,uint256 nonce,uint256 deadline)"
    "Action(bytes32 action,Constraint[] constraints)"
    "Constraint(uint8 index,uint8 check,bytes32 value)"
    "Limit(address asset,uint8 direction,uint48 refillPeriod,uint256 maxTransactionValue,uint256 capacity,"
    "uint256 refillAmount,uint256 available,uint256 maxCumulativeValue,uint256 cumulativeUsed)"
);

bytes32 constant ACTION_TYPEHASH = keccak256(
    "Action(bytes32 action,Constraint[] constraints)Constraint(uint8 index,uint8 check,bytes32 value)"
);

bytes32 constant CONSTRAINT_TYPEHASH = keccak256("Constraint(uint8 index,uint8 check,bytes32 value)");

bytes32 constant LIMIT_TYPEHASH = keccak256(
    "Limit(address asset,uint8 direction,uint48 refillPeriod,uint256 maxTransactionValue,uint256 capacity,"
    "uint256 refillAmount,uint256 available,uint256 maxCumulativeValue,uint256 cumulativeUsed)"
);

bytes32 constant REVOKE_MANDATE_TYPEHASH = keccak256(
    "RevokeMandate(address agent,address principal,address target,uint256 nonce,uint256 deadline)"
);

bytes32 constant EXTEND_MANDATE_TYPEHASH = keccak256(
    "ExtendMandate(address agent,address principal,address target,uint48 newValidUntil,uint256 nonce,uint256 deadline)"
);

bytes32 constant UPDATE_RATE_LIMIT_TYPEHASH = keccak256(
    "UpdateRateLimit(address agent,address principal,address target,address asset,uint8 direction,uint256 capacity,"
    "uint256 refillAmount,uint48 refillPeriod,uint256 nonce,uint256 deadline)"
);

bytes32 constant SET_OPERATOR_TYPEHASH = keccak256(
    "SetOperator(address principal,address operator,bool approved,uint256 nonce,uint256 deadline)"
);

Arrays of structs are hashed as EIP-712 defines: the keccak256 of the concatenated struct hashes of their elements.

grantMandate MUST revert if the (agent, principal, target) triple already has an active mandate. grantMandate MUST revert if complianceProvider is address(0), and MUST revert if complianceProvider.checkPrincipal returns eligible == false. extendMandate MUST revert if the mandate is not active, or if newValidUntil is less than or equal to the current validUntil. When checkPrincipal returns a nonzero expiresAt, grantMandate and extendMandate MUST revert if validUntil (respectively newValidUntil) is later than that expiresAt, so a mandate cannot outlive the principal’s compliance window. extendMandate MUST re-check checkPrincipal and revert if the principal is no longer eligible. grantMandate MUST revert if validUntil is not greater than validFrom, and MUST revert if validUntil is not greater than the current block timestamp, so a mandate cannot be granted already expired or permanently unusable. grantMandate MUST revert if checkPrincipal returns a nonzero expiresAt in the past. grantMandate MUST revert if any action label is bytes32(0), so an unset label cannot become an enabled action. grantMandate MUST revert if any limit has asset == address(0), if two limits have the same asset and direction, or if a limit has cumulativeUsed greater than maxCumulativeValue. grantMandate MUST revert if a limit has a non-zero refillAmount and a refillPeriod of 0, or if a limit with a checked capacity has available greater than capacity. updateRateLimit MUST revert if the mandate is not active, if the mandate has no limit with the given asset and direction, or if refillAmount is non-zero and refillPeriod is 0.

At grantMandate the implementation writes the signed actions, with their constraints, and the signed limits into storage keyed by (agent, principal, target). It MUST first clear the actions, constraints and limits of a prior mandate for the same triple. The new mandate MUST start with revoked set to false, and each limit MUST start with the signed cumulativeUsed and the signed available. The refilledAt of each limit MUST start at the later of the current block timestamp and validFrom, so the rate limit does not refill before the mandate is valid. A principal re-issuing a mandate can so carry over the budget already used; a new budget signs cumulativeUsed 0 and available equal to capacity. Enforcement then reads each action and each limit in O(1).

updateRateLimit changes only the rate limit of one limit: capacity, refillAmount and refillPeriod, and with them available and refilledAt. If the old capacity is type(uint256).max, the rate limit was not checked, and it MUST set available to the new capacity. Otherwise, it MUST compute the current available amount at the old rate, then set available to the lesser of that amount and the new capacity. It MUST set refilledAt to the later of the current block timestamp and the stored refilledAt, so the new rate does not apply to the time before the update, and the rate limit does not refill before the mandate is valid. It MUST NOT change maxTransactionValue, maxCumulativeValue or cumulativeUsed.

A mapping cannot be enumerated and events are not readable on-chain, so that clear requires the labels and limits of the current mandate to be recorded enumerably: implementations MUST keep them enumerable on-chain, for example as arrays per (agent, principal, target), as the reference implementation does.

Authorization check

canExecute MUST apply the checks below in the order shown, and return the reason of the first check that fails:

function canExecute(
    address agent,
    address principal,
    address target,
    bytes32 action,
    bytes calldata data,
    Flow[] calldata flows
) public view returns (bool ok, MandateReason reason) {
    bytes32 mandateKey = keccak256(abi.encode(agent, principal, target));
    Mandate storage mandate = mandates[mandateKey];

    // First, revert if flows repeats an asset and direction.
    if (mandate.principal == address(0))                     return (false, MandateReason.NONEXISTENT);
    if (isAgentFrozen(agent))                                return (false, MandateReason.AGENT_FROZEN);
    if (isPrincipalFrozen(principal))                        return (false, MandateReason.PRINCIPAL_FROZEN);
    if (block.timestamp < mandate.validFrom)                 return (false, MandateReason.NOT_YET_VALID);
    if (block.timestamp > mandate.validUntil)                return (false, MandateReason.EXPIRED);
    if (mandate.revoked)                                     return (false, MandateReason.REVOKED);
    if (!actionEnabled[mandateKey][action])                  return (false, MandateReason.ACTION_NOT_ENABLED);
    if (!constraintsPass(constraints[mandateKey][action], data))
                                                             return (false, MandateReason.CONSTRAINT_FAILED);

    for (uint256 index = 0; index < flows.length; index++) {
        Flow calldata flow = flows[index];
        if (flow.amount == 0) continue;
        Limit storage limit = limits[mandateKey][flow.asset][flow.direction];
        if (limit.asset == address(0))                       return (false, MandateReason.NO_LIMIT);
        if (limit.maxTransactionValue != type(uint256).max
            && flow.amount > limit.maxTransactionValue)
                                                             return (false, MandateReason.OVER_TX_CAP);
        if (limit.maxCumulativeValue != type(uint256).max
            && flow.amount > limit.maxCumulativeValue - limit.cumulativeUsed)
                                                             return (false, MandateReason.OVER_CUMULATIVE_CAP);
        if (limit.capacity != type(uint256).max
            && flow.amount > currentAvailable(limit, refilledAt[mandateKey][flow.asset][flow.direction]))
                                                             return (false, MandateReason.RATE_LIMITED);
    }

    return (true, MandateReason.OK);
}

canExecute MUST revert if the same asset and direction appear more than once in flows, so a caller cannot split one flow into parts that each fit a limit. This check comes before all other checks. A caller MAY pass no flows to check every rule except the limits, for example before the call when the amounts are not yet known.

canExecute returns a boolean and a MandateReason. The reason is OK when the boolean is true. When it is false, reason MUST be the first failing check in the order shown above, so an integrator can tell an expired mandate from an over-cap amount and respond accordingly. When several flows fail, the reason is the one of the first failing flow, in the order of flows. The enum lists the reasons in the order canExecute checks them. A future revision of this standard adds new reasons at the end, without renumbering. Only NONEXISTENT precedes AGENT_FROZEN and PRINCIPAL_FROZEN, since a triple with no mandate has nothing to halt. The precedence runs one way: a freeze reported for a mandate that is also expired or revoked leaves that reason to surface once the freeze is lifted. The listed reasons are the normative set; OTHER is reserved for implementation-specific checks not covered here and MUST NOT stand in for a listed reason. A registry that cannot evaluate a check MUST revert rather than return ok == false, so a failed evaluation is never reported as a denial. The registry holds no funds and cannot evaluate balances, allowances, or custody, and MUST NOT return OTHER for those conditions.

Interface

interface IAgentMandate is IERC165 {
    /// @notice Reason a canExecute check passed or failed. OK means the action may execute.
    /// @dev The listed reasons are the normative check set. OTHER is only for implementation-specific
    ///      checks not covered here, and MUST NOT stand in for one of the listed reasons.
    ///      The reasons are listed in the order canExecute checks them. A future revision adds new reasons at the end.
    enum MandateReason {
        OK,
        NONEXISTENT,
        AGENT_FROZEN,
        PRINCIPAL_FROZEN,
        NOT_YET_VALID,
        EXPIRED,
        REVOKED,
        ACTION_NOT_ENABLED,
        CONSTRAINT_FAILED,
        NO_LIMIT,
        OVER_TX_CAP,
        OVER_CUMULATIVE_CAP,
        RATE_LIMITED,
        OTHER
    }

    /// @notice Reverts recordExecution, and any gate, with the reason of the first failing check.
    error MandateBlocked(MandateReason reason);

    /// @notice How a constraint compares a calldata parameter with its value.
    enum Check {
        EQUALS,
        NOT_EQUALS,
        AT_MOST,
        AT_LEAST
    }

    /// @notice A rule on one parameter of an action's calldata. Several EQUALS constraints on the same index pass
    ///         if any of them matches. All other constraints must pass.
    /// @param index Index of the 32-byte calldata word after the selector.
    /// @param check The comparison.
    /// @param value The value the word is compared with. AT_MOST and AT_LEAST compare it as uint256.
    struct Constraint {
        uint8 index;
        Check check;
        bytes32 value;
    }

    /// @notice An enabled action and the constraints on its calldata.
    struct Action {
        bytes32 action;
        Constraint[] constraints;
    }

    /// @notice The side of a balance change that a limit counts: what leaves the principal's account, or what
    ///         enters it.
    enum Direction {
        OUTFLOW,
        INFLOW
    }

    /// @notice The budget of one asset in one direction, in its base unit, shared by every action of the mandate.
    /// @param refillPeriod The refill period of the rate limit, in seconds.
    /// @param maxTransactionValue The most one execution can move.
    /// @param capacity The most the rate limit holds. type(uint256).max means the rate limit is not checked.
    /// @param refillAmount The amount the rate limit refills every refillPeriod. 0 means it never refills.
    /// @param available Starting value at grant. getLimits returns the current available amount.
    ///        Not used when capacity is type(uint256).max.
    /// @param maxCumulativeValue The most the mandate can move in total.
    /// @param cumulativeUsed Starting value at grant. 0 for a new budget.
    struct Limit {
        address asset;
        Direction direction;
        uint48 refillPeriod;
        uint256 maxTransactionValue;
        uint256 capacity;
        uint256 refillAmount;
        uint256 available;
        uint256 maxCumulativeValue;
        uint256 cumulativeUsed;
    }

    /// @notice An amount of one asset that an execution moves in one direction.
    struct Flow {
        address asset;
        Direction direction;
        uint256 amount;
    }

    struct Mandate {
        address agent;
        uint48 validFrom;
        uint48 validUntil;
        address principal;
        bool revoked;
        address complianceProvider;
        bytes32 identityRef;
        address target;
        bytes32 metadata;
    }

    /// @notice Parameters for grantMandate, bundled into a struct to avoid stack-too-deep.
    /// @param agent The address of the agent receiving the mandate.
    /// @param validFrom Unix timestamp from which the mandate is active.
    /// @param validUntil Unix timestamp after which the mandate expires.
    /// @param principal The address of the principal granting the mandate.
    /// @param complianceProvider Address of an IComplianceProvider. MUST be a non-zero address.
    /// @param identityRef Off-chain identity reference for the principal.
    /// @param target The contract the agent calls.
    /// @param actions The enabled actions, each with its constraints.
    /// @param limits One budget per asset and direction. An amount with no limit on its asset and direction fails.
    /// @param metadata Optional 32-byte pointer to off-chain metadata (e.g., legal-text content hash).
    /// @param deadline Signature expiry timestamp (replay protection).
    struct GrantMandateParams {
        address agent;
        uint48 validFrom;
        uint48 validUntil;
        address principal;
        address complianceProvider;
        bytes32 identityRef;
        address target;
        Action[] actions;
        Limit[] limits;
        bytes32 metadata;
        uint256 deadline;
    }

    /// @notice Parameters for updateRateLimit, bundled into a struct to avoid stack-too-deep.
    /// @param agent The agent address.
    /// @param principal The principal address.
    /// @param target The target of the mandate.
    /// @param asset The asset of the limit.
    /// @param direction The direction of the limit.
    /// @param capacity The new capacity. type(uint256).max means the rate limit is not checked.
    /// @param refillAmount The new amount the rate limit refills every refillPeriod. 0 means it never refills.
    /// @param refillPeriod The new refill period, in seconds.
    /// @param deadline Signature expiry timestamp.
    struct UpdateRateLimitParams {
        address agent;
        address principal;
        address target;
        address asset;
        Direction direction;
        uint256 capacity;
        uint256 refillAmount;
        uint48 refillPeriod;
        uint256 deadline;
    }

    /// @notice Emitted when a mandate is granted.
    event MandateGranted(
        address indexed agent,
        address indexed principal,
        address indexed target,
        address complianceProvider,
        uint48 validFrom,
        uint48 validUntil,
        bytes32 metadata
    );

    /// @notice Emitted when an action is enabled on a mandate at grant time.
    event ActionEnabled(address indexed agent, address indexed principal, bytes32 indexed action, address target);

    /// @notice Emitted for each limit of a mandate at grant time, and for a limit whose rate limit is updated.
    event LimitSet(
        address indexed agent,
        address indexed principal,
        address indexed asset,
        address target,
        Direction direction,
        uint48 refillPeriod,
        uint256 maxTransactionValue,
        uint256 capacity,
        uint256 refillAmount,
        uint256 available,
        uint256 maxCumulativeValue,
        uint256 cumulativeUsed
    );

    /// @notice Emitted when a mandate is revoked.
    event MandateRevoked(address indexed agent, address indexed principal, address indexed target, address revokedBy);

    /// @notice Emitted when a mandate's validity is extended.
    event MandateExtended(
        address indexed agent, address indexed principal, address indexed target, uint48 newValidUntil
    );

    /// @notice Emitted when an operator approval is set or revoked.
    event OperatorSet(address indexed principal, address indexed operator, bool approved);

    /// @notice Emitted for each amount an execution moves, with the cumulativeUsed, the available amount and the refill
    ///         time after it.
    event ExecutionRecorded(
        address indexed agent,
        address indexed principal,
        bytes32 indexed action,
        address target,
        address asset,
        Direction direction,
        uint256 amount,
        uint256 cumulativeUsed,
        uint256 available,
        uint48 refilledAt
    );

    /// @notice Emitted when an agent is frozen. Freezing is restricted to authorized enforcer roles.
    event AgentFrozen(address indexed agent, address indexed enforcer);

    /// @notice Emitted when a freeze is lifted.
    event AgentUnfrozen(address indexed agent, address indexed enforcer);

    /// @notice Emitted when a principal is frozen. Freezing is restricted to authorized enforcer roles.
    event PrincipalFrozen(address indexed principal, address indexed enforcer);

    /// @notice Emitted when a freeze on a principal is lifted.
    event PrincipalUnfrozen(address indexed principal, address indexed enforcer);

    /// @notice Grants a mandate from a principal to an agent.
    /// @dev If `signature` is empty, msg.sender MUST be params.principal or an approved operator of it. Otherwise the
    ///      GrantMandate EIP-712 digest MUST be signed by the principal (ERC-1271 supported) or by an approved operator.
    /// @param params The mandate parameters.
    /// @param signature Principal or operator signature (EIP-712).
    function grantMandate(GrantMandateParams calldata params, bytes calldata signature) external;

    /// @notice Revokes the active mandate for the given agent, principal and target.
    /// @dev Callable by the principal or an approved operator, directly or by signature.
    /// @param agent The agent address whose mandate is revoked.
    /// @param principal The principal address whose mandate is revoked.
    /// @param target The target of the mandate being revoked.
    /// @param deadline Signature expiry timestamp.
    /// @param signature Principal or operator signature (EIP-712).
    function revokeMandate(address agent, address principal, address target, uint256 deadline, bytes calldata signature)
        external;

    /// @notice Extends the validity of an existing mandate without resetting cumulativeUsed or the rate limit.
    /// @dev Callable by the principal or an approved operator, directly or by signature.
    /// @param agent The agent address.
    /// @param principal The principal address.
    /// @param target The target of the mandate being extended.
    /// @param newValidUntil New expiry timestamp. MUST be greater than the current validUntil.
    /// @param deadline Signature expiry timestamp.
    /// @param signature Principal or operator signature (EIP-712).
    function extendMandate(
        address agent,
        address principal,
        address target,
        uint48 newValidUntil,
        uint256 deadline,
        bytes calldata signature
    ) external;

    /// @notice Updates the rate limit of one limit of an active mandate. The caps and cumulativeUsed do not change.
    /// @dev Callable by the principal or an approved operator, directly or by signature.
    /// @param params The rate limit parameters.
    /// @param signature Principal or operator signature (EIP-712).
    function updateRateLimit(UpdateRateLimitParams calldata params, bytes calldata signature) external;

    /// @notice Freezes an agent, halting all of its mandates. Restricted to authorized enforcer roles.
    /// @param agent The agent address to freeze.
    function freezeAgent(address agent) external;

    /// @notice Lifts a freeze on an agent.
    /// @param agent The agent address to unfreeze.
    function unfreezeAgent(address agent) external;

    /// @notice Freezes a principal, halting every mandate granted by that principal. Restricted to authorized
    ///         enforcer roles.
    /// @dev Reversible and keyed by principal alone, so it needs no enumeration of the principal's agents and
    ///      also covers mandates granted while the freeze is in place. It does not revoke: revocation stays with
    ///      the principal, so an enforcer cannot destroy a delegation the principal wants to keep.
    /// @param principal The principal address to freeze.
    function freezePrincipal(address principal) external;

    /// @notice Lifts a freeze on a principal.
    /// @param principal The principal address to unfreeze.
    function unfreezePrincipal(address principal) external;

    /// @notice Sets or revokes operator approval for the principal. An operator can do everything the principal can
    ///         on its mandates, except set operators.
    /// @dev Callable by the principal, directly or by signature. An enforcer can call it directly, but only to remove
    ///      an operator.
    /// @param principal The principal granting/revoking operator status.
    /// @param operator The operator address being approved or revoked.
    /// @param approved True to approve, false to revoke.
    /// @param deadline Signature expiry timestamp.
    /// @param signature Principal signature (EIP-712, ERC-1271 supported).
    function setOperator(address principal, address operator, bool approved, uint256 deadline, bytes calldata signature)
        external;

    /// @notice Records an agent-initiated execution and adds each flow to the cumulativeUsed of its limit.
    /// @param agent The agent address.
    /// @param principal The principal on whose behalf the action is executed.
    /// @param target The target of the mandate. When the caller is the target, it MUST pass its own address.
    /// @param action The action label being executed.
    /// @param data The calldata the constraints are checked against.
    /// @param flows The amounts the execution moves, each asset and direction at most once.
    function recordExecution(
        address agent,
        address principal,
        address target,
        bytes32 action,
        bytes calldata data,
        Flow[] calldata flows
    ) external;

    /// @notice Returns whether the agent can execute the action on the target for the principal, and the reason.
    /// @dev Bundles existence, validity, agent and principal freeze, action, constraint and limit checks.
    /// @param agent The agent address.
    /// @param principal The principal address.
    /// @param target The contract the action calls; selects the mandate.
    /// @param action The action label being checked.
    /// @param data The calldata the constraints are checked against.
    /// @param flows The amounts to check, each asset and direction at most once.
    /// @return ok True if the agent can execute the action.
    /// @return reason MandateReason.OK when ok is true, otherwise the first failing check.
    function canExecute(
        address agent,
        address principal,
        address target,
        bytes32 action,
        bytes calldata data,
        Flow[] calldata flows
    ) external view returns (bool ok, MandateReason reason);

    /// @notice Returns true if the action is enabled on the mandate.
    function isActionEnabled(address agent, address principal, address target, bytes32 action)
        external
        view
        returns (bool);

    /// @notice Returns the Mandate struct for the given agent, principal and target.
    function getMandate(address agent, address principal, address target) external view returns (Mandate memory);

    /// @notice Returns the enabled actions of the mandate.
    function getActions(address agent, address principal, address target) external view returns (bytes32[] memory);

    /// @notice Returns the limits of the mandate, with their cumulativeUsed and their current available amount.
    function getLimits(address agent, address principal, address target) external view returns (Limit[] memory);

    /// @notice Returns the constraints of an enabled action.
    function getConstraints(address agent, address principal, address target, bytes32 action)
        external
        view
        returns (Constraint[] memory);

    /// @notice Returns true if the operator is approved for the given principal.
    /// @param principal The principal address.
    /// @param operator The operator address.
    /// @return True if approved.
    function isOperator(address principal, address operator) external view returns (bool);

    /// @notice Returns true if the agent is frozen.
    /// @param agent The agent address.
    /// @return True if frozen.
    function isAgentFrozen(address agent) external view returns (bool);

    /// @notice Returns true if the principal is frozen.
    /// @param principal The principal address.
    /// @return True if frozen.
    function isPrincipalFrozen(address principal) external view returns (bool);

    /// @notice Returns the current nonce for a principal (used in signed operations).
    /// @param principal The principal address.
    /// @return The current nonce value.
    function nonces(address principal) external view returns (uint256);

    /// @notice Returns the EIP-712 domain separator.
    /// @return The domain separator hash.
    function DOMAIN_SEPARATOR() external view returns (bytes32);
}

Integration with Regulated Token Contracts

A regulated token, such as an ERC-7943 or ERC-3643 token, integrates RAMS by gating each function that an agent can call for a holder. In a gated call, the holder (from) is the principal and the caller (msg.sender) is the agent. When the gate treats a call as agent-initiated, it MUST check the mandate of (msg.sender, from, address(this)). A token MUST gate every function that an agent can call for a holder.

At the token gate, a mandate does not replace token-level authorization. An agent-initiated transfer needs both: the token-level authorization (ERC-20 allowance, or ERC-721/ERC-1155 operator approval), and a valid RAMS mandate. RAMS adds a compliance layer on top of the token’s ownership rules. It does not replace them.

The action label is an opaque bytes32 chosen by the token: a function selector, a keccak256 of a string, or any other 32-byte identifier matching the labels the principal signed. A selector MUST be left-aligned as bytes32(selector), so the label the principal signs and the label the token computes are the same value.

Each gated function carries its own label, as a compile-time constant:

function transferFrom(address from, address to, uint256 value)
    public override
    gatedByMandate(IERC20.transferFrom.selector, from, value)
    returns (bool)
{
    return super.transferFrom(from, to, value);
}

gatedByMandate is in the Reference Implementation. It passes msg.data for the constraints, and one OUTFLOW flow: the token itself, with the amount of the call. A token MAY write its own gate.

In this example, any caller that is not the holder needs a mandate, so an ordinary ERC-20 spender with only an allowance is rejected with NONEXISTENT. A token MAY instead check only callers that hold a mandate, leaving normal allowance transfers untouched.

The enforcement venue depends on whether the target itself can be changed:

  1. Token gate: a new or upgradeable token gates its own functions, as above.
  2. Principal’s account: the principal’s account runs an IAgentExecutor, and the agent calls execute on that account. Agent actions so originate as the principal, and the funds stay in the principal’s account. An EOA delegates to the executor code with EIP-7702. One deployment of that code per chain and registry serves every principal: the principal is always the account that runs it, so the code holds no state and no configuration of its own. A smart account can run the same logic as a module, for example a Safe module. A module is a separate contract, so it needs the recorder role.
  3. Standalone executor: on an EVM chain without EIP-7702, the principal deploys one IAgentExecutor bound to itself, and the agent acts only through it. A standalone executor MUST serve one principal only. It needs the setup that EIP-7702 avoids: the recorder role on the registry, an allowance or custody of the principal’s funds, and, on a regulated asset, a place on the asset’s whitelist.

Venues 2 and 3 exist because a target already deployed without RAMS awareness cannot be gated. All three read the same mandate, so the agent’s authority does not depend on which one applies. They do not combine: a gated token evaluates msg.sender, so a call forwarded by an executor is evaluated against the executor or the principal rather than the agent.

A deployment implements IAgentExecutor only for the account-side venues. The forwarding logic is never part of IAgentMandate.

interface IAgentExecutor {
    /// @dev msg.sender is the agent; the principal is the account that runs the code. The action label is the
    ///      selector bytes4(data). Calls canExecute and reverts if false, forwards the call, then measures the
    ///      change of the principal's balance in each token that the mandate limits, checks it against the limits
    ///      and records it. An approval moves no funds, so it spends nothing: a mandate that enables approve SHOULD
    ///      constrain the spender.
    function execute(address target, bytes calldata data) external returns (bytes memory);
}

An IAgentExecutor in venues 2 and 3 SHOULD measure the flows rather than read them from the calldata. Before the call, it checks the mandate with no flows. It reads the principal’s balance of each asset that the mandate limits, makes the call, and reads the balances again. A decrease counts against the OUTFLOW limit of the asset, and an increase counts against its INFLOW limit. It then records these flows with recordExecution, which applies the same checks. A failing check reverts the whole call, so nothing moves.

The transferFrom example is principal-custodied, the known pattern for regulated assets, but RAMS is custody-agnostic: an agent MAY hold the asset itself when its own wallet is an eligible holder, in which case the token’s eligibility check already governs it.

Rationale

RAMS is a separate ERC rather than an extension of any agent identity or token compliance standard because mandate delegation is a distinct concern. Coupling it to a specific standard would limit its use across the fragmented regulated token ecosystem.

Mandates are keyed by (agent, principal, target), not by asset, because one call can spend several assets: a liquidity position on a pool takes two tokens, and a router can take any token. The limits stay per asset because amounts in different assets do not add up without a price oracle. A limit has a direction because an inflow can create an obligation for the principal, and an OUTFLOW limit does not see it.

Only one mandate is active per key. Two active mandates on the same scope would add up their limits, a revocation could leave the other one active, and an auditor could not find the one record that authorized an action.

The key is computed, not chosen. A gated token cannot receive an identifier inside a transfer, but it can compute the key from msg.sender, the holder and its own address. An executor computes it from the agent, the principal and the target of the call.

Constraints check calldata words because the words are what the target executes. They cover the arguments at a fixed position, such as a recipient, a spender or a deadline. They do not cover amounts inside a dynamic argument, such as the bytes of a router command, and they do not cover an asset that the target takes without naming it in the calldata. Measured flows cover both, so the limits do not depend on the calldata layout, and the executor needs no per-function configuration: the signed mandate is the whole permission.

A single IComplianceProvider interface is used rather than separate identity and compliance interfaces because identity verification is a logical subset of compliance checking. A compliance provider that declares a principal eligible has already verified that the underlying identity is valid and unrevoked.

Mandate scope is encoded fully on-chain and bound by the principal’s EIP-712 signature, eliminating drift between on-chain state and any off-chain document. Actions with their constraints, and limits, are signed as nested EIP-712 structs and written into mappings at grant time for O(1) enforcement. The metadata field is non-normative and does not participate in enforcement.

All signed lifecycle operations include a nonce and deadline; ERC-1271 verification allows smart-wallet principals (multisigs, DAOs).

canExecute bundles every runtime check into one call so the integrator cannot accidentally skip one.

canExecute does not call the compliance provider. It sits in the transfer path of every gated asset, so an external call there would let a provider that reverts, is upgraded badly, or becomes unreachable halt all activity on assets that merely reference it. Eligibility is therefore checked when a mandate is granted or extended, and the mandate’s validUntil is bounded under the principal’s expiresAt so it cannot outlive the compliance window it was issued against. Eligibility lost inside that window is handled by the enforcer freeze and by the asset’s own compliance checks, not by the registry.

canExecute returns a MandateReason rather than a bare boolean so an integrator knows what to do next. The reasons group into five responses, plus OTHER: NOT_YET_VALID means wait; RATE_LIMITED means wait if the rate limit can refill to the amount; OVER_TX_CAP succeeds on a retry with a smaller amount; CONSTRAINT_FAILED succeeds on a retry with arguments the rules allow; NONEXISTENT, EXPIRED, REVOKED, ACTION_NOT_ENABLED, NO_LIMIT and OVER_CUMULATIVE_CAP need the principal to grant, extend or widen a mandate, and a spent cumulative budget is not restored by extendMandate; AGENT_FROZEN and PRINCIPAL_FROZEN need an enforcer; OTHER carries no remediation and an integrator cannot infer one.

AGENT_FROZEN and PRINCIPAL_FROZEN are evaluated before the mandate-specific checks because a freeze applies to every mandate the frozen party holds, and an unrelated failing check on one mandate would otherwise hide the freeze.

checkPrincipal returns a reason code and an expiry timestamp, not only a boolean, because a compliance audit needs both.

Limits are per mandate, so a principal granting several mandates is not bounded in aggregate by this standard; each principal manages its own total exposure.

Freeze authority is kept within IAgentMandate rather than a separate registry because an enforcer does not exist independently of the mandates it can freeze. Enforcer authority is governed by the implementation’s access-control roles, not by a hardcoded tier.

Enforcement is venue-agnostic: RAMS standardizes the mandate, not how it is enforced. Any contract in the agent’s path applies it by calling canExecute, so the same mandate is honored whether the gate is in the token, in the principal’s account, or in an executor. The account-side venues exist because an asset already deployed cannot be changed to gate itself.

Agents use standard token functions (ERC-20, ERC-721, ERC-1155) rather than agent-prefixed variants because that would require interface duplication. The token’s own gate validates mandates via canExecute, requiring no new functions on the token.

Value limits are denominated in token base units rather than fiat to stay deterministic and oracle-free.

cumulativeUsed does not reset on extendMandate because a mandate represents a single delegation agreement. A new budget requires revocation and re-issuance. The principal signs the starting cumulativeUsed of each limit, so a re-issued mandate that changes its actions can keep the budget already used.

updateRateLimit changes the rate limit and not the caps. maxTransactionValue and maxCumulativeValue set the largest single exposure and the total exposure that the principal granted. They are the terms of the delegation, so a change to them needs a new grant. The rate limit is a velocity control inside those terms, the same as a pre-trade risk control: the principal tunes it during the mandate as conditions change, without a change of terms. It slows an agent under review, or allows more speed when volume grows. No rate can move more value than the caps allow, so the worst-case exposure stays the value that the principal granted. The update first credits the refill at the old rate, so the new rate does not apply retroactively.

A limit has a rate limit next to its total because a total alone is a one-time budget, and a principal often needs a budget that renews. The rate limit refills continuously and does not reset at fixed times. A budget that resets at a fixed time lets an agent move the full budget just before the reset and again just after it, and gives the agent a reason to spend before each reset. A continuous refill bounds how fast a faulty agent moves the principal’s assets, so an enforcer or the principal has time to act. capacity and the refill rate are separate, so one limit bounds both the amount that moves at once and the rate after that. The principal signs the starting available, like cumulativeUsed, so a re-issued mandate does not restore a spent rate limit. A limit that must follow calendar periods uses one mandate per period, with validFrom and validUntil on the period boundaries and maxCumulativeValue as the period cap.

Freezing is reserved for authorized enforcer roles, reflecting the exceptional nature of a halt. It is deliberately coarse: freezeAgent is keyed by agent and halts that agent’s mandates from every principal at once, freezePrincipal is keyed by principal and halts every mandate that principal granted, and neither requires enumerating the mandates involved. Enforcement stops at halting. Revocation is left to the principal because a mandate is the principal’s own delegation of authority, revocation is irreversible, and restoring a revoked mandate needs a fresh signature from the principal, which is unavailable in exactly the compliance scenarios a freeze exists for. A freeze is the reversible tool an enforcer needs while a lapse is resolved; revocation would let the registry admin permanently unwind delegations, which is the capture risk the model is built to avoid.

An operator has the powers of the principal over its mandates, so a principal can hand the management of its agents to a platform or a custodian without sharing its key. Only the principal can approve an operator, so no other party can take the principal’s powers. An enforcer can remove an operator, for example when the operator’s key leaks and the principal cannot act in time. Like a freeze, this is an emergency action, and it gives the enforcer no power over the principal’s mandates. An operator cannot set operators. Operator signatures use the principal’s nonce, so one nonce sequence orders every signed operation on a principal’s mandates.

Backwards Compatibility

RAMS changes no existing standard. With the token gate, a caller that moves tokens for a holder with only an allowance or an operator approval fails. Protocols that rely on these approvals then fail too. A token that must keep these integrations SHOULD check only callers that hold a mandate.

Reference Implementation

A reference implementation and test suite are available: the IAgentMandate registry, an IComplianceProvider, an IAgentExecutor, a RamsGated base contract, and an ERC-7943 asset that inherits it. The reference registry verifies principal signatures with OpenZeppelin SignatureChecker.isValidSignatureNow.

The reference AgentExecutor is EIP-7702 delegate code. Its constructor takes only the registry. The principal is address(this), the account that runs the code, so the registry accepts it as its own recorder and no role is needed. It implements ERC-1271 isValidSignature, which accepts a signature made by the account’s own key, so the principal can still sign lifecycle operations after delegation. It has no configuration: the mandate alone decides what the agent may do.

RamsGated is an optional base contract for the token gate venue, holding the registry address as rams. A token inherits it and applies gatedByMandate to each function an agent performs for a holder.

modifier gatedByMandate(bytes4 selector, address holder, uint256 amount) {
    bytes32 action = bytes32(selector);
    bool agentCall = msg.sender != holder;
    IAgentMandate.Flow[] memory flows = new IAgentMandate.Flow[](1);
    flows[0] = IAgentMandate.Flow(address(this), IAgentMandate.Direction.OUTFLOW, amount);

    if (agentCall) {
        (bool ok, IAgentMandate.MandateReason reason) =
            rams.canExecute(msg.sender, holder, address(this), action, msg.data, flows);
        if (!ok) revert IAgentMandate.MandateBlocked(reason);
    }

    _;

    if (agentCall) rams.recordExecution(msg.sender, holder, address(this), action, msg.data, flows);
}

Solidity modifiers cannot be overloaded, so a token labeling actions with keccak256 strings rather than selectors writes its own gate.

Security Considerations

identityRef is a reference, not proof of eligibility. Grant-time eligibility comes from checkPrincipal; runtime eligibility comes from the token’s own check, on assets that perform one. A token gate treats a call as agent-initiated when msg.sender != from. When an agent moves tokens from its own wallet, it is the holder, so the gate applies no mandate and the token’s own eligibility check governs it.

If recordExecution were callable by arbitrary addresses, an attacker could advance cumulativeUsed to exhaust the limits and deny service to the legitimate agent. The caller restriction specified in the Specification closes this attack surface, leaving the recorder role itself as a trusted surface. The recorder role is global: a recorder can record against the mandates of every principal, so a faulty or malicious standalone executor can use up the budgets of principals it does not serve. It cannot move their funds. Implementations that serve standalone executors MAY replace the global role with a recorder that each principal approves for its own mandates, on the pattern of setOperator. Callers can use canExecute for pre-transaction checks or rely on recordExecution’s revert behavior for atomic enforcement.

If a revoked mandate’s record were removed instead of flagged, then on a token that checks only callers holding a mandate, an agent that still holds a token-level allowance would fall through to plain allowance rules, turning revocation into a silent permission upgrade. Retaining the record also preserves the audit trail.

If grantMandate does not clear the actions and limits of a prior mandate, they stay in force, so a principal who re-issues a narrower mandate keeps the wider mandate’s authority.

A compromised compliance provider can approve an ineligible principal at grant time. This is bounded: compliance is checked at grant, not on the execution path, so a provider going offline cannot brick active mandates, though it does block extension; the token’s own eligibility check (for example canSend in ERC-7943) still runs on every transfer of an asset that implements one; and an enforcer can freeze the agent or the principal independently of provider state. Principals should select compliance providers with audited, time-locked upgrade mechanisms.

Those two runtime layers are not present in every venue. An asset that carries its own eligibility logic gates each transfer independently of the registry, so a principal who loses eligibility mid-mandate is stopped by the asset even if no enforcer acts. An IAgentExecutor applying a mandate over an asset with no compliance logic of its own, which is the venue this specification provides for assets already deployed and unchangeable, has no such layer: the enforcer freeze is then the only runtime control that responds to eligibility lost inside a mandate’s validity window. Deployments of that shape SHOULD treat the freeze relay described below as required rather than optional, and SHOULD issue short mandates renewed through extendMandate, since extension re-checks checkPrincipal and so converts mandate length into the interval at which eligibility is revisited.

A transaction can fail at two distinct compliance layers: the token’s investor eligibility check on the principal, or the RAMS mandate validity check on the agent. Frontends and autonomous agents should pre-verify both layers before submitting a transaction to enable clear diagnostic reporting.

A window exists between a PrincipalRevoked event from the compliance provider and enforcement of a freeze on the RAMS registry. High-sensitivity protocols should use an automated freeze relay that monitors PrincipalRevoked events and calls freezePrincipal immediately, which matches the scope of the event, since PrincipalRevoked names a principal and not the agents holding that principal’s mandates. A provider that reads an external backend, such as EAS, does not emit PrincipalRevoked when the backend revokes an attestation. A freeze relay for such a provider SHOULD watch the backend’s revocation events instead.

A gate applies only to the functions it is placed on. A function an agent can call for a holder without a gate admits that agent on its token-level allowance alone, with no mandate check.

Under EIP-7702 the agent’s calls originate as the principal, so msg.sender equals the holder and a token gate cannot tell the agent from the principal acting directly. Enforcement for that venue belongs to the IAgentExecutor, which is the only party that knows the acting agent.

In the executor venue, limits do not cover an approval, because it does not move tokens. A mandate that enables an approval, on a token or on an allowance contract such as Permit2, SHOULD constrain the spender with EQUALS, and MAY cap the amount with AT_MOST. Without a spender constraint, the agent can approve itself and move the tokens with its own key, outside the executor and its limits. The same applies to any function that grants a later right to move the principal’s assets, such as an operator approval.

The target finds the content of a dynamic argument through offsets that the caller writes. A constraint on a word inside it can therefore be bypassed, and if the argument holds a recipient, the agent can name itself. A mandate that enables such a function SHOULD pin with EQUALS every word of the argument, including offsets and lengths, and leave open only the words the agent needs, such as amounts, unless the target itself restricts the recipient.

A measured limit counts the net change of the principal’s balance during one call: the decrease for OUTFLOW, the increase for INFLOW. Assets that leave and come back within the call do not count, and an increase in one asset does not offset a decrease in another. An executor measures only the assets that the mandate limits. When the target is itself an asset, the principal SHOULD set a limit on it. A principal SHOULD NOT approve a target for an asset that the mandate does not limit. An executor measures the principal’s balance only. Value that the principal holds in another contract, such as a position or a deposit, is not measured, so a call that withdraws it to another address spends nothing against the limits.

An INFLOW limit counts an asset only if it is still in the principal’s account when the call ends. If one call receives the asset and sends it away, the balance does not go up and the limit counts nothing. So a mandate with an INFLOW limit SHOULD NOT enable a function that batches several calls, and SHOULD fix the recipient to the principal. A later outflow does not give the budget back, because cumulativeUsed only goes up.

A rate limit does not cap the amount moved in a period at capacity. In any interval of length T, a limit with a checked capacity lets at most capacity + refillAmount * T / refillPeriod move. A principal that needs a hard cap over an interval sets capacity and the refill rate so that this sum stays under the cap, or uses maxCumulativeValue. The refill rounds down and refilledAt advances by a time rounded up, so rounding never lets the agent move more than the rate allows.

A standalone executor is the bridge between the agent and the principal’s funds: it holds them, or it can pull them through an allowance, and every target sees it as the sender. A fault in it exposes the funds of its principal, which is why it serves one principal only. The principal SHOULD limit its allowances to what the mandates need. Under EIP-7702 or a module, the funds never leave the principal’s account, which is why this specification recommends those venues where they exist. EIP-7702 allows one delegation per account, so a principal already delegated to other code needs the module or the standalone venue.

Only the principal can approve an operator, so no other party can act as the principal or grant a mandate that moves the principal’s assets. An enforcer can remove an operator, as an emergency action.

The content of metadata, such as off-chain legal text, cannot be verified on-chain. It is an opaque pointer for human-readable context and audit only.

Copyright and related rights waived via CC0.

Citation

Please cite this document as:

Ludovico Rossi (@ludovicor-eth) <ludovico@brickken.com>, Dario Lo Buglio (@xaler5) <dario@brickken.com>, Thamer Dridi (@thamerdridi) <thamer@brickken.com>, Nabil El Alami Khalifi (@nabil-brickken) <nabil@brickken.com>, "ERC-8226: Regulated Agent Mandate [DRAFT]," Ethereum Improvement Proposals, no. 8226, April 2026. Available: https://eips.ethereum.org/EIPS/eip-8226.