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.

ERC-7988 proposes a minimal smart wallet interface that uses EIP-7702 code delegation to give an externally owned account (EOA) atomic batching and gas sponsorship.

This article walks through the proposal below.

For other EIP, BIP, SLIP, CAIP, ENSIP, RFC, and ACP articles, see the proposal index.

Overview

ERC-7988 defines the Minimal Avatar Smart Wallet, or MASW, around the code delegation mechanism introduced by EIP-7702.

For background on EIP-7702, see the following article.

[EIP-7702] How EOAs gain smart contract functionality

EIP-7702 lets an EOA designate a smart contract whose code runs in the EOA's context. The delegation persists until cleared or replaced. In ERC-7988, the EOA is the avatar and MASW supplies the delegate code. The account keeps its address and gains smart wallet functionality at that address.

The EOA avatar and the MASW delegate

MASW provides atomic batch execution through executeBatch, gas sponsorship with reimbursement in ETH or an ERC-20 token, and two extension points: a Policy Module and a Recovery Module. Diagram labels are retained in Japanese where present.

For background on ERC-20, see the following article.

[ERC-20] An introduction to ERC-20

Motivation

Wallet fragmentation

EIP-7702 gives EOAs considerable freedom to choose their delegated contract code. That flexibility can fragment wallet integrations. If wallet ABIs and fee settlement methods differ, dApps and relayers need a separate adapter for each wallet.

Why standardization matters

Area Effect of fragmentation
Interoperability dApps must support wallet-specific ABIs, increasing integration work and the number of ways an integration can fail.
Gas sponsorship Differences in fee settlement weaken relayer incentives and slow adoption of sponsored transactions.
Tooling Indexers, debuggers, and static analyzers can decode events and estimate gas more accurately when they target a single bytecode implementation and a fixed seven-field schema.
Extensibility Limiting variation in the core and keeping extensions behind two module boundaries lets developers focus security and research efforts.

How the proposal addresses fragmentation

ERC-7988 standardizes immutable bytecode, a fixed EIP-712 signing domain, and a minimal ABI. It exposes the Policy Module and Recovery Module as separate extension points. Developers can replace these modules to customize behavior while the wallet core stays fixed.

Specification

Delegation flow

An ERC-7988 wallet is set up as follows.

  1. Deploy MASW. Deploy the MASW contract with the owner's EOA address as the constructor argument.
  2. Submit an EIP-7702 transaction. The owner authorizes the MASW contract as the delegation target through a type 0x04 transaction. While the Japanese article and ERC-7988 draft describe a bytecode hash, the finalized EIP-7702 authorization tuple specifies the delegate's address.
  3. Use the avatar wallet. MASW code executes at the avatar EOA's address on subsequent delegated calls. The delegation remains active until the owner authorizes a new 0x04 transaction to clear or replace it.
sequenceDiagram
    participant Owner as EOA(所有者)
    participant MASW as MASWコントラクト
    participant Chain as ブロックチェーン

    Owner->>Chain: MASWをデプロイ(_owner = EOA)
    Owner->>Chain: EIP-7702 tx(0x04)でコード委任
    Note over Owner,Chain: 以降、EOAアドレスでMASWロジックが実行可能
    Owner->>MASW: executeBatch(署名付き)
    MASW->>Chain: targets[0].call → targets[1].call → ...

Public interface

executeBatch

MASW's primary function executes multiple contract calls in one transaction.

javascript
function executeBatch(
    address[] calldata targets,
    uint256[] calldata values,
    bytes[]   calldata calldatas,
    address token,
    uint256 fee,
    uint256 expiry,
    bytes   calldata signature
) external;

The function takes seven parameters.

Parameter Type Description
targets address[] Contract addresses to call.
values uint256[] ETH to send with each call, in wei.
calldatas bytes[] Calldata for each call, including its encoded arguments.
token address Token used to pay the fee. address(0) means ETH.
fee uint256 Amount to pay the relayer. Zero means no reimbursement.
expiry uint256 Signature expiration as a Unix timestamp. The batch is invalid after this time.
signature bytes EIP-712 signature covering the batch fields and metaNonce.
Batch execution stages

