Introduction

Hi, I'm cardene, a software engineer and technical writer focused on blockchain and AI.

I've also authored Japanese technical books on specification-driven development with LLMs and decentralized application (DApp) development.

I also build and publish a variety of tools, libraries, and open-source projects.

This article covers ERC7579, a proposal for minimal modular smart accounts.

This explanation translates, summarizes, and expands on the following specification.

I have also written about other EIPs.

ERC7579 extends the mechanisms of EIP4337. See the following resources for more information.

[ERC4337] Implementing AA Without Protocol Changes

https://mirror.xyz/0xcE77b9fCd390847627c84359fC1Bc02fC78f0e58/-qoixMc413uT4FFM61uhXYUiL05Hw-wahq9hV_JtjJs

The following article discusses ERC7579 in more detail.

Overview

ERC7579 defines the minimal interfaces and behaviors needed for interoperability between modular smart accounts and their modules. Smart accounts must conform to execution, configuration, and fallback interfaces, as well as ERC165 and ERC1271. For modules, the proposal defines a core interface, module types, and interfaces for each type.

For more about ERC165, see the following article.

[ERC165] Checking Whether a Contract Supports a Particular Interface

For more about ERC1271, see the following article.

[ERC2771] Meta-Transactions with Gas Paid by Another Address

Motivation

Smart accounts are increasingly adopted, and many use modular architectures. Separating functionality into external contracts (modules) aims to speed up development, support future extensions, and enable customization by developers and users.

However, smart accounts currently use their own designs, resulting in fragmented modules and vendor lock-in. Standardizing smart accounts offers several benefits.

  • Interoperability that allows modules to be reused across different smart accounts.
  • Interoperability that allows smart accounts to work with different wallet applications and SDKs.
  • Reduced risk of users being locked into a specific vendor.

Standardization must nevertheless minimize its impact on smart account implementation logic. This allows account developers to continue innovating while encouraging a module ecosystem that supports multiple accounts. ERC7579 aims to establish interoperability between accounts and modules by defining the minimum necessary interfaces and behaviors.

Specification

Terminology

Smart account

A contract account with a modular architecture. It delegates some or all of its functionality to external modules, providing flexibility and extensibility.

Module

A contract implementing functionality used by a smart account. It handles specific operations such as validation, execution, or fallback.

Validator

A module that validates whether a transaction can be executed on a smart account. When using ERC4337, this corresponds to the validateUserOp function.

Executor

A module that executes transactions on behalf of a smart account. It executes actions through callbacks.

Fallback handler

A module extending the fallback functionality of a smart account, such as handling calls to undefined functions.

EntryPoint

A trusted singleton contract defined by ERC4337. It coordinates validation and execution of user operations.

Validation

The functionality that determines whether a smart account should execute a transaction. In ERC4337, this corresponds to validateUserOp.

Execution

The functionality that executes operations from or on a smart account. In ERC4337, the EntryPoint invokes it through userOp.callData.

Accounts

Validation

ERC7579 does not prescribe how validator selection must be implemented. A smart account is free to choose how it determines which validator to use.

However, if an ERC4337 implementation encodes validator selection information in a data field such as userOp.signature, the account must sanitize that value before calling the validator. Sanitization removes malicious or invalid input and converts it into a safe format.

As a general rule, the account's validation function must return the validator's return value unchanged. This ensures the validator's result is accurately reflected.

Execution behavior

To conform to ERC7579, a smart account must implement the following execution interface.

IERC7579Execution
IERC7579Execution.sol
interface IERC7579Execution {
    /**
     * @dev Executes a transaction on behalf of the account. MAY be payable.
     * @param mode The encoded execution mode of the transaction.
     * @param executionCalldata The encoded execution call data.
     *
     * MUST ensure adequate authorization control: e.g. onlyEntryPointOrSelf if used with ERC-4337
     * If a mode is requested that is not supported by the Account, it MUST revert
     */
    function execute(bytes32 mode, bytes calldata executionCalldata) external;

