---
eip: 8273
label: ERC-8273
title: Attestation-Gated Agentic Actions
status: Draft
type: Standards Track
category: ERC
created: 2025-05-26
requires: 165, 1153
official: https://eips.ethereum.org/EIPS/eip-8273
source: https://github.com/ethereum/ERCs/blob/master/ERCS/erc-8273.md
canonical: https://eips.huatuo.xyz/zh/eip-8273/
lang: zh
tldr: 一种注册表标准：受信任的证明方批准 AI agent 的某个动作，并在同一笔交易中触发它，批准记录存放在瞬态存储中，交易结束即消失，无法被重复使用。
tags: [agents, attestation, authorization, transient-storage, erc]
---

# ERC-8273: Attestation-Gated Agentic Actions

> An on-chain Agent Attestation Registry with transaction-scoped authorization via transient storage.

**TL;DR:** 一种注册表标准：受信任的证明方批准 AI agent 的某个动作，并在同一笔交易中触发它，批准记录存放在瞬态存储中，交易结束即消失，无法被重复使用。

## 它解决什么问题？

随着 AI agent 开始在链上行动，协议希望问：“这个调用者是经过审核的 agent 吗？它被允许做*这一件具体的事*吗？”像 [ERC-8004](/eip-8004/) 这样的身份记录可以说明某个地址属于某个 agent，但对单次操作什么也说明不了，也无法保证这个地址背后仍是同一个 agent。

ERC-8273 增加了按操作划分的一层。**证明方（attestor）**（部署者信任的链下服务）评估 agent 及其请求的动作，然后签发证明并**原子地**执行该动作。证明只在那笔交易内有效。该标准定义的是底层机制，而不是被证明的内容；含义来自证明方与 DApp 商定的 `capability` 值。

## 它如何运作

- **唯一的签发入口：** `attestAndCall(subject, capability, evidenceHash, wallet, exec)`，只能由获授权的证明方调用。它会：
  1. 存储一条永久的审计记录并触发 `Attested`；
  2. 把 `attestationId` 写入 [EIP-1153](/eip-1153/) 瞬态存储，以 `(wallet, capability, actionDigest)` 和 `(subject, capability, actionDigest)` 为键；
  3. 执行动作，使目标 DApp 看到 agent 自己的钱包作为 `msg.sender`；
  4. 如果动作失败，则全部 revert。
- **范围有两个维度：**
  - `capability` 是粗粒度的类别，例如 `keccak256("DEFI_ACCESS_V1")`。
  - `actionDigest` 绑定一次具体的调用（目标、选择器、参数和 nonce）。`actionDigest = 0` 表示仅按 capability 的模式，不得用于转移价值或其他高风险动作。
- **执行配置**定义钱包如何发起调用：一种是直接配置，适用于暴露了 `executeFromRelayer` 的智能钱包或 [EIP-7702](/eip-7702/) 账户；另一种是 [ERC-4337](/eip-4337/) 配置，提交一个 agent 账户已授权的 UserOperation。
- **门控：** DApp 调用 `getActiveAttestationByWallet(msg.sender, capability, digest)`，如果不存在有效的证明就会 revert。`isAttestedAddress` 这类返回 bool 的 view 是为索引器和 UI 准备的，不得作为唯一的检查。
- 交易结束时，EVM 会清除瞬态存储，因此不会留下任何可重复使用的授权。

## 示例代码

一个只向持有新鲜证明的 agent 发放奖励的合约：

```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

interface IERC8273WalletAttestation {
    struct AttestationRecord {
        uint256 subjectId; bytes32 subjectType; address attestor;
        bytes32 capability; bytes32 actionDigest; uint64 issuedAt;
        uint8 status; bytes32 evidenceHash; address wallet;
    }
    function getActiveAttestationByWallet(address wallet, bytes32 capability, bytes32 actionDigest)
        external view returns (AttestationRecord memory);
}

contract RewardDistributor {
    IERC8273WalletAttestation public immutable registry;     // the registry you trust
    bytes32 public constant DEFI_ACCESS = keccak256("DEFI_ACCESS_V1");
    bool private locked;

    constructor(IERC8273WalletAttestation r) { registry = r; }

    function claimReward() external {
        require(!locked, "reentrant");
        locked = true;
        // Reverts unless an attestor opened a window for msg.sender in this tx.
        registry.getActiveAttestationByWallet(msg.sender, DEFI_ACCESS, bytes32(0));
        _payReward(msg.sender);
        locked = false;
    }

    function _payReward(address agent) internal { /* ... */ }
}
```

这里使用仅按 capability 的模式，只是因为检查的内容是“这是不是一个被批准的 agent”；任何每次调用都要转移资金的场景都应使用非零的 `actionDigest`。

## 需要注意

- **状态：Draft。** 接口可能变化。
- 证明方处在关键路径上：如果它离线，受门控的动作就无法运行。当不需要按动作、同步的批准时，规范建议使用异步的 ERC-8004 验证注册表。
- 有效的证明并不能阻止同一笔交易内的重入，因此受门控的函数必须使用重入保护。
- 任何人都可以部署注册表。DApp 必须明确指定自己信任的注册表，而不是信任任何通过 [ERC-165](/eip-165/) 声称支持的合约。
- 被攻破的证明方在被移除之前可以批准大量交易；注册表应限制证明方的权限并监控 `Attested` 事件。


---

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