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 ERC6900, which proposes interfaces for modular smart contract accounts and account plugins.

This article translates, summarizes, and expands on the material below.

At the time of writing, ERC6900 was in the Draft stage. Please note that its contents may change in the future.

Overview

This proposal seeks to standardize interfaces for smart contract accounts and the code modules, known as plugins, that can be used within them. A smart contract is a program that executes particular logic or operations within an account. This proposal separates the logic available within an account so that individual components can be managed in separate pieces of code. This allows account functionality to be composed flexibly as needed.

The proposal builds on the ERC4337 standard.

See the following article for more on ERC4337.

[ERC4337] Understanding Account Abstraction Without Protocol Changes

It also draws inspiration from ERC2535 when defining interfaces for updating functionality and retrieving information.

See the following article for more on ERC2535.

[ERC2535] 💎 Understanding the Diamond Pattern

This improves compatibility with other smart contracts and tools.

Specifically, the proposal divides account functionality into three categories. Functionality for each category is implemented in external contracts. Finally, it defines how execution from the account should behave.

Defining the expected behavior of account execution Defining the expected behavior of account execution is important to ensure that smart contract operations and functionality work as intended.

Trigger detection Detect the trigger for smart contract execution. This refers, for example, to execution initiated by an external transaction or when certain conditions are met.

Action initiation When a trigger is detected, an action defined within the smart contract is initiated. Examples include calling particular functions or methods, updating data, and initiating new transactions.

Action execution The defined action is executed. This includes executing code within the smart contract and interacting with external contracts.

Result handling Once the action finishes executing, its result is handled appropriately. Examples include checking transaction success or failure, updating data, and emitting events.

This approach allows functionality to be managed and composed more effectively when building complex smart contracts.

Motivation

ERC4337 aims to abstract execution and validation logic within individual smart contract accounts.

Limitations of ERC4337 ERC4337 has the following limitations.

Lack of customizability To create a new contract account, developers must either fork an existing implementation and add functionality or start with a base implementation and rebuild standard components alongside a new feature set. In both cases, developers must audit and redeploy the entire account. This degrades the developer experience, limits the potential of contract accounts to serve as application-layer platforms, and introduces problems such as vendor lock-in and user fragmentation.

Vendor lock-in

With EOAs, users can readily migrate their accounts to other EOA-based wallets, for example using a seed phrase. This allows users to choose both their wallet vendor and the functionality available to them. Contract accounts, by contrast, cannot easily be transferred between wallet vendors, and there is no standard interoperability implementation guaranteeing feature portability. Consequently, when different vendors offer different desired features, users may need multiple accounts, degrading the user experience and fragmenting their activity.

User fragmentation

Consider a concrete example. Alice has a contract account created by vendor A. Suppose she wants to play a Web3 game supported by vendor B, and the developers have enhanced the game using features such as batching and multicall. Alice must choose between playing a game with a relatively poor user experience that supports vendor A and creating a new account supported by the game using vendor B. This fragments her assets and negatively affects both Alice, through increased wallet-management overhead, and the game developers, through reduced access to on-chain data about users.

Security Forking and rebuilding accounts to add functionality duplicates work and increases the complexity of DApp and wallet integrations. It also increases exposure to security vulnerabilities.

New account functionality can be added by customizing logic associated with the validation and execution steps. Examples include session keys, subscriptions, spending limits, and role-based access control. Some of these features are currently implemented natively within individual smart contract accounts, while others are implemented through plugin systems. Examples of plugin systems include Safe modules and ZeroDev plugins.

https://docs.zerodev.app/extend-wallets/build-a-plugin

Managing multiple accounts, however, degrades the user experience. Accounts become fragmented across different feature sets and security configurations, and plugin developers must choose which platforms to support. This can lead to platform dependence and duplicated development work.

The proposal provides a standard to encourage collaboration between plugin developers and wallet developers. The standard defines modular smart contract accounts that can support all compliant plugins. This makes user data easier to migrate and removes the need for plugin developers to choose a specific account implementation.

Modular smart contract accounts Think of this as dividing a smart account into composable LEGO pieces and assembling them as needed. This addresses the problem of account customization and allows developers to focus on new account features rather than building entirely new accounts.

MSCA_Shared_Components_Diagram.png

0_nObXBhfgwEO5P0ZI.png