    /**
     * @dev Executes a transaction on behalf of the account. MAY be payable.
     *         This function is intended to be called by Executor Modules
     * @param mode The encoded execution mode of the transaction.
     * @param executionCalldata The encoded execution call data.
     *
     * @return returnData An array with the returned data of each executed subcall
     *
     * MUST ensure adequate authorization control: i.e. onlyExecutorModule
     * If a mode is requested that is not supported by the Account, it MUST revert
     */
    function executeFromExecutor(bytes32 mode, bytes calldata executionCalldata)
        external
        returns (bytes[] memory returnData);
}
execute

Executes operations from the smart account itself or the EntryPoint contract. It takes mode (execution mode) and executionCalldata (execution data) as arguments. It can also be declared payable. Access control is mandatory. With ERC4337, a restriction such as onlyEntryPointOrSelf (allowing execution only by the EntryPoint or the smart account itself) must be applied. Execution must fail if an unsupported execution mode is specified.

executeFromExecutor

Allows an Executor module to execute operations on behalf of the smart account. It takes mode (execution mode) and executionCalldata (execution data) and returns the execution results as returnData. Access control such as onlyExecutorModule (allowing calls only from an Executor module) must be implemented. Execution must fail if an unsupported execution mode is specified.

Additional function
js
/**
 * @dev ERC-4337 executeUserOp according to ERC-4337 v0.7
 *         This function is intended to be called by ERC-4337 EntryPoint.sol
 * @param userOp PackedUserOperation struct (see ERC-4337 v0.7+)
 * @param userOpHash The hash of the PackedUserOperation struct
 *
 * MUST ensure adequate authorization control: i.e. onlyEntryPoint
 */
function executeUserOp(PackedUserOperation calldata userOp, bytes32 userOpHash) external;
executeUserOp

Executes a UserOperation from the ERC4337 EntryPoint contract. It receives userOp (a PackedUserOperation struct) and its hash. It requires access control through onlyEntryPoint. If implemented, it must execute userOp.callData[4:], excluding the first four bytes of userOp.callData (executeUserOp.selector).

The first four bytes of userOp.callData contain a function selector. A function selector is a four-byte identifier for a function. It is derived by taking the function signature, consisting of the function name and parameter types (for example, transfer(address,uint256)), encoding it in UTF-8, hashing it with Keccak-256, and taking the first four bytes. This makes it possible to identify the function to execute using a small amount of data.

The function selector is stored in the first four bytes of userOp.callData (userOp.callData[:3] in the original notation), and userOp.callData[4:] contains the data to execute.

Using delegatecall is generally recommended. It preserves msg.sender during execution, enabling proper access control and related checks.

js
(bool success, bytes memory innerCallRet) = address(this).delegatecall(userOp.callData[4:]);

Execution mode structure

The mode is a 32-byte value with the following structure.

Field Size Description
callType 1 byte Call type (0x00: single call, 0x01: batch, 0xfe: staticcall, 0xff: delegatecall)
execType 1 byte Behavior on failure (0x00: return an error with revert, 0x01: handle errors without reverting)
unused 4 bytes Reserved for future extensions
modeSelector 4 bytes Identifier for an extended execution mode
modePayload 22 bytes Space for additional data

Declaring and restricting supported execution modes

Accounts do not need to support all execution modes. They must explicitly declare supported modes through supportsExecutionMode. An unsupported mode must result in an error.

Encoding execution data

The encoding of executionCalldata depends on the execution mode.

  • Single call

    • Encode as follows.
    js
    abi.encodePacked(target, value, callData)
  • delegatecall

    • Encode as follows.
    js
    abi.encodePacked(target, callData)
  • Batch call

    • Encode an array of Execution structs (address target, uint256 value, bytes callData) using abi.encode.
    js
    struct Execution {
        address target;
        uint256 value;
        bytes callData;
    }
    
    abi.encode(Execution[])

Specifying the encoding and behavior for each execution mode provides both flexibility and safety.

Account configuration

Smart accounts conforming to ERC7579 must implement the following account configuration interface. It allows external callers to inspect account identity, supported execution modes, and module compatibility.

