ERC-7806 是一个新的以太坊标准,旨在通过 EIP-7702 改进 EOA 账户,使其具备智能合约的功能,并引入原生收益分配的潜力。它通过允许用户表达意图(如代币交换或奖励领取),同时由求解器处理执行,简化了账户抽象。ERC-7806 有助于创建更智能、更便宜、更用户友好的以太坊账户。
以太坊生态系统在不断发展,而钱包是这种转变的核心。ERC-7806,标题为“极简的以意图为中心的 EOA 智能账户”,是由 hellohanchen 在 2024 年 11 月 4 日 提出的一个突破性标准。它使用智能合约功能增强了传统的 外部所有账户 (EOA),并引入了 原生收益分配 的潜力。
ERC-7806 建立在 EIP-7702 之上,通过使用户能够表达 意图(例如代币交换或奖励领取),同时 求解器 处理执行,从而简化了 账户抽象 (AA)。本文探讨了 ERC-7806 如何将智能账户功能与原生收益代币机制结合起来,为 DeFi、GameFi 和 DAO 生态系统提供简化的框架。
以太坊钱包充当数字身份,允许用户:
传统上,用户依赖于 EOA,它很简单但有限。虽然 EOA 可以:
但在处理更高级的操作时,它们显得不足,例如:
为了克服 EOA 的局限性,引入了 账户抽象:
EIP-7702 通过允许 EOA 使用 SET_CODE_TX_TYPE=0x04
临时委托 给智能合约来解决这些限制。这种方法:
ERC-7806 是一个极简的、以意图为中心的 EOA 标准,它可以:
想象一下使用 Uber:你输入目的地,系统处理物流。ERC-7806 为以太坊带来了同样的 用户至上的简洁性:
与 ERC-4337 相比,ERC-7806 是:
ERC-7806 由两个主要接口组成:
处理 验证 和 意图解包:
interface IStandard {
function validateUserIntent(bytes calldata intent) external view returns (bytes4);
function unpackOperations(bytes calldata intent) external view returns (bytes4, bytes[] memory);
}
通过委托合约执行经过验证的意图:
interface IAccount {
function executeUserIntent(bytes calldata intent) external returns (bytes memory);
}
扩展代币标准以支持 自动奖励:
interface IERC7806Yield is IERC20 {
function getAccumulatedRewards(address account) external view returns (uint256);
function claimRewards() external returns (uint256);
function getRewardRate() external view returns (uint256);
event RewardsClaimed(address indexed account, uint256 amount);
event RewardRateUpdated(uint256 newRate);
}
library PackedIntent {
function getSenderAndStandard(bytes calldata intent) external pure returns (address, address) {
require(intent.length >= 40, "Intent too short");
return (address(bytes20(intent[:20])), address(bytes20(intent[20:40])));
}
function getLengths(bytes calldata intent) external pure returns (uint256, uint256, uint256) {
require(intent.length >= 46, "Missing length section");
return (
uint256(uint16(bytes2(intent[40:42]))),
uint256(uint16(bytes2(intent[42:44]))),
uint256(uint16(bytes2(intent[44:46])))
);
}
}
contract RelayedExecutionStandard is HashGatedStandard {
function validateUserIntent(bytes calldata intent) external view returns (bytes4) {
(address sender, address standard) = PackedIntent.getSenderAndStandard(intent);
require(standard == address(this), "Not this standard");
(uint256 headerLength, uint256 instructionsLength, uint256 signatureLength) = PackedIntent.getLengths(intent);
require(headerLength == 28 || headerLength == 8, "Invalid header length");
require(instructionsLength >= 36, "Instructions too short");
require(signatureLength == 65, "Invalid signature length");
// Validate timestamp, signatures, and balances
// 验证时间戳、签名和余额
return ERC7806Constants.VALIDATION_APPROVED;
}
function unpackOperations(bytes calldata intent) external view returns (bytes4, bytes[] memory) {
// Unpack and validate intent, return executable operations
// 解包和验证意图,返回可执行操作
// Example: Extract token swap or yield claim instructions
// 示例:提取代币交换或收益领取指令
}
}
contract AccountImplV0 {
StandardRegistry public constant REGISTRY = StandardRegistry(address());
bytes4 public constant VALIDATION_APPROVED = 0x00000001;
function executeUserIntent(bytes calldata intent) external returns (bytes memory) {
(address sender, address standard) = PackedIntent.getSenderAndStandard(intent);
require(sender == address(this), "Intent is not from this account");
require(REGISTRY.isRegistered(address(this), standard), "Standard not registered");
(bytes4 validationCode, bytes[] memory instructions) = IStandard(standard).unpackOperations(intent);
require(validationCode == VALIDATION_APPROVED, "Validation failed");
for (uint256 i = 0; i < instructions.length; i++) {
(address dest, uint256 value, bytes memory data) = abi.decode(instructions[i], (address, uint256, bytes));
(bool success,) = dest.call{value: value, gas: gasleft()}(data);
require(success, "Execution failed");
}
return new bytes(0);
}
}
contract ERC7806Token is IERC7806Yield {
mapping(address => uint256) private _lastUpdateTime;
uint256 private _rewardRate;
function getAccumulatedRewards(address account) public view override returns (uint256) {
return _calculateRewards(account);
}
function claimRewards() external override returns (uint256) {
uint256 rewards = _calculateRewards(msg.sender);
if (rewards > 0) {
_lastUpdateTime[msg.sender] = block.timestamp;
_transfer(address(this), msg.sender, rewards);
emit RewardsClaimed(msg.sender, rewards);
}
return rewards;
}
function _calculateRewards(address account) internal view returns (uint256) {
uint256 timeElapsed = block.timestamp - _lastUpdateTime[account];
return balanceOf(account) * _rewardRate * timeElapsed / 1e18;
}
}
ERC-7806 代表着在使以太坊账户更智能、更便宜、更用户友好方面向前迈出了一大步——而不会牺牲去中心化或安全性。通过结合 以意图为中心的设计、EOA 保留 和 原生收益分配,它为新一代的 钱包、dApp 和 协议 铺平了道路。
随着采用率的增长,ERC-7806 很可能成为日常以太坊交互的支柱——用户专注于他们想要什么,而区块链只是使其发生。
- 原文链接: medium.com/@ankitacode11...
- 登链社区 AI 助手,为大家转译优秀英文文章,如有翻译不通的地方,还请包涵~
如果觉得我的文章对您有用,请随意打赏。你的支持将鼓励我继续创作!