---
eip: 7988
label: ERC-7988
title: Minimal Avatar Smart Wallet (MASW)
status: Draft
type: Standards Track
category: ERC
created: 2025-07-08
requires: 7702
official: https://eips.ethereum.org/EIPS/eip-7988
source: https://github.com/ethereum/ERCs/blob/master/ERCS/erc-7988.md
canonical: https://eips.huatuo.xyz/zh/eip-7988/
lang: zh
tldr: 提出一个固定且不可变的智能钱包合约，EOA 通过 EIP-7702 委托给它，提供签名批量执行、中继者费用补偿，以及用于策略和恢复的两个可插拔模块。
tags: [wallet, eip-7702, account-abstraction, batching, sponsorship]
---

# ERC-7988: Minimal Avatar Smart Wallet (MASW)

> A smart‑wallet interface for EIP‑7702 account‑code delegation.

**TL;DR:** 提出一个固定且不可变的智能钱包合约，EOA 通过 EIP-7702 委托给它，提供签名批量执行、中继者费用补偿，以及用于策略和恢复的两个可插拔模块。

## 它解决什么问题？

[EIP-7702](/eip-7702/) 允许普通 EOA 把自己的代码指向任意合约，这样账户无需转移资金就能批量调用或由他人代付 gas。但这种自由也意味着每个钱包都可以发明自己的 ABI、签名方案和费用约定，中继者、dApp 和索引器必须分别支持每一种。

Minimal Avatar Smart Wallet（MASW）提出一个统一的标准委托目标：一份不可变的字节码、一种签名批量格式、一条费用补偿路径，定制化则交给两个可选模块。

## 它如何运作

1. 以所有者的 EOA 作为 `_owner` 部署 MASW。
2. 所有者发送一笔委托给它的 type `0x04`（EIP-7702）交易。此后，该 EOA 就是"化身"（avatar），MASW 的代码在同一地址运行，直到委托被清除或替换。

主要入口是：

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

- 所有者对一个 [EIP-712](/eip-712/) `Batch` 结构体签名，其中包含全局 `metaNonce` 和过期时间。域分隔符绑定 `chainId`，并以所有者地址作为 `verifyingContract`。
- 任何中继者都可以提交。调用按顺序执行，第一次失败时整个批次回滚。
- 如果 `fee > 0`，钱包会用 ETH（`token == address(0)`）或 [ERC-20](/eip-20/) 向中继者付费。费用已包含在签名中，因此中继者无法加价。
- **策略模块**（可选）：可以否决批次的 `preCheck` / `postCheck` 钩子。
- **恢复模块**（可选）：通过返回 `0x1626ba7e` 的 [ERC-1271](/eip-1271/) 风格 `isValidSignature` 验证的备用签名者。

## 示例代码

为中继者签署一个批次（ethers v6）：

```ts
import { Wallet, TypedDataDomain } from "ethers";

const domain: TypedDataDomain = {
  name: "MASW", version: "1", chainId, verifyingContract: owner.address,
};
const types = {
  Batch: [
    { name: "targets", type: "address[]" },
    { name: "values", type: "uint256[]" },
    { name: "calldatas", type: "bytes[]" },
    { name: "token", type: "address" },
    { name: "fee", type: "uint256" },
    { name: "exp", type: "uint256" },
    { name: "metaNonce", type: "uint256" },
  ],
};
const batch = {
  targets: [usdc], values: [0n], calldatas: [transferCalldata],
  token: usdc, fee: 50_000n, exp: BigInt(Math.floor(Date.now() / 1000) + 30), metaNonce,
};
const signature = await (owner as Wallet).signTypedData(domain, types, batch);
// relayer calls executeBatch(targets, values, calldatas, token, fee, exp, signature) on owner.address
```

## 需要注意

- **状态：Draft。** 接口和参考实现可能变化。规范中的费用转账一行仍标记为 TODO。
- 只有一个全局 nonce，因此两个中继者争抢同一批次时，一个成功，另一个回滚。较短的过期时间可以限制影响。
- 核心逻辑不可变。升级意味着发送新的 7702 委托，更换模块则需要所有者签名的交易，因此恶意模块是主要的扩展风险。
- 没有内置的批次大小上限。如果需要上限，请安装策略模块。
- 与任何 7702 委托目标一样，委托给某个合约就是让该代码完全控制 EOA 的资产。签署授权之前，请审查确切的字节码。


---

This is an unofficial plain-language summary. Read the full specification: https://eips.ethereum.org/EIPS/eip-7988