IERC7579AccountConfig.sol
interface IERC7579AccountConfig {
    /**
     * @dev Returns the account id of the smart account
     * @return accountImplementationId the account id of the smart account
     *
     * MUST return a non-empty string
     * The accountId SHOULD be structured like so:
     *        "vendorname.accountname.semver"
     * The id SHOULD be unique across all smart accounts
     */
    function accountId() external view returns (string memory accountImplementationId);

    /**
     * @dev Function to check if the account supports a certain execution mode (see above)
     * @param encodedMode the encoded mode
     *
     * MUST return true if the account supports the mode and false otherwise
     */
    function supportsExecutionMode(bytes32 encodedMode) external view returns (bool);

    /**
     * @dev Function to check if the account supports a certain module typeId
     * @param moduleTypeId the module type ID according to the ERC-7579 spec
     *
     * MUST return true if the account supports the module type and false otherwise
     */
    function supportsModule(uint256 moduleTypeId) external view returns (bool);
}
accountId
js
function accountId() external view returns (string memory accountImplementationId);

Returns the smart account's unique identifier (account ID). The returned string must not be empty. The recommended format is "vendor.account.version" (for example, mywallet.safemodule.v1.0.0). The identifier should distinguish the implementation from other smart account implementations.

External callers use this ID to identify the smart account's implementation.

supportsExecutionMode
js
function supportsExecutionMode(bytes32 encodedMode) external view returns (bool);

Checks whether the smart account supports the specified encoded execution mode (encodedMode).

The mode encodes details such as call type and error handling. It returns true if supported and false otherwise. Modules and external applications can therefore check compatibility in advance.

supportsModule
js
function supportsModule(uint256 moduleTypeId) external view returns (bool);

Returns whether the smart account supports the specified module type (moduleTypeId).

The moduleTypeId identifies a module type defined by ERC7579, such as Validator, Executor, or Fallback. It returns true if the smart account is designed to accept that type.

This allows callers to determine in advance whether a module can be installed, ensuring a safe combination of module and account.

Module configuration

Smart accounts conforming to ERC7579 must implement an interface for installing, uninstalling, and checking modules. This allows each module type to be identified and the necessary access control, initialization, and cleanup to be performed safely.

Identifying module types

A smart account must be able to identify the type of an installed module (Validator, Executor, Fallback, and so on). For example, only Executor modules should be able to call executeFromExecutor, so they must be distinguished clearly from other modules.

IERC7579ModuleConfig
IERC7579ModuleConfig.sol
interface IERC7579ModuleConfig {
    event ModuleInstalled(uint256 moduleTypeId, address module);
    event ModuleUninstalled(uint256 moduleTypeId, address module);

    /**
     * @dev Installs a Module of a certain type on the smart account
     * @param moduleTypeId the module type ID according to the ERC-7579 spec
     * @param module the module address
     * @param initData arbitrary data that may be required on the module during `onInstall`
     * initialization.
     *
     * MUST implement authorization control
     * MUST call `onInstall` on the module with the `initData` parameter if provided
     * MUST emit ModuleInstalled event
     * MUST revert if the module is already installed or the initialization on the module failed
     */
    function installModule(uint256 moduleTypeId, address module, bytes calldata initData) external;

    /**
     * @dev Uninstalls a Module of a certain type on the smart account
     * @param moduleTypeId the module type ID according the ERC-7579 spec
     * @param module the module address
     * @param deInitData arbitrary data that may be required on the module during `onInstall`
     * initialization.
     *
     * MUST implement authorization control
     * MUST call `onUninstall` on the module with the `deInitData` parameter if provided
     * MUST emit ModuleUninstalled event
     * MUST revert if the module is not installed or the deInitialization on the module failed
     */
    function uninstallModule(uint256 moduleTypeId, address module, bytes calldata deInitData) external;

    /**
     * @dev Returns whether a module is installed on the smart account
     * @param moduleTypeId the module type ID according the ERC-7579 spec
     * @param module the module address
     * @param additionalContext arbitrary data that may be required to determine if the module is installed
     *
     * MUST return true if the module is installed and false otherwise
     */
    function isModuleInstalled(uint256 moduleTypeId, address module, bytes calldata additionalContext) external view returns (bool);
}
installModule
js
function installModule(uint256 moduleTypeId, address module, bytes calldata initData) external;

