Matador Docs
API Reference

Contract Interfaces

Technical reference for the Matador smart contract ecosystem.

This reference documents the core interfaces, data structures, and errors used by the on-chain components of Matador.

IPermissionInterpreter

The IPermissionInterpreter is the heart of the system. It executes the compiled bytecode to validate transactions.

contracts/src/interfaces/IPermissionInterpreter.sol
interface IPermissionInterpreter {
    function enforce(
        bytes memory context,
        address subject,
        ExecutionContext calldata exec
    ) external;

    function enforceView(
        bytes memory context,
        address subject,
        ExecutionContext calldata exec
    ) external view;
}

ExecutionContext

The ExecutionContext struct contains all runtime metadata available to the interpreter during a policy check.

PropertyTypeDescription
calleraddressThe address initiating the execution (usually the entry point or msg.sender).
targetaddressThe destination contract address.
valueuint256The native value (Wei) sent with the call.
databytesThe transaction calldata.
gasLimituint256The gas limit for the execution.
gasPriceuint256The gas price (or max fee per gas) of the transaction.
nonceuint256The nonce of the smart account.
blobBaseFeeuint256The base fee for blob gas (EIP-4844).
blobGasPriceuint256The blob gas price.

Methods

enforce

Executes the permission policy in a mutable context. This is required for policies that update state, such as RATE_LIMIT_CHECK or OPERATION_COUNT_CHECK.

  • Reverts: If any condition in the policy fails.
  • Gas: Costs vary based on the policy complexity and state access.

enforceView

Executes the permission policy in a read-only context. Useful for off-chain simulations or validateUserOp where storage modification is restricted.

Stateful Opcodes

Calling enforceView with a policy that contains state-modifying opcodes (like RATE_LIMIT_CHECK) will revert.

IModuleRegistry

The registry maps 1-byte module IDs to their deployed contract addresses.

contracts/src/interfaces/IModuleRegistry.sol
interface IModuleRegistry {
    function getModule(uint8 moduleId) external view returns (address module);
}

Errors

Matador uses custom errors for gas efficiency and clarity.

Permission Errors

Errors thrown when a specific policy condition fails.

ErrorParametersDescription
UnknownOpcodeuint8 opcodeThe bytecode contained an undefined opcode.
InvalidCondition-A logical condition (AND/OR) was malformed.
RateLimitExceededcount, limit, resetA rate limit has been breached.
BalanceCheckFailedtoken, account, req, actToken or native balance requirements were not met.
CallerCheckFailedrequired, actualThe caller is not allowed.
PermissionExpiredexpiry, currentThe policy includes an expiry timestamp that has passed.

System Errors

Errors related to the interpreter's internal execution or account management.

ErrorParametersDescription
Unauthorized-Caller is not authorized to grant/revoke permissions.
StackOverflow-Policy complexity exceeded the interpreter's stack limit (1024).
StackUnderflow-An opcode attempted to pop from an empty stack.
PermissionNotFoundbytes32 idThe requested permission ID does not exist on the account.

On this page