ERC-7988 Minimal Avatar Smart Wallet (MASW)
Draft · Accounts & wallets · created 2025-07-08
An immutable-code delegate wallet that an EOA can designate via EIP-7702, providing signed batch calls and gas sponsorship through a single fixed ABI, reducing wallet-specific interface fragmentation.
Why it is needed
EIP-7702 lets an EOA delegate execution to arbitrary contract code on a per-transaction basis, but things get complicated when each wallet uses a different ABI and fee settlement scheme. dApps and relayers must build separate adapters for each wallet, and gas sponsorship becomes harder to scale because relayers cannot reliably expect predictable rewards when fee payment paths differ by wallet. Indexers, debuggers, and static analysis tools must also separately interpret each wallet's distinct bytecode and call structure, lowering the accuracy of decoding and gas estimation. Without a standard for how far customization can go, the scope of security verification also varies by wallet, fragmenting research and hardening efforts.
What to implement
function setPolicyModule(address newModule) external;: Replace the address of the Policy module responsible for validation before and after batch execution.function setRecoveryModule(address newModule) external;: Replace the address of the Recovery module that substitutes for signature verification.event BatchExecuted(bytes32 indexed structHash);: Record the struct hash (structHash) when batch execution completes.event ModuleChanged(bytes32 indexed kind, address oldModule, address newModule);: Record the previous and new module addresses when the Policy or Recovery module is replaced.function postCheck(address sender, bytes calldata rawData, uint256 value) external view returns (bool);: Perform the same check after batch execution and return whether it passed.function isValidSignature(bytes32 hash, bytes calldata sig) external view returns (bytes4);: Check whether the given hash and signature are valid, returning 0x1626ba7e if valid.
In depth
executeBatch validation steps
The targets, values, and calldatas arrays must all be the same length and greater than 0, and block.timestamp must be at or before expiry. The stored metaNonce must match the value used in the signature, and it is incremented only after the match is confirmed. The EIP-712 digest must be recovered and must match the owner, or if a recoveryModule is set, approval from that module is required for validity.
Policy module hooks
If policyModule is not zero, preCheck is called before the list of calls executes and postCheck is called after. Both functions receive the sender, rawData, and the total ETH value transferred, and must return true to pass; a revert or a false return rejects the entire batch. An aggregator structure that chains multiple sub-policies and stops at the first failure point is also permitted.
Recovery module
If a recoveryModule is set, isValidSignature(hash, sig) performs signature verification in its place, and it must return 0x1626ba7e for a valid signature. This allows alternative authentication methods to be plugged in besides signing with the owner's private key.
Gas sponsorship and fee structure
The relayer and owner agree on (token, fee) off-chain in advance, and this value is included in the signed batch data, so the relayer cannot arbitrarily raise the fee. If another relayer broadcasts the same signed batch first, that relayer takes the fee and the original transaction is necessarily reverted, which naturally aligns competition among relayers. Relayers must check the avatar's balance in advance before submitting, and if funds are insufficient the transaction is invalidated in the mempool.
Domain separator construction
DOMAIN_SEPARATOR is constructed by encoding the EIP712Domain type hash with the name "MASW", version "1", the actual chain ID (block.chainid, using 0 is forbidden), and _owner. The owner is placed in the verifyingContract slot, designed so the separator stays the same before and after delegation.
Storage slot layout
Slot 0 is the monotonically increasing metaNonce, slot 1 is the reentrancy guard flag _entered, slot 2 is the Policy module address, and slot 3 is the Recovery module address. owner and DOMAIN_SEPARATOR are declared immutable and do not occupy separate storage slots.
Nonce-Race
MASW uses a single global metaNonce rather than a per-batch one. If two relayers submit simultaneously with the same nonce, one succeeds and the other is reverted. It is recommended to set expiry short, typically 30 seconds or less, to reduce the impact of the race, and the wallet UI should surface such failures to the user.
Proposal status
This ERC is currently in Draft status, not yet finalized, and its detailed provisions or ABI composition may change or discussion may stall going forward.
Things to watch out for
- Same-chain replay: To prevent a signed batch from being resubmitted on the same chain, a global metaNonce is used so a signature that has been used once cannot be reused.
- Cross-chain replay: Binding the actual chainId into the domain separator prevents a batch signed on one chain from being reused on another chain.
- Fee overcharging and front-running: Because the fee is included in the signed data, the relayer cannot arbitrarily raise it, and the risk from the preemption race is borne by the relayer.
- Reentrancy attack: A nonReentrant guard is used, and state is changed only before external calls (nonce increment) and after (fee payment), blocking reentrancy paths.
- Malicious module replacement: The core logic is immutable, and replacing the Policy or Recovery module requires a transaction signed by the owner, preventing arbitrary module replacement.