Installs a module of the specified type in the account.

  • moduleTypeId
    • ID identifying the module type (defined by ERC7579).
  • module
    • Contract address of the module.
  • initData
    • Arbitrary data passed when initializing the module.

Appropriate access control is required. The account must call onInstall(initData) on the module. It must revert if the module is already installed or initialization fails. On success, it must emit a ModuleInstalled event.

uninstallModule
js
function uninstallModule(uint256 moduleTypeId, address module, bytes calldata deInitData) external;

Removes the specified module from the account.

  • deInitData
    • Arbitrary data passed to the module on uninstallation, for example for cleanup.

Appropriate access control is required. The account must call onUninstall(deInitData) on the module. It must revert if the module is not installed or cleanup fails. On success, it must emit a ModuleUninstalled event.

isModuleInstalled
js
function isModuleInstalled(uint256 moduleTypeId, address module, bytes calldata additionalContext) external view returns (bool);

Returns whether the specified module is currently installed in the account. The additionalContext is extra data that may be used to check installation status when needed. It returns true if the module is installed and false otherwise.

Modules are normally checked by address, but additionalContext may be needed for more complex conditions, such as the following.

  • The module is enabled only for a particular function.
  • The module is enabled only for a particular user.
  • The module is enabled only at a particular block time or on a particular chain ID.

In such cases, external callers can supply additional information through additionalContext to enable flexible checks.

This module configuration interface allows smart accounts to integrate external modules and extend their functionality flexibly and safely.

Hooks

Hooks are defined as an optional feature in ERC7579. They are an extension mechanism that smart accounts may implement to insert custom logic or validation before and after transaction execution.

Purpose of Hooks

Hooks provide additional controls when a smart account executes single or batched operations.

  • Security checks, such as restricting transaction destinations.
  • Logging and audit-related events.
  • Execution conditions and pre- and post-execution validation.
  • Validation during module installation.
Implementation requirements

Smart accounts supporting this extension must call preCheck and postCheck through Hooks as follows.

  • Before executing execute or executeFromExecutor, call preCheck on one or more Hooks.
  • After execution completes, call postCheck on one or more Hooks.
  • Calling preCheck and postCheck before and after installModule or uninstallModule is also recommended.
  • Hooks are recommended where possible for other execution functions defined by the account.

ERC-1271 Forwarding

A smart account conforming to ERC7579 must implement ERC1271, the standard interface for contract-based signature validation. The specification defines how that signature validation can be delegated (forwarded) to a Validator.

For more about ERC1271, see the following article.

[ERC1271] Validating Signatures in Smart Contracts

What is ERC1271?

ERC1271 is a standard interface for contracts to validate signatures. It proposes the following function.

js
function isValidSignature(bytes32 hash, bytes memory signature) public view returns (bytes4 magicValue);

This function enables signature validation by smart accounts rather than only by EOAs.

How forwarding works

If a smart account forwards signature validation to an external validator instead of processing it internally, it must follow these rules.

  • The smart account must implement the ERC1271 isValidSignature function.
  • When forwarding, call the following function on the validator.
js
isValidSignatureWithSender(address sender, bytes32 hash, bytes memory signature)

Pass the caller address (msg.sender) of the account's isValidSignature function unchanged as sender.

Considerations when using signature data for validator selection

If a smart account encodes validator selection information in the signature parameter, it must remove invalid data and sanitize the value before passing it to the validator. This prevents signature data from being abused to redirect validation to an unauthorized validator.

Handling return values

The smart account's isValidSignature function should return the value received from the validator unchanged. This accurately reflects the result of signature validation.

Fallback

A smart account conforming to ERC7579 may implement a fallback function that forwards operations to a Fallback handler. This supports calls to undefined functions and flexible extensions.

Purpose of Fallback

In an ordinary contract, calling an undefined function invokes the fallback function. ERC7579 uses this behavior to extend account functionality by forwarding fallback operations to an external Fallback handler contract.

Rules for Fallback handlers