Source: https://blog.rhinestone.wtf/part-1-modular-account-abstraction-for-everyone-else-84567422bc46

MSCA stands for Modular Smart Contract Accounts.

Features that modules can implement Modules can implement features such as the following.

  • Support for various signature schemes.
  • Triggering particular actions when tokens are transferred.
  • Daily spending limits.
  • Authorization to send additional funds without requiring the owner's consent.
  • Recurring transactions using session keys.
  • Scheduled and automated transactions.
  • Social recovery.

Drawing inspiration from the diamond pattern in ERC2535, the proposal adopts function-selector-based execution routing and proposes similarly composable accounts.

Diamond pattern A diamond contains multiple distinct facets, each with its own characteristics. Similarly, a smart contract account can consist of multiple components with different functions, using function selectors.

A function selector identifies the function specified in an external transaction or call to a smart contract. The proposal uses this mechanism to determine which component executes a particular function. In other words, the goal is to execute the code in the corresponding component when a particular function is called.

This idea allows different functions to be composed within an account, making account design more flexible. Properly routing account functionality through function selectors improves the user experience and makes integrating plugins and features easier.

However, this standard does not require a multi-facet proxy pattern.

Multi-facet proxy pattern This is a technique for combining contracts with different functionality within a single account. However, the proposal does not require this pattern.

The diamond-inspired approach enables a simpler design than a multi-facet proxy pattern. Each functional component is independent, and function selectors select the appropriate component for execution, eliminating the need for a complex proxy structure. This can make smart contract management and security improvements easier.

These plugins include execution logic, validation schemes, and hooks. Validation schemes define the conditions under which a smart contract account authorizes actions executed on its behalf, while hooks enable pre- and post-execution control.

Plugins are extensions integrated into smart contract accounts. These plugins contain three main elements.

  1. Execution logic: A plugin contains logic for executing a particular function or set of functions. Examples include logic for processing payments, updating data, and initiating transactions. This allows new functionality to be added to a smart contract account or existing functionality to be extended.

  2. Validation scheme: A validation scheme defines the conditions under which plugin execution is authorized. Before executing a particular action, the smart contract account checks whether the action is valid according to the validation scheme. For example, a validation scheme could check that a transaction does not exceed the balance of a particular account.

  3. Hooks: Hooks insert additional processing before or after plugin execution. Pre-hooks perform operations or checks before execution, while post-hooks perform subsequent processing or control the result after execution. This allows plugins to perform particular operations before and after an action.

In summary, plugins are modules that extend smart contract account functionality and contain execution logic, validation schemes, and hooks. This makes smart contract account behavior more flexible and customizable, facilitating the integration of new features and improvements to security.

Accounts conforming to the proposal support modular and upgradeable execution and validation logic. The standard for smart contract accounts aims to facilitate secure plugin development and enable a high degree of interoperability.

Goals

  1. Provide a standard for writing validation, execution, and hook functions for smart contract accounts.
  2. Provide a standard for compliant accounts to add, update, remove, and inspect plugins.

Specification

Definitions

An account (or smart contract account, SCA) is a smart contract that sends transactions and holds digital assets. It implements the IAccount interface defined in ERC4337. This allows the account to receive and process transactions and manage digital assets.

A modular account (or modular smart contract account, MSCA) is an account that supports modular functionality. Modular functions are components used to customize account behavior. The details are described below.

1. Validation functions

These functions verify the caller's legitimacy and authorization to use the account. Before executing an action, they check whether the caller is authorized to perform it.

Validation functions Specifically, they check whether the appropriate permissions and conditions for an action are satisfied before it is executed.

For example, when an account attempts an action such as transferring assets or changing information, a validation function checks whether the necessary conditions and approvals for that action are satisfied. As a simple example, if an account attempts to transfer assets, validation checks whether the transfer is legitimate by examining its conditions and whether the caller is authorized to make it, so the transfer executes only if it is valid.

This prevents unauthorized actions and operations. Validation functions play an important role in securing accounts and ensuring their proper operation.

2. Execution functions

These functions execute custom logic authorized by the account. This allows the account's functionality to be extended and specific custom operations to be performed.

Execution functions An account is a smart contract that accepts and processes transactions and operations. Beyond basic operations, however, it may need to perform custom processing tailored to specific needs or requirements. Execution functions are used in such cases.

For example, if particular processing should run automatically when an event occurs, that processing can be implemented within an execution function. Execution functions can also change account behavior or add new functionality.

