EIPs Explained

ERC-7579 · Draft · ERC · 2023-12-14

ERC-7579: Minimal Modular Smart Accounts

A minimal common interface for modular smart accounts and their plug-in modules (validators, executors, fallback handlers, hooks), so one module can work across many account implementations instead of locking users into a single vendor.

What problem does it solve?

Smart contract accounts increasingly move features into external modules: passkey or multisig validation, session keys, spending limits, recovery. Each account vendor designed its own module system, so a module written for one account did not work on another, and users were tied to whichever vendor they started with.

ERC-7579 defines the smallest set of interfaces that lets accounts and modules interoperate, while leaving account internals open so vendors can keep innovating.

How it works

Module types, identified by a numeric id (one module may be several types):

Id Type Role
1 Validator Checks validateUserOp and ERC-1271 signatures
2 Executor Can make the account execute calls via executeFromExecutor
3 Fallback handler Adds functions to the account through its fallback
4 Hook preCheck / postCheck around executions

Every module implements onInstall(data), onUninstall(data) and isModuleType(id).

Accounts must implement:

  • execute(bytes32 mode, bytes executionCalldata) and executeFromExecutor(...), the latter callable only by installed executors.
  • installModule, uninstallModule, isModuleInstalled, emitting ModuleInstalled / ModuleUninstalled. Accounts must keep module types apart so that, for example, a validator cannot call executeFromExecutor.
  • accountId() (e.g. "vendor.account.semver"), supportsExecutionMode(mode), supportsModule(typeId).
  • ERC-1271 isValidSignature, optionally forwarded to a validator via isValidSignatureWithSender.

The execution mode is a packed bytes32: callType (1 byte: 0x00 single, 0x01 batch, 0xfe staticcall, 0xff delegatecall), execType (1 byte: 0x00 revert on failure, 0x01 try and continue), 4 unused bytes, a 4-byte custom mode selector, and a 22-byte payload. A single call encodes abi.encodePacked(target, value, callData); a batch is abi.encode(Execution[]).

Fallback handlers are invoked with call/staticcall, and the original sender is appended per ERC-2771. Validation currently assumes ERC-4337 PackedUserOperations.

Sample code

Encoding a batch execution (ethers v6):

import { AbiCoder, Interface } from "ethers";

// mode: callType=0x01 (batch), execType=0x00 (revert on failure), rest zero
const MODE_BATCH = "0x01" + "00".repeat(31);

const calls = [
  { target: token, value: 0n, callData: erc20.encodeFunctionData("approve", [router, amount]) },
  { target: router, value: 0n, callData: swapCalldata },
];
const executionCalldata = AbiCoder.defaultAbiCoder().encode(
  ["tuple(address target,uint256 value,bytes callData)[]"], [calls]);

const account = new Interface(["function execute(bytes32 mode, bytes executionCalldata)"]);
const userOpCallData = account.encodeFunctionData("execute", [MODE_BATCH, executionCalldata]);

A minimal validator skeleton:

contract OwnerValidator /* is IERC7579Validator */ {
    mapping(address account => address) public owner;

    function onInstall(bytes calldata data) external { owner[msg.sender] = abi.decode(data, (address)); }
    function onUninstall(bytes calldata) external { delete owner[msg.sender]; }
    function isModuleType(uint256 id) external pure returns (bool) { return id == 1; }
    // validateUserOp(...) and isValidSignatureWithSender(...) check signatures against owner[msg.sender]
}

Things to know

  • Status is Draft; the Security Considerations section still says "needs more discussion".
  • delegatecall mode runs foreign code in the account's storage context. Only allow trusted targets.
  • Modules can revert in onUninstall to make themselves hard to remove, and malicious hooks can brick an account by always reverting. Install only audited modules.
  • Accounts that allow configuration calls via execute on themselves may let stricter authorization on installModule be bypassed.
  • ERC-6900 is a separate, more prescriptive modular account standard; ERC-7579 deliberately takes the minimal route.

#account-abstraction #smart-accounts #modules #erc4337 #wallets

Details

Authors
zeroknots (@zeroknots), Konrad Kopp (@kopy-kat), Taek Lee (@leekt), Fil Makarov (@filmakarov), Elim Poon (@yaonam), Lyu Min (@rockmin216)
Status
Draft
Type
Standards Track / ERC
Created
2023-12-14
Requires
Required by

Machine-readable: Markdown · JSON