If a smart account uses a Fallback handler, it must satisfy the following conditions.

  • Fallback operations must invoke the handler using call or staticcall.
  • In accordance with ERC2771, append msg.sender to the end of calldata before the call.
  • Select the appropriate handler based on the function selector (four bytes) at the beginning of calldata.
  • Using Hooks is recommended when adding access control.

For more about ERC2771, see the following article.

[ERC2771] Meta-Transactions with Gas Paid by Another Address

Handling functionality added through Fallback

New functionality added to an account through a Fallback handler must be treated as equivalent to functionality implemented by the smart account itself.

In other words, it must be included in the smart account's interface.

For example, interface detection such as ERC165 can also be provided through Fallback.

ERC165 proposes a mechanism for checking whether a contract implements a particular interface.

Implementation considerations

Implementing view (read-only) functions through Fallback is recommended to improve future extensibility. However, relying on Fallback for core account logic such as signature validation and transaction execution is discouraged because it can reduce security and predictability.

ERC165

A smart account conforming to ERC7579 may implement ERC165. ERC165 enables external callers to determine whether a smart account supports a particular interface.

For more about ERC165, see the following article.

[ERC165] Checking Whether a Contract Supports a Particular Interface

What is ERC165?

ERC165 provides a mechanism for identifying supported interface IDs through a function such as the following.

js
function supportsInterface(bytes4 interfaceID) external view returns (bool);

Pass an interface ID (for example, 0x80ac58cd for IERC721). The function returns true if supported and false otherwise.

Requirements under ERC7579

If a smart account implements ERC165, it must satisfy the following conditions:

  • If a declared interface is not actually implemented (for example, its functions revert), it must be treated as unsupported.
  • Specifically, supportsInterface must return false for such interface IDs.

This prevents accounts from merely appearing to support an interface without implementing its functionality.

Modules

ERC7579 externalizes smart account functionality into modules that can be categorized and managed by role. Each module has a type ID that smart accounts and other modules use to identify its type.

Module types and type IDs

Modules are classified into the following four types, each with its own type ID.

  • Validator
    • type id: 1
  • Executor
    • type id: 2
  • Fallback handler (Fallback)
    • type id: 3
  • Hook
    • type id: 4

A module can also support multiple types.

IERC7579Module

All modules must provide the following three functions.

IERC7579Module.sol
interface IERC7579Module {
     /**
     * @dev This function is called by the smart account during installation of the module
     * @param data arbitrary data that may be required on the module during `onInstall` initialization
     *
     * MUST revert on error (e.g. if module is already enabled)
     */
    function onInstall(bytes calldata data) external;

    /**
     * @dev This function is called by the smart account during uninstallation of the module
     * @param data arbitrary data that may be required on the module during `onUninstall` de-initialization
     *
     * MUST revert on error
     */
    function onUninstall(bytes calldata data) external;

    /**
     * @dev Returns boolean value if module is a certain type
     * @param moduleTypeId the module type ID according the ERC-7579 spec
     *
     * MUST return true if the module is of the given type and false otherwise
     */
    function isModuleType(uint256 moduleTypeId) external view returns(bool);
}
onInstall

Installs a module in a smart account. The module receives data and performs initialization. It must revert if, for example, the module is already installed.

onUninstall

Removes a module from a smart account. The data can be used to clean up state.

isModuleType

Checks whether a particular module supports the moduleTypeId passed as an argument.

Data structure design

If a module supports multiple types, including moduleTypeId in the data passed to onInstall or onUninstall enables flexible type-specific initialization.

Example:

js
// Module.sol
function onInstall(bytes calldata data) external {
    // ...
    (uint256 moduleTypeId, bytes memory otherData) = abi.decode(data, (uint256, bytes));
    // ...
}

Validator

Must implement both IERC7579Module and IERC7579Validator.

  • type id: 1
IERC7579Validator.sol
interface IERC7579Validator is IERC7579Module {
    /**
     * @dev Validates a UserOperation
     * @param userOp the ERC-4337 PackedUserOperation
     * @param userOpHash the hash of the ERC-4337 PackedUserOperation
     *
     * MUST validate that the signature is a valid signature of the userOpHash
     * SHOULD return ERC-4337's SIG_VALIDATION_FAILED (and not revert) on signature mismatch
     */
    function validateUserOp(PackedUserOperation calldata userOp, bytes32 userOpHash) external returns (uint256);