A concrete example is swapping token A for token B and depositing it into protocol X when a button is pressed.

Execution functions give users the flexibility to add custom behavior and operations beyond an account's basic functionality. This broadens the account's potential uses and enables behavior tailored to particular purposes.

3. Hooks

These functions perform particular actions before or after execution functions. Hooks allow additional operations to be incorporated before and after execution.

Hooks For example, if a particular condition needs to be checked before an action executes, a pre-hook can check that condition. If particular processing is needed after the action executes, a post-hook can perform it.

Hooks extend account functionality by adding custom processing to particular operations. For example, hooks can be used to send a notification or record an operation log when a particular event occurs.

Hooks are a powerful tool for customizing account behavior and are useful for adding or adjusting operations to suit particular requirements. This improves account flexibility and functionality.

There are two types of validation functions.

User Operation Validator functions

These functions validate user operations (actions) under ERC4337. They verify whether particular actions are valid.

User Operation Validator functions They check whether a particular user operation can be executed appropriately within an account. User operations have specific conditions and requirements, and the validator checks whether they are met.

For example, when an account attempts to transfer assets, the user operation validator checks whether the conditions and restrictions for the transfer are satisfied. If the conditions are not met, the transfer is rejected or an error occurs.

User operation validators check the validity of particular actions within an account, helping ensure proper account operation and security. This prevents incorrect operations and unauthorized actions.

Runtime Validator functions

These functions run before execution functions when the call is not made through a user operation. They check particular conditions, for example whether the owner initiated execution.

Runtime Validator functions For example, suppose a particular execution function within an account must check whether it is being executed by the owner. In this case, before the execution function is called, the runtime validator checks whether the caller is the account owner.

A runtime validator can also check whether a particular operation is being performed by the only user authorized to perform it. This helps ensure the legitimacy of execution functions within the account.

Because runtime validators execute before execution functions, they help ensure the safety and correctness of those functions. If the necessary conditions or requirements are not satisfied, the execution function does not execute or an error occurs.

  • An execution function defines the main execution step of a modular account. It is a core part of account behavior and contains the concrete implementation of custom operations.

  • Standard execution functions are two specific execution functions incorporated into the modular account. They are implemented within the account itself and provided directly by the account rather than by plugins.

  • Hooks perform additional operations and checks before or after execution functions. They provide prior control and subsequent processing, allowing account behavior to be customized.

  • Plugins are smart contracts that provide additional functionality to modular accounts. This functionality includes execution functions, validation functions, and hooks. Plugins allow account functionality to be extended flexibly.

Plugin function signatures

User operation validator functions and pre-user-operation validation hooks

  • Code
    • function(UserOperation calldata, bytes32) external returns (uint256)
  • Description
    • This function receives a user operation and its hash from the account.
    • It must then return validation data packing authorizer, validUntil, and validAfter.
    • The packing order places validAfter in the first 6 bytes, validUntil in the next 6 bytes, and authorizer in the final 20 bytes.
    • However, pre-user-operation validation hooks must not return an authorizer value other than 0 or 1.

Runtime validator functions and pre-runtime validation hooks

  • Code
    • function(address, uint256, bytes calldata) external
  • Description
    • This function receives the caller's address, call value, and supplied calldata from the account.
    • It checks particular conditions and executes before the execution function.
    • If the function needs to revert, it must revert.

Pre-execution hooks

  • Code
    • function(address, uint256, bytes calldata) external returns (bytes memory)
  • Description
    • This function receives the caller's address, call value, and supplied calldata from the account.
    • This function executes before the execution function and can configure operations to be performed before execution.
    • The return value must contain context to pass to the post-execution hook.
    • However, it may also return an empty byte array.

Post-execution hooks

  • Code
    • function(bytes calldata) external
  • Description
    • This function receives context returned by the corresponding pre-execution hook.
    • It executes after the execution function and is used to perform post-execution operations.
    • If the function needs to revert, it must revert.

Execution functions

  • Description
    • Execution functions may have arbitrary function signatures.
    • This enables extending the account's functionality and executing particular custom operations.

These function signatures specify the format of functions defined within plugins and are used to control account logic effectively.

Overview

A modular account handles two types of calls. One is a call from the entry point through ERC4337, and the other is a direct call from an externally owned account (EOA) or another smart contract. The standard supports both use cases.

