ERC-7806 · Draft(草案) · ERC · 2024-11-02
ERC-7806: Minimal intent-centric EOA smart account
面向通过 EIP-7702 委托代码的 EOA 的极简智能账户接口:所有者签署一个打包的意图,任何求解者或中继者都可以提交,由可插拔的"standard"合约验证并将其展开为一系列调用。
它解决什么问题?
账户抽象带来了批量处理、gas 代付和灵活的访问控制。ERC-4337 实现了这些,但组成部分很多(账户、EntryPoint、paymaster、bundler,以及 ERC-6900 和 ERC-7579 等插件标准),每个 UserOperation 的 gas 相对较高,升级需要协调,实际使用中还依赖 paymaster 和 bundler。
EIP-7702 让普通 EOA 可以指向合约代码。ERC-7806 利用这一点,本着 ERC-7521 的精神,为 EOA 提供一个刻意保持小巧的、以意图为中心的智能账户接口:用户签署的是应该发生什么,由求解者/中继者组成的开放市场去执行,他们可以用 ETH 支付 gas,再从账户中以代币获得补偿。
它如何运作
UserIntent。 一个打包的 bytes 数据块,包含五个逻辑部分:
| 字段 | 含义 |
|---|---|
sender |
该意图所属的 EOA |
standard |
知道如何解读该意图的 IStandard 合约的地址 |
header |
元数据,例如 nonce 或过期时间,由 standard 解释 |
instructions |
要做什么,例如 (to, value, calldata) 条目或代币支出上限 |
signatures |
standard 检查的签名(不一定全部来自所有者) |
建议的编码是 sender (20) ‖ standard (20) ‖ three uint16 lengths ‖ header ‖ instructions ‖ signatures ‖ extra,但每个 standard 可以自行定义。
两个接口。
IStandard.validateUserIntent(bytes) → bytes4和IStandard.unpackOperations(bytes) → (bytes4, bytes[])。standard 持有验证规则,就像一个精简版的 EntryPoint。IAccount.executeUserIntent(bytes) → bytes。由 EOA 委托的代码实现;它请 standard 验证并展开,然后以 EOA 的身份执行这些操作,因此下游的msg.sender就是 EOA 本身。
Gas 抽象。 任何人都可以提交交易。意图可以让账户用任意代币向提交者(tx.origin)付款,所以用户永远不需要为 gas 持有 ETH。求解者还可以把许多意图打包进一笔交易。
重放保护不是全局的:由各个 standard 自行决定(一次性哈希、nonce、过期时间),因为有些意图本来就是要重复执行的。
示例代码
一个只信任单个 standard 的极简无状态账户(Solidity,仅作演示):
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
interface IStandard {
function validateUserIntent(bytes calldata intent) external view returns (bytes4);
function unpackOperations(bytes calldata intent) external view returns (bytes4, bytes[] memory);
}
contract MinimalIntentAccount {
bytes4 constant APPROVED = 0x00000001;
IStandard public immutable standard; // code is shared; no per-EOA storage
constructor(IStandard s) { standard = s; }
function executeUserIntent(bytes calldata intent) external returns (bytes memory) {
require(address(bytes20(intent[0:20])) == address(this), "wrong sender");
require(address(bytes20(intent[20:40])) == address(standard), "unknown standard");
(bytes4 code, bytes[] memory ops) = standard.unpackOperations(intent);
require(code == APPROVED, "rejected");
for (uint256 i; i < ops.length; ++i) {
(address to, uint256 value, bytes memory data) = abi.decode(ops[i], (address, uint256, bytes));
(bool ok, ) = to.call{value: value}(data);
require(ok, "op failed");
}
return "";
}
}
需要注意
- 状态:Draft。 文本的部分内容尚未完成(例如推荐的重入防护列表是空的)。
- 安全性取决于所选的
IStandard和IAccount代码。两者都应公开并经过审计,EOA 所有者只能委托给可信的实现。 - 强烈建议使用无状态的账户代码:被委托的 EOA 会在其指向的各种代码之间共享存储,因此存储的状态可能冲突或被滥用。
- 规范中的参考实现仅作演示;请仔细审查,而不要原样部署。
- EOA 的私钥仍然拥有完全控制权;取消委托会禁用所有智能账户行为。