    /**
     * @dev Validates a signature using ERC-1271
     * @param sender the address that sent the ERC-1271 request to the smart account
     * @param hash the hash of the ERC-1271 request
     * @param signature the signature of the ERC-1271 request
     *
     * MUST return the ERC-1271 `MAGIC_VALUE` if the signature is valid
     * MUST NOT modify state
     */
    function isValidSignatureWithSender(address sender, bytes32 hash, bytes calldata signature) external view returns (bytes4);
}
validateUserOp

Validates an ERC4337 UserOperation. For an invalid signature, returning the defined value (SIG_VALIDATION_FAILED) instead of reverting is recommended.

isValidSignatureWithSender

Performs signature validation based on ERC1271. Returning MAGIC_VALUE indicates that the signature is valid.

Executor

Implements only IERC7579Module.

  • type id: 2

Used to call the smart account's executeFromExecutor function, which executes operations on behalf of the account.

Fallback handler

Implements IERC7579Module.

  • type id: 3

Access control considerations

When implementing access control, use _msgSender() based on ERC2771 rather than msg.sender. This is necessary to identify the original sender of a forwarded transaction correctly.

Hooks

Implements IERC7579Module and IERC7579Hook.

  • type id: 4
IERC7579Hook.sol
interface IERC7579Hook is IERC7579Module {
    /**
     * @dev Called by the smart account before execution
     * @param msgSender the address that called the smart account
     * @param value the value that was sent to the smart account
     * @param msgData the data that was sent to the smart account
     *
     * MAY return arbitrary data in the `hookData` return value
     */
    function preCheck(address msgSender, uint256 value, bytes calldata msgData) external returns (bytes memory hookData);

    /**
     * @dev Called by the smart account after execution
     * @param hookData the data that was returned by the `preCheck` function
     *
     * MAY validate the `hookData` to validate transaction context of the `preCheck` function
     */
    function postCheck(bytes calldata hookData) external;
}
preCheck

Called before execution and returns arbitrary data (hookData).

postCheck

Called after execution to perform validation or cleanup based on the hookData returned by preCheck.

Additional considerations

The minimal approach

Smart accounts are a relatively new concept, and their optimal design is still evolving. The proposal therefore avoids prescribing specific implementations and defines only the minimum interfaces needed for interoperability.

The specification is based on two principles.

  • Build on lessons from existing smart accounts deployed in practice and from developing compatibility layers for those accounts.
  • Keep interfaces minimal and flexible enough to accommodate future architectural diversity.

Extensions

The standard should remain minimal while allowing innovative functionality and vendor-specific extensions.

Additional functionality needed in the future should therefore be proposed as independent ERC extensions without affecting the base standard. The recommended naming convention is [FEATURE] Extension for ERC-7579.

Execution mode design

Rather than defining separate functions for each way of executing calldata, the execution method is represented by a single bytes32 value.

The execution mode is structured as follows.

  • First byte (callType)
    • Call method, such as single execution, batch execution, or delegatecall.
  • Next byte (execType)
    • Whether to revert on failure or handle errors without reverting.
  • Next four bytes (unused)
    • Reserved for future standardization.
  • Next four bytes (modeSelector)
    • Custom execution mode identifier, with collision avoidance similar to Solidity selectors.
  • Remaining 22 bytes (modePayload)
    • Space for arbitrary additional data, such as hook addresses or configuration flags.

This structure makes future execution extensions easier, keeps code readable, and facilitates maintenance and auditing.

Identifying module types

Failing to distinguish modules with different roles, such as Validators and Executors, creates security risks through improper permissions.

For example, a Validator mistakenly treated as an Executor could execute arbitrary transactions on a smart account.

To prevent such risks, module types must be strictly distinguished by moduleTypeId.

Purpose of account IDs

Smart accounts can provide an accountId for identification. Frontends and libraries primarily use the ID to select appropriate behavior for the account type and version.

Alternatives include the following.

  • Declaring interface differences as in ERC165 → Less extensible and dependent on a predefined set of capabilities.
  • Returning a hash of accountId → Less readable and difficult for humans to interpret meaningfully.