Calls to a smart contract account can be broken down into five steps, as shown in the diagram below.

The first two steps (1 and 2) verify whether the caller is authorized to make the call. The third step (pre-execution hook, Step 3) performs checks or updates before execution. The fourth step (execution, Step 4) performs the defined task or operation. The fifth step (post-execution hook, Step 5) performs additional actions or validation after execution.

Each step is modular, supporting different implementations for different execution functions and allowing multiple steps to be composed through hooks. This enables flexible, extensible, programmable accounts.

MSCA_Two_Call_Paths_Diagram.png

Interface

A modular account must implement the IAccount interface defined in ERC4337. This interface provides rules and guidelines enabling modular accounts to provide the required functionality.

This design provides a flexible mechanism that enables modular accounts to handle requests from different callers and makes their functionality easy to extend.

Common types

The following types are shared among the interfaces below. Implementers may use the underlying types instead of type aliases.

This means that the same data types or structures can be reused across multiple interfaces. For example, if multiple interfaces handle the same kind of data, it can be defined as a shared data type and used in each interface. Shared data types improve code reusability and reduce complexity.

Implementers may also use the underlying types. Specifying concrete data types directly instead of type aliases can make code clearer and simpler.

This guideline supports efficient programming while maintaining data type consistency when combining interfaces.

javascript
type FunctionReference is bytes24;

type HookGroupId is uint32;

struct Execution {
    address target;
    uint256 value;
    bytes data;
}

Variables of the FunctionReference type must satisfy certain requirements. The variable contains two components.

  1. First 20 bytes These represent an address. An address identifies a smart contract, externally owned account, or similar entity. This address component identifies where the function resides.

  2. Remaining 4 bytes These constitute the function selector, which identifies the function. A function selector is a hash-derived identifier generated from the function name and parameter types. This identifies exactly which function to call.

By representing both the function location (address) and identifier (function selector) in a single variable, this structure makes programs simpler and more efficient. Combining function access and invocation information in one variable makes code easier to understand and maintain.

IPluginUpdate.sol

Modular accounts may implement this interface. This enables support for modifying plugins.

It provides a way to add new features or fixes to a modular account. If an account implements this interface, plugin functionality and behavior can be modified later. Specifically, it is used when adding new plugins or modifying existing ones.

Implementing this interface gives modular accounts flexibility and enables them to support future changes and updates. This allows smart contract functionality to be extended and adjusted to meet new requirements.

javascript
interface IPluginUpdate {
    enum PluginAction {
        ADD,
        REPLACE,
        REMOVE
    }

    enum ValidatorType {
        USER_OP_VALIDATOR,
        RUNTIME_VALIDATOR
    }

    enum HookType {
        PRE_EXEC_HOOK,
        POST_EXEC_HOOK,
        PRE_USER_OP_VALIDATION_HOOK,
        PRE_RUNTIME_VALIDATION_HOOK
    }

    struct ExecutionUpdate {
        PluginAction action;
        address pluginAddress;
        bytes4[] executionSelectors;
        ValidatorUpdate[] validatorUpdates;
    }

    struct ValidatorUpdate {
        PluginAction action;
        ValidatorType validatorType;
        FunctionReference functionReference;
    }

    struct HookGroupUpdate {
        PluginAction action;
        HookGroupId hookGroupId;
        bytes4[] executionSelectors;
    }

    struct HookUpdate {
        PluginAction action;
        HookGroupId hookGroupId;
        HookType hookType;
        FunctionReference functionReference;
    }

    event ExecutionPluginUpdate(ExecutionUpdate[] executionUpdates);

    function updatePlugins(
        ExecutionUpdate[] calldata executionUpdates,
        HookUpdate[] calldata hookUpdates,
        HookGroupUpdate[] calldata hookGroupUpdates,
        Execution[] calldata initializationCalls
    ) external;
}
PluginAction

Overview This enum represents actions performed on plugins. Three actions are defined: ADD, REPLACE, and REMOVE.

Details It represents actions such as adding plugins, replacing existing plugins, and removing plugins.


ValidatorType

Overview This enum represents validator types. Two types are defined: user operation validators (USER_OP_VALIDATOR) and runtime validators (RUNTIME_VALIDATOR).

Details It distinguishes between validation types such as user operation validators and runtime validators.


HookType