Stages of executeBatch

executeBatch proceeds through the following stages.

  1. Validate the batch. Check that targets, values, and calldatas have the same nonzero length and that block.timestamp is at most expiry. Verify the signature against the batch digest built with the current metaNonce. The address recovered from the EIP-712 digest must match the owner, or the Recovery Module must approve the signature. Increment metaNonce after validation.
  2. Run the policy pre-hook. If a Policy Module is configured, call preCheck. If it returns false or reverts, reject the entire batch.
  3. Execute the calls. Run targets[i].call{value:values[i]}(calldatas[i]) for each index. If a call fails, revert the entire batch.
  4. Run the policy post-hook. Call postCheck if the module is configured. It can reject the batch in the same way as the pre-hook.
  5. Settle the fee. If fee is greater than zero, reimburse the relayer in ETH when token is address(0). Otherwise, pay the relayer with an ERC-20 transfer and check the return value using OpenZeppelin's SafeERC20 pattern.
  6. Emit the event. Emit BatchExecuted(structHash).

setPolicyModule / setRecoveryModule

These functions configure or replace the modules.

javascript
function setPolicyModule(address newModule)   external;
function setRecoveryModule(address newModule) external;

Changing either module requires authorization from the owner.

Events

MASW defines two events.

javascript
event BatchExecuted(bytes32 indexed structHash);
event ModuleChanged(bytes32 indexed kind, address oldModule, address newModule);

BatchExecuted is emitted when executeBatch finishes. The indexed structHash identifies the batch. ModuleChanged is emitted when a module is configured or replaced. The indexed kind distinguishes the Policy Module from the Recovery Module.

Storage layout

MASW uses four storage slots.

Slot Variable Type Description
0 metaNonce uint256 Monotonically increasing meta-transaction nonce that prevents replay.
1 _entered uint256 Reentrancy guard flag.
2 policyModule address Policy Module address. The zero address means no module is configured.
3 recoveryModule address Recovery Module address. The zero address means no module is configured.

owner and DOMAIN_SEPARATOR are immutable. Their values are fixed at deployment and occupy no storage slots.

EIP-712 signatures

EIP-712

EIP-712 defines how to sign structured data. Including types in what gets signed lets users and applications verify the meaning of the data covered by the signature.

Batch type hash

The signature for executeBatch uses the following type string.

javascript
bytes32 constant BATCH_TYPEHASH = keccak256(
  "Batch(address[] targets,uint256[] values,bytes[] calldatas,address token,uint256 fee,uint256 exp,uint256 metaNonce)"
);

The type string's exp field corresponds to the expiry function parameter. Including the current metaNonce in the signed data prevents reuse of a signature.

Domain separator

MASW uses an EIP-712 domain separator to prevent replay.

javascript
DOMAIN_SEPARATOR = keccak256(
  abi.encode(
    keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"),
    keccak256("MASW"),
    keccak256("1"),
    block.chainid,
    _owner
  )
);

chainId uses the current chain ID, and zero is disallowed. Binding the signature to the chain ID prevents it from being reused on another chain. Using the owner's address as verifyingContract keeps the domain separator consistent before and after delegation.

Gas sponsorship

A relayer submits the transaction on the owner's behalf and receives a fee in return.

The relayer and owner agree to (token, fee) off-chain. The fee is covered by the batch signature, so the relayer cannot increase it unilaterally.

If another relayer broadcasts the same signed batch and gets it included first, that relayer earns the fee. The original relayer's transaction then reverts because the nonce has already been consumed. This gives relayers an incentive to submit promptly.

Relayers should check the avatar wallet's balance before submitting. A batch without sufficient funds for all transfers and reimbursement will fail execution. Relayer-side simulation or mempool admission checks may detect that failure before inclusion.

Modules

MASW exposes two module extension points. Replacing a module adds custom behavior without changing the wallet's core logic.

Policy Module