A flexible and human-readable accountId is therefore considered the most practical approach.

Dependence on ERC4337 and future direction

The current specification depends on ERC4337 for smart account validation. Native Account Abstraction may appear on rollups and other L1s in the future. Such environments will need smart accounts that do not depend on ERC4337. At that point, ERC4337-related interfaces would need to be separated into extensions and incorporated as needed.

Because modular accounts in practical use currently exist on ERC4337, the specification first standardizes that implementation while allowing flexible migration in the future.

Compatibility

Accounts deployed through proxies

Existing smart accounts deployed using the proxy pattern can conform to ERC7579 by replacing their implementation logic. The upgrade functionality of the proxy makes it possible to deploy an implementation conforming to the new standard.

Non-upgradeable accounts

Even smart accounts deployed as standalone, non-upgradeable contracts may conform to ERC7579 under certain conditions. For example, a contract with a fallback function that supports adding external Fallback handlers could become compatible by installing a conforming adapter as a Fallback handler.

Reference implementation

IERC7579Account.sol
// SPDX-License-Identifier: CC0-1.0
pragma solidity ^0.8.21;

interface IERC7579Account {
    // MUST be emitted when a module is installed
    event ModuleInstalled(uint256 moduleTypeId, address module);

    // MUST be emitted when a module is uninstalled
    event ModuleUninstalled(uint256 moduleTypeId, address module);

    /**
     * @dev Executes a transaction on behalf of the account.
     * @param mode The encoded execution mode of the transaction. See ModeLib.sol for details
     * @param executionCalldata The encoded execution call data
     *
     * MUST ensure adequate authorization control: e.g. onlyEntryPointOrSelf if used with ERC-4337
     * If a mode is requested that is not supported by the Account, it MUST revert
     */
    function execute(bytes32 mode, bytes calldata executionCalldata) external;

    /**
     * @dev Executes a transaction on behalf of the account.
     *         This function is intended to be called by Executor Modules
     * @param mode The encoded execution mode of the transaction. See ModeLib.sol for details
     * @param executionCalldata The encoded execution call data
     *
     * MUST ensure adequate authorization control: i.e. onlyExecutorModule
     * If a mode is requested that is not supported by the Account, it MUST revert
     */
    function executeFromExecutor(bytes32 mode, bytes calldata executionCalldata)
        external
        returns (bytes[] memory returnData);

    /**
     * @dev ERC-1271 isValidSignature
     *         This function is intended to be used to validate a smart account signature
     * and may forward the call to a validator module
     * @param hash The hash of the data that is signed
     * @param data The data that is signed
     *
     * MAY forward the call to a validator module
     * The validator module MUST be called with isValidSignatureWithSender(address sender, bytes32 hash, bytes signature)
     * with sender being the msg.sender of this function
     * MUST sanitize the data parameter to before forwarding it to the validator module
     */
    function isValidSignature(bytes32 hash, bytes calldata data) external view returns (bytes4);

    /**
     * @dev Returns the account id of the smart account
     * @return accountImplementationId the account id of the smart account
     *
     * MUST return a non-empty string
     * The accountId SHOULD be structured like so:
     *        "vendorname.accountname.semver"
     * The id SHOULD be unique across all smart accounts
     */
    function accountId() external view returns (string memory accountImplementationId);

    /**
     * @dev Function to check if the account supports a certain execution mode (see above)
     * @param encodedMode the encoded mode
     *
     * MUST return true if the account supports the mode and false otherwise
     */
    function supportsExecutionMode(bytes32 encodedMode) external view returns (bool);

    /**
     * @dev Function to check if the account supports a certain module typeId
     * @param moduleTypeId the module type ID according to the ERC-7579 spec
     *
     * MUST return true if the account supports the module type and false otherwise
     */
    function supportsModule(uint256 moduleTypeId) external view returns (bool);