Overview This enum represents hook types. Four types are defined: pre-execution hooks (PRE_EXEC_HOOK), post-execution hooks (POST_EXEC_HOOK), pre-user-operation validation hooks (PRE_USER_OP_VALIDATION_HOOK), and pre-runtime validation hooks (PRE_RUNTIME_VALIDATION_HOOK).

Details It distinguishes between different hook types and represents their respective roles.


ExecutionUpdate

Overview This struct represents update information for execution functions.

Details It contains update information for adding, replacing, and removing execution functions. It includes the plugin action, plugin address, execution function selector, and validator update information.


ValidatorUpdate

Overview This struct represents validator update information.

Details It contains update information for adding, replacing, and removing validators, including the plugin action, validator type, and function reference.


HookGroupUpdate

Overview This struct represents hook group update information.

Details It contains update information for adding, replacing, and removing hook groups. It includes the plugin action, hook group identifier, and execution function selector.


HookUpdate

Overview This struct represents hook update information.

Details It contains update information for adding, replacing, and removing hooks. It includes the plugin action, hook group identifier, hook type, and function reference.


ExecutionPluginUpdate

Overview An event that reports updates to execution functions.

Details This event is triggered when execution functions are updated. The arguments include an array of execution function update information.


updatePlugins

Overview Performs plugin updates.

Details It is used to update execution functions, hooks, and initialization calls. Changes such as adding, replacing, or removing execution functions and hooks can be applied.

Arguments The function arguments include execution function updates, hook updates, hook group updates, and initialization call information.

Return value None.


IPluginLoupe.sol

The plugin inspection interface is an interface that modular accounts may implement to support on-chain visibility into their plugin configuration.

It allows the settings and configuration of plugins installed in a modular account to be inspected on-chain. Information such as how plugins are configured and which functions are associated with each plugin can be viewed transparently on-chain.

Implementing this interface allows users and other smart contracts to retrieve information about a modular account's plugin configuration easily and perform appropriate operations. This improves on-chain visibility and transparency and enables more efficient smart contract operations.

javascript
interface IPluginLoupe {
    struct ExecutionPluginConfig {
        address executionPluginAddress;
        HookGroupId[] hookGroupIds;
        HookGroup[] hookGroups;
        FunctionReference userOpValidator;
        FunctionReference runtimeValidator;
    }

    struct HookGroup {
        FunctionReference preUserOpValidation;
        FunctionReference preRuntimeValidation;
        FunctionReference preExec;
        FunctionReference postExec;
    }

    function getExecutionFunctionConfig(bytes4 executionSelector)
        external
        view
        returns (ExecutionPluginConfig memory);

    function getStandardExecutionValidators()
        external
        view
        returns (FunctionReference[] memory userOpValidators, FunctionReference[] memory runtimeValidators);
}
ExecutionPluginConfig

Overview A struct storing execution plugin configuration information. It includes the execution plugin address, associated hook groups, and validator function information.

Details:

  • executionPluginAddress
    • Stores the execution plugin address.
  • hookGroupIds
    • An array storing IDs of associated hook groups.
  • hookGroups
    • An array storing details of associated hook groups.
  • userOpValidator
    • Stores the user operation validator function reference.
  • runtimeValidator
    • Stores the runtime validator function reference.

HookGroup

Overview A struct storing hook group configuration information. It includes references to functions such as pre-execution and post-execution hooks.

Details

  • preUserOpValidation
    • Stores the pre-user-operation validation hook function reference.
  • preRuntimeValidation
    • Stores the pre-runtime validation hook function reference.
  • preExec
    • Stores the pre-execution hook function reference.
  • postExec
    • Stores the post-execution hook function reference.

getExecutionFunctionConfig

Overview Retrieves execution plugin configuration information for the specified execution selector.

Arguments

  • executionSelector
    • The execution selector (function identifier).

Return value

  • ExecutionPluginConfig
    • Returns execution plugin configuration information for the specified execution selector.

getStandardExecutionValidators

Overview Retrieves information about validator functions for standard execution.

Return value

  • userOpValidators
    • An array of user operation validator functions.
  • runtimeValidators
    • An array of runtime validator functions.

IStandardExecutor.sol

Modular accounts must implement this interface to support open-ended execution. In other words, it provides a mechanism for supporting different execution functions and extending account functionality.

Implementing this interface allows modular accounts to call various execution functions and customize their functionality and behavior.