javascript
interface IPolicyModule {
  function preCheck(address sender, bytes calldata rawData, uint256 value) external view returns (bool);
  function postCheck(address sender, bytes calldata rawData, uint256 value) external view returns (bool);
}

This module checks a batch before and after execution. preCheck runs before the calls and postCheck runs afterward. Either can reject the entire batch by returning false or reverting.

The value parameter is the total ETH sent with the transaction (msg.value). A Policy Module can compare it with the batch requirements encoded in rawData.

A policy might cap the number of calls in a batch or allow calls only to specific contracts. The proposal also recommends an aggregator pattern that forwards checks to multiple policies in order and stops at the first failure.

Recovery Module

javascript
interface IRecoveryModule {
  function isValidSignature(bytes32 hash, bytes calldata sig) external view returns (bytes4);
}

This module provides an alternative way to validate signatures if the owner loses their private key. Returning 0x1626ba7e marks the signature as valid. Examples include social recovery, in which a set of trusted contacts agrees to recover access, and multisignature verification.

Additional notes

Why keep the logic immutable?

MASW's core logic is immutable. To use a new version, the owner must explicitly sign a new EIP-7702 authorization pointing to another contract and have it included in a 0x04 transaction.

This reduces upgrade risk. A proxy pattern can change the implementation behind the same address, introducing bugs or malicious behavior. MASW fixes the core code so users can know which implementation will execute for their chosen delegate.

Custom behavior goes through the Policy Module or Recovery Module. This lets users add features such as batch-size limits or social recovery while keeping the core logic fixed.

Nonce contention

MASW uses a global metaNonce. If two relayers submit transactions with the same nonce, one can succeed and the other reverts.

The expiry field can limit the effect of these races. The Japanese article suggests a lifetime of 30 seconds or less. A short lifetime narrows the window in which a signed batch can be submitted. The UI still needs to tell the user when an attempt fails.

Batch size limits

MASW does not hard-code a maximum number of calls in a batch, as measured by the length of targets. Advanced users can bundle many calls, while users who prefer a tighter limit can enforce it with a Policy Module. This preserves flexibility in the core and lets users choose their own constraints.

Reference implementation

The Solidity reference implementation is available here.

https://github.com/ethereum/ERCs/blob/master/assets/eip-7988/MASW.sol

Security

Replay protection

A replay attack resubmits a previously successful authorization to execute it again. MASW uses two mechanisms to prevent this. On the same chain, the monotonically increasing metaNonce makes each signature usable only once. Across chains, the domain separator binds the signature to the chain ID.

Reentrancy protection

When executeBatch calls an external contract, that contract may attempt to call executeBatch again. MASW uses a nonReentrant guard to block this. It increments metaNonce before making external calls and settles fees after the calls finish, maintaining a consistent execution order.

Fee front-running

In a sponsored transaction, a relayer receives an owner-signed batch and submits it. The token and fee are covered by the signature, so a relayer cannot increase the fee. Another relayer could submit the same batch first and collect the agreed fee. The relayer bears the risk of losing the reimbursement, while the owner's signed fee remains the same.

Threat Mitigation
Same-chain replay Use a global metaNonce.
Cross-chain replay Bind the domain separator to the chain ID.
Unauthorized fee increases Fees are covered by the signature. Relayers bear the risk of being front-run.
Excessive gas consumption from batching Use a Policy Module to reject oversized batches.
Nonstandard ERC-20 return values Check return values with OpenZeppelin's SafeERC20 pattern.
Reentrancy Use a nonReentrant guard and order state changes around external calls.
Malicious modules Keep the core logic immutable and require owner authorization to change modules.

References

Conclusion

ERC-7988 proposes MASW, a minimal smart wallet built on EIP-7702. Code delegation makes EOAs more capable, but wallet-specific ABIs and fee models can fragment the ecosystem. MASW uses a fixed seven-parameter ABI and two module boundaries to support compatibility while leaving room for extensions.

If you have questions, feel free to send me a message on Twitter.

Twitter @cardene777

You can also find my work here.