    /**
     * @dev Installs a Module of a certain type on the smart account
     * @param moduleTypeId the module type ID according to the ERC-7579 spec
     * @param module the module address
     * @param initData arbitrary data that may be required on the module during `onInstall`
     * initialization.
     *
     * MUST implement authorization control
     * MUST call `onInstall` on the module with the `initData` parameter if provided
     * MUST emit ModuleInstalled event
     * MUST revert if the module is already installed or the initialization on the module failed
     */
    function installModule(uint256 moduleTypeId, address module, bytes calldata initData) external;

    /**
     * @dev Uninstalls a Module of a certain type on the smart account
     * @param moduleTypeId the module type ID according the ERC-7579 spec
     * @param module the module address
     * @param deInitData arbitrary data that may be required on the module during `onInstall`
     * initialization.
     *
     * MUST implement authorization control
     * MUST call `onUninstall` on the module with the `deInitData` parameter if provided
     * MUST emit ModuleUninstalled event
     * MUST revert if the module is not installed or the deInitialization on the module failed
     */
    function uninstallModule(uint256 moduleTypeId, address module, bytes calldata deInitData) external;

    /**
     * @dev Returns whether a module is installed on the smart account
     * @param moduleTypeId the module type ID according the ERC-7579 spec
     * @param module the module address
     * @param additionalContext arbitrary data that may be required to determine if the module is installed
     *
     * MUST return true if the module is installed and false otherwise
     */
    function isModuleInstalled(uint256 moduleTypeId, address module, bytes calldata additionalContext)
        external
        view
        returns (bool);
}

Security

Risks of delegatecall

When a smart account uses delegatecall, the code of the target contract directly operates on the account's storage, so particular care is required.

Calling a malicious contract through delegatecall risks unauthorized changes to the account's storage or state. A mechanism is needed to verify in advance that the target can be trusted.

The onInstall and onUninstall functions invoked when installing or uninstalling modules may introduce the following problems.

  • Reentrancy attacks
    • Callbacks may cause the account's internal state to be modified in an unexpected order.
  • Uninstallation denial
    • A malicious module can obstruct its removal by deliberately reverting in onUninstall.

Preventing these problems requires explicit design of reentrancy protection and exception handling.

Overwriting risks for single-module types

For a type that assumes only one module is active, such as a Fallback handler, installing a new module using installModule may cause unintended behavior if the existing module is not properly uninstalled.

Installing another module while the old module remains may preserve old state or side effects.

Insufficient authorization in Fallback handlers

A Fallback handler with inadequate authorization controls may allow third parties to call arbitrary functions. In particular, controls based only on msg.sender may be bypassed because of ERC2771 forwarding.

Denial-of-service risks from Hooks

Hooks can execute preCheck and postCheck before and after transactions, but introduce the following risks.

  • A malicious Hook reverting in preCheck or postCheck may prevent all account operations.
  • Installing untrusted Hooks may make the account deliberately unusable (DoS).

Bypassing configuration operations through self-calls

Configuration functions such as module installation currently assume single operations. If the account itself (address(this)) can call these functions, multiple configuration operations can be nested and executed as a batch. Consequently, restrictions may be bypassed through internal self-calls even if external calls are strictly controlled.

References

zeroknots (@zeroknots), Konrad Kopp (@kopy-kat), Taek Lee (@leekt), Fil Makarov (@filmakarov), Elim Poon (@yaonam), Lyu Min (@rockmin216), "ERC-7579: Minimal Modular Smart Accounts [DRAFT]," Ethereum Improvement Proposals, no. 7579, December 2023. [Online serial]. Available: https://eips.ethereum.org/EIPS/eip-7579.

References

zeroknots (@zeroknots), Konrad Kopp (@kopy-kat), Taek Lee (@leekt), Fil Makarov (@filmakarov), Elim Poon (@yaonam), Lyu Min (@rockmin216), "ERC-7579: Minimal Modular Smart Accounts [DRAFT]," Ethereum Improvement Proposals, no. 7579, December 2023. [Online serial]. Available: https://eips.ethereum.org/EIPS/eip-7579.

Conclusion

This article covered ERC7579, a proposal for minimal modular smart accounts. I hope it helped clarify the mechanism.

If you have questions, feel free to reach out via Twitter DM.

Twitter @cardene777

I also publish on the following platforms.

https://chaldene.net/