The standard execution interface is an important component that allows modular accounts to offer open-ended execution functionality, facilitating flexible programming and modifications to account behavior.

javascript
interface IStandardExecutor {

    function execute(address target, uint256 value, bytes calldata data, FunctionReference validator)
        external
        payable;

    function executeBatch(Execution[] calldata executions, FunctionReference validator) external payable;
}

execute

Overview Sends a transaction to the specified target address and executes custom logic. A validator function can be specified to perform checks before execution when needed.

Details This function sends a transaction to the specified target address. An arbitrary value in ether and data can also be specified when sending the transaction. A validator function can be specified to perform checks before execution. This function enables custom logic to be executed.

Arguments

  • target
    • The destination address for the transaction (a smart contract or EOA).
  • value
    • The amount of ether to send (value).
  • data
    • The data to include in the transaction.
  • validator
    • The address of the validator function called before execution.

Return value: None.

executeBatch

Overview Executes multiple operations together as a batch. A validator function can be specified for each execution.

Details: This function is used to batch multiple executions. It receives information about multiple executions in an array called executions and performs each execution using the necessary information. A validator function can also be specified for each execution to perform checks before execution.

Arguments:

  • executions
    • An array of type Execution containing information about multiple executions.
  • validator
    • The address of the validator function called before execution.

Return value: None.

Expected behavior

Calling updatePlugins

  • The updatePlugins function receives execution updates, hook updates, and hook group updates and executes them sequentially.
  • It can optionally receive initialization call information.
Sequential execution of update operations
  • The received execution updates, hook updates, and hook group updates are executed sequentially.
  • Each update operation modifies the configuration of plugins within the account.
Executing initialization calls
  • For each element in the initialization call array, make a call using the specified address and data.
  • This enables account initialization and additional processing after updates.
Executing initialization calls
  • For each element in the initialization call array, make a call using the specified address and data.
  • This enables account initialization and additional processing after updates.

⚠️ Caution

  • Updating plugins is a very powerful capability.
  • The security of updatePlugins affects the security of the entire account, so appropriate security measures and access control are necessary.
  • Modular account implementers must implement updatePlugins with appropriate security considerations and access control.

Calling validateUserOp

  • The validateUserOp function is called on the modular account by the entry point.
  • This function validates user operations.
User operation validation procedure
  1. Identify the user operation validator corresponding to the selector (function identifier) in the first 4 bytes of the user operation's callData.
  2. If no validator is defined for the selector, or if callData is shorter than 4 bytes, execution reverts.
  3. If the selector has associated hook groups, execute their hooks in order.
    • If any hook reverts, the external call also reverts.
  4. If a hook returns an authorizer value other than 0 or 1, execution reverts.
  5. If the authorizer value is 1, indicating an invalid signature, the external call must also return 1.
  6. If time constraints are validated using validUntil or validBefore values, the resulting validation data is the intersection of all supplied time constraints.
Standard execution functions
  1. If the target is a standard execution function, the modular account verifies whether the supplied validator was previously associated with standard execution functions.
  2. If the association exists, execute the specified user operation validator.
  3. Call the validator function with the user operation and its hash as parameters, and return the resulting validation data.
  4. If necessary, update the validation data using the return values of pre user operation validation hooks, and ultimately return it from validateUserOp.

Calling execution functions

When a function that is not defined natively is called on a modular account (MSCA), the plugin configuration associated with the corresponding selector (function identifier) must be found through updatePlugins. If no corresponding plugin is found, the account must revert (abort processing). Otherwise, it must perform the following steps.

If the modular account implements the functions of IPluginUpdate and IStandardExecutor natively, it must also perform the same steps for those functions. Other natively implemented functions may perform these steps.

The execution procedure is as follows.

  1. If the caller is not the entry point, look up the associated runtime validator function. If none exists, execution must revert (abort processing). The modular account executes all pre runtime validation hooks and then calls the runtime validator function. These functions must receive the caller, value, and execution function calldata as parameters. If any function reverts, execution also reverts.

  2. If pre execution hook functions are defined in hook groups associated with the execution function, call them with the caller, value, and execution function calldata as parameters. If any of these hooks returns data, retain the data until the corresponding post execution hook is called. This operation uses the call opcode. If any hook reverts, execution also reverts.

  3. Execute the execution function.

  4. If associated post execution hook functions are defined, execute them. If a pre execution hook in the same hook group returned data to the account, pass that data as a parameter to the post execution hook. This operation uses the call opcode. If any hook reverts, execution also reverts.

⚠️ Caution If pre runtime validation hooks, pre execution hook functions, or post execution hook functions are not defined for the execution function, skip the undefined functions. The execution function itself runs and may change the account state.

This allows modular accounts to process external function calls correctly and execute the associated validators and hooks appropriately. However, accurate implementation of these procedures and appropriate security measures are essential.

Plugin update operations

When updatePlugins is called with PluginAction.ADD

Perform the following operations.

  • For each execution selector, add the contract corresponding to the specified pluginAddress as the implementation contract. This defines a new execution function whose implementation resides in the specified contract.

  • Associate each validator function reference with its parent execution function according to the specified validatorType. This enables validation before calling execution functions, improving security.

  • Each hook update associates the specified hookType with the group identified by hookGroupId. However, if the same hook type is already defined in that group, the update reverts.

  • For each hook group update, add the specified hookGroupUpdates to the corresponding execution selector. This adds pre- or post-execution processing as hooks for particular execution functions.

Execution function selectors must be unique when added. This prevents the same execution selector from being added more than once.

When updatePlugins is called with PluginAction.REPLACE

  • Each execution selector or function reference must overwrite the previous definition.
  • Existing associated functions not specified in this operation must not be changed.

When updatePlugins is called with PluginAction.REMOVE

  • The execution function definition and associated function definitions must be removed.

When calling updatePlugins, the specified validators and hooks are executed beforehand. This performs the necessary checks and processing before the update operation.

In particular, post execution hook functions defined before the update are executed after the update. This enables a proper transition from the previous account configuration to the new one.

These procedures allow modular accounts to add, update, and remove plugins securely while retaining appropriate functionality. Implementing the operations above carefully is important to maintain account security and operational consistency.

Additional notes

Accounts conforming to ERC4337 must implement the IAccount interface, which the source describes as combining validation and execution in a single validateUserOp method. One of the principal design goals of this proposal is to separate these functions and extend account functionality. At the same time, it preserves the benefits of account abstraction.

The function routing pattern in ERC2535 is a logical starting point for building accounts with multiple functions. Another principal design goal is to generalize execution calls across multiple implementation contracts. However, the strict diamond pattern does not allow customizing validation schemes for individual execution functions in the context of validateUserOp and requires delegatecall.

The proposal builds on ERC4337 and includes several interfaces inspired by ERC2535. First, it standardizes a set of modular plugins allowing smart contract developers to compose validation, execution, and hook logic flexibly. It also proposes interfaces such as IPluginUpdate and IPluginLoupe, providing methods to update and query execution functions, validation functions, and hooks.

This approach extends smart contract account functionality while balancing flexibility and efficiency.

ERC6900 features

Customizable transaction fees

  • Developers can customize transaction fees under particular conditions.
  • This flexibility may enable smoother operations and reduce costs for users interacting with DApps.

Enhanced security through signature validation

  • Implements signature validation to enhance transaction security.
  • This improves the trustworthiness of interactions between users and DApps and can significantly reduce the risk of unauthorized access.

Seamless interoperability

  • Encourages interoperability with other standards and facilitates integration with various blockchain platforms.

Backwards compatibility

No backwards compatibility issues have been identified.

Reference implementation

At the time of writing, a concrete reference implementation had not yet been provided (TBD).

Security considerations

Further discussion is needed regarding the potential security implications of new features and changes. These should be thoroughly examined and evaluated from a security perspective.

Citation

Adam Egyed (@adamegyed), Fangting Liu (@trinity-0111), "ERC-6900: Modular Smart Contract Accounts and Plugins [DRAFT]," Ethereum Improvement Proposals, no. 6900, April 2023. [Online serial]. Available: https://eips.ethereum.org/EIPS/eip-6900.

References

https://blog.rhinestone.wtf/part-1-modular-account-abstraction-for-everyone-else-84567422bc46

https://medium.portto.com/erc-6900-modular-account-abstraction-what-it-means-for-smart-contract-wallets-cd0b1fd2a885

https://mirror.xyz/konradkopp.eth/7Q3TrMFgx2VbZRKa7UEaisIMjimpMABiqGYo00T9egA

Conclusion

This article covered ERC6900, which proposes interfaces for modular smart contract accounts and account plugins. I hope you found it useful.