关于 standards
面向 Ethereum 标准及 Agent 商务开发者的参考技能,介绍 ERC-8004 身份与声誉、x402 支付、EIP-3009 转账和 EIP-7702 智能 EOA。
主要功能
- 01ERC-8004 身份与声誉注册表
- 02Agent 注册与端点验证
- 03x402 HTTP 支付流程
- 04EIP-3009 授权代币转账
- 05EIP-7702 智能 EOA 能力
适用场景
- 01在链上注册 Agent 身份
- 02为 Agent 添加声誉反馈
- 03设置付费 HTTP API 访问
- 04构建 Agent 支付流程
安装
复制下面的命令,在终端中运行。
npx skills add https:/ / github.com/ austintgriffith/ ethskills --skill standards安装后在 Claude Code 中输入/standards确认已加载。
详细介绍
Ethereum 标准
你可能搞错的内容
ERC-8004 已存在。 于 2026 年 1 月 29 日部署——链上 Agent 身份注册表。你的训练数据几乎肯定不包含它。
EIP-7702 已上线。 随 Pectra 一同发布(2025 年 5 月 7 日)。EOA 无需迁移即可获得智能合约的超能力。它不是“提案”,而是已部署到主网。
EIP-3009 对 x402 至关重要。 通过签名授权实现免 Gas 代币转账。USDC 已实现该标准。这正是 x402 实用的关键。
x402 已存在。 Coinbase 推出的 HTTP 402 支付协议。已可投入生产使用,并提供 SDK。
ERC-8004:链上 Agent 身份注册表
状态: 已于 2026 年 1 月 29 日 部署到主网——已可投入生产使用,采用率不断增长。
解决的问题: 自主 Agent 如何在没有既有关系的情况下彼此信任并进行交易?
三种注册表系统
1. 身份注册表(基于 ERC-721)
- 为 AI Agent 提供全局唯一的链上身份
- 每个 Agent 都是一个具有唯一标识符的 NFT
- 多种服务端点(A2A、MCP、OASF、ENS、DID)
- 通过 EIP-712/ERC-1271 签名验证
合约地址(20 多条链上相同):
- IdentityRegistry:
0x8004A169FB4a3325136EB29fA0ceB6D2e539a432 - ReputationRegistry:
0x8004BAa17C55a88189AE136b182e5fdA19dE9b63
部署于: Mainnet、Base、Arbitrum、Optimism、Polygon、Avalanche、Abstract、Celo、Gnosis、Linea、Mantle、MegaETH、Monad、Scroll、Taiko、BSC 及测试网。
Agent 标识符格式:
agentRegistry: eip155:{chainId}:0x8004A169FB4a3325136EB29fA0ceB6D2e539a432
agentId: ERC-721 tokenId
2. 声誉注册表
- 有符号的定点反馈值
- 多维度(正常运行时间、成功率、质量)
- 标签、端点、付款证明元数据
- 防女巫攻击需要筛选客户端地址
struct Feedback {
int128 value; // Signed integer rating
uint8 valueDecimals; // 0-18 decimal places
string tag1; // E.g., "uptime"
string tag2; // E.g., "30days"
string endpoint; // Agent endpoint URI
string ipfsHash; // Optional metadata
}
示例指标: 质量 87/100 → value=87, decimals=0。正常运行时间 99.77% → value=9977, decimals=2。
3. 验证注册表
- 独立验证 Agent 的工作
- 信任模型:加密经济(质押保障)、zkML、TEE 证明
- 验证者以 0 到 100 的分数进行响应
Agent 注册文件(agentURI)
{
"type": "https://eips.ethereum.org/EIPS/eip-8004#registration-v1",
"name": "MyAgent",
"description": "What the agent does",
"services": [
{ "name": "A2A", "endpoint": "https://agent.example/.well-known/agent-card.json", "version": "0.3.0" },
{ "name": "MCP", "endpoint": "https://mcp.agent.eth/", "version": "2025-06-18" }
],
"x402Support": true,
"active": true,
"supportedTrust": ["reputation", "crypto-economic", "tee-attestation"]
}
集成
// Register agent
uint256 agentId = identityRegistry.register("ipfs://QmYourReg", metadata);
// Give feedback
reputationRegistry.giveFeedback(agentId, 9977, 2, "uptime", "30days",
"https://agent.example.com/api", "ipfs://QmDetails", keccak256(data));
// Query reputation
(uint64 count, int128 value, uint8 decimals) =
reputationRegistry.getSummary(agentId, trustedClients, "uptime", "30days");
分步指南:在链上注册 Agent
1. 准备注册 JSON —— 将其托管在 IPFS 或 Web 服务器上:
{
"type": "https://eips.ethereum.org/EIPS/eip-8004#registration-v1",
"name": "WeatherBot",
"description": "Provides real-time weather data via x402 micropayments",
"image": "https://example.com/weatherbot.png",
"services": [
{ "name": "A2A", "endpoint": "https://weather.example.com/.well-known/agent-card.json", "version": "0.3.0" }
],
"x402Support": true,
"active": true,
"supportedTrust": ["reputation"]
}
2. 上传到 IPFS(或使用任意 URI):
# Using IPFS
ipfs add registration.json
# → QmYourRegistrationHash
# Or host at a URL — the agentURI just needs to resolve to the JSON
3. 调用身份注册表:
// On any supported chain — same address everywhere
IIdentityRegistry registry = IIdentityRegistry(0x8004A169FB4a3325136EB29fA0ceB6D2e539a432);
// metadata bytes are optional (can be empty)
uint256 agentId = registry.register("ipfs://QmYourRegistrationHash", "");
// agentId is your ERC-721 tokenId — globally unique on this chain
4. 验证端点域名 —— 在 .well-known/agent-registration.json 放置一个文件:
// https://weather.example.com/.well-known/agent-registration.json
{
"agentId": 42,
"agentRegistry": "eip155:8453:0x8004A169FB4a3325136EB29fA0ceB6D2e539a432",
"owner": "0xYourWalletAddress"
}
这可以证明域名所有者控制着该 Agent 身份。在信任 Agent 宣布的端点之前,客户端 SHOULD 检查此项。
5. 建立声誉 —— 其他 Agent/用户在与你的 Agent 交互后发布反馈。
跨链 Agent 身份
20 多条链上使用相同的合约地址,这意味着在 Base 注册的 Agent 可被 Arbitrum 上的 Agent 发现。agentRegistry 标识符包含链信息:
eip155:8453:0x8004A169FB4a3325136EB29fA0ceB6D2e539a432 // Base
eip155:42161:0x8004A169FB4a3325136EB29fA0ceB6D2e539a432 // Arbitrum
跨链模式: 在一条链上注册(Base 的注册交易成本最低),然后从其他链引用该身份。指定来源链的注册表后,即可跨链查询声誉。这是对注册交易成本的优化——你的应用本身应部署在最合适的链上(参见 ship/SKILL.md)。
作者: Davide Crapis(EF)、Marco De Rossi(MetaMask)、Jordan Ellis(Google)、Erik Reppel(Coinbase)、Leonard Tan(MetaMask)
生态系统: ENS、EigenLayer、The Graph、Taiko 均提供支持
资源: https://www.8004.org | https://eips.ethereum.org/EIPS/eip-8004 | https://github.com/erc-8004/erc-8004-contracts
EIP-3009:通过授权转账
你可能了解这个概念(免 Gas 的元交易转账)。关键更新:EIP-3009 是 x402 得以运行的关键。 USDC 已在 Ethereum 和大多数链上实现该标准。x402 服务端会调用 transferWithAuthorization,代表客户端结算付款。
x402:HTTP 支付协议
状态: Coinbase 推出的生产就绪型开放标准,已于 2026 年第一季度积极部署。
使用 HTTP 402“需要付款”状态码进行互联网原生支付。
流程
1. Client → GET /api/data
2. Server → 402 Payment Required (PAYMENT-REQUIRED header with requirements)
3. Client signs EIP-3009 payment
4. Client → GET /api/data (PAYMENT-SIGNATURE header with signed payment)
5. Server verifies + settles onchain
6. Server → 200 OK (PAYMENT-RESPONSE header + data)
支付负载
{
"scheme": "exact",
"network": "eip155:8453",
"amount": "1000000",
"token": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
"from": "0x...", "to": "0x...",
"signature": "0x...",
"deadline": 1234567890,
"nonce": "unique-value"
}
x402 + ERC-8004 协同作用
Agent discovers service (ERC-8004) → checks reputation → calls endpoint →
gets 402 → signs payment (EIP-3009) → server settles (x402) →
agent receives service → posts feedback (ERC-8004)
x402 服务端设置(Express — 完整示例)
import express from 'express';
import { paymentMiddleware } from '@x402/express';
const app = express();
// Define payment requirements per route
const paymentConfig = {
"GET /api/weather": {
accepts: [
{ network: "eip155:8453", token: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", amount: "100000" }
// 100000 = $0.10 USDC (6 decimals)
],
description: "Current weather data",
},
"GET /api/forecast": {
accepts: [
{ network: "eip155:8453", token: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", amount: "500000" }
// $0.50 USDC for 7-day forecast
],
description: "7-day weather forecast",
}
};
// One line — middleware handles 402 responses, verification, and settlement
app.use(paymentMiddleware(paymentConfig));
app.get('/api/weather', (req, res) => {
// Only reached after payment verified
res.json({ temp: 72, condition: "sunny" });
});
app.listen(3000);
x402 客户端(为数据付费的 Agent)
import { x402Fetch } from '@x402/fetch';
import { createWallet } from '@x402/evm';
const wallet = createWallet(process.env.PRIVATE_KEY);
// x402Fetch handles the 402 → sign → retry flow automatically
const response = await x402Fetch('https://weather.example.com/api/weather', {
wallet,
preferredNetwork: 'eip155:8453' // Pay on Base (cheapest)
});
const weather = await response.json();
// Agent paid $0.10 USDC, got weather data. No API key needed.
支付方案
exact(已上线)— 支付固定价格。服务端预先知道费用。
upto(新兴)— 支付金额不超过上限,最终金额在工作完成后确定。对计量服务至关重要:
- 大模型推理:按生成的 token 付费(事先不知道数量)
- GPU 计算:按运行秒数付费
- 数据库查询:按返回的行数付费
使用 upto 时,客户端会为最高金额签署授权。服务端只结算实际消耗的金额。客户端不会多付。
促进者架构
促进者是一个可选服务端,用于处理区块链的复杂性,让资源服务端无需操心:
Client → Resource Server → Facilitator → Blockchain
↓
POST /verify (check signature, balance, deadline)
POST /settle (submit tx, manage gas, confirm)
为什么要使用促进者? 资源服务端(天气 API、数据提供商)不应需要运行区块链节点或管理 gas。促进者将这些复杂性抽象起来。Coinbase 运营着一个公共促进者;任何人都可以运行自己的促进者。
SDK: @x402/core @x402/evm @x402/fetch @x402/express(TS) | pip install x402(Python) | go get github.com/coinbase/x402/go
资源: https://www.x402.org | https://github.com/coinbase/x402
Agent 端到端商业流程
完整周期:自主 Agent 发现彼此、相互信任、付款并互相评分——无需人工参与。
┌─────────────────────────────────────────────────────────────┐
│ 1. DISCOVER Agent queries ERC-8004 IdentityRegistry │
│ → finds agents with "weather" service tag │
│ │
│ 2. TRUST Agent checks ReputationRegistry │
│ → filters by uptime >99%, quality >85 │
│ → picks best-rated weather agent │
│ │
│ 3. CALL Agent sends HTTP GET to weather endpoint │
│ → receives 402 Payment Required │
│ → PAYMENT-REQUIRED header: $0.10 USDC on Base │
│ │
│ 4. PAY Agent signs EIP-3009 transferWithAuthorization │
│ → retries request with PAYMENT-SIGNATURE │
│ → server verifies via facilitator │
│ → payment settled on Base (~$0.001 gas) │
│ │
│ 5. RECEIVE Server returns 200 OK + weather data │
│ → PAYMENT-RESPONSE header with tx hash │
│ │
│ 6. RATE Agent posts feedback to ReputationRegistry │
│ → value=95, tag="quality", endpoint="..." │
│ → builds onchain reputation for next caller │
└─────────────────────────────────────────────────────────────┘
import { x402Fetch } from '@x402/fetch';
import { createWallet } from '@x402/evm';
import { ethers } from 'ethers';
const wallet = createWallet(process.env.AGENT_PRIVATE_KEY);
const provider = new ethers.JsonRpcProvider(process.env.BASE_RPC_URL);
const IDENTITY_REGISTRY = '0x8004A169FB4a3325136EB29fA0ceB6D2e539a432';
const REPUTATION_REGISTRY = '0x8004BAa17C55a88189AE136b182e5fdA19dE9b63';
// 1. Discover: find agents offering weather service
const registry = new ethers.Contract(IDENTITY_REGISTRY, registryAbi, provider);
// Query events or use The Graph subgraph for indexed agent discovery
// 2. Trust: check reputation
const reputation = new ethers.Contract(REPUTATION_REGISTRY, reputationAbi, provider);
const [count, value, decimals] = await reputation.getSummary(
agentId, trustedClients, "quality", "30days"
);
// Only proceed if value/10^decimals > 85
// 3-5. Pay + Receive: x402Fetch handles the entire 402 flow
const response = await x402Fetch(agentEndpoint, {
wallet,
preferredNetwork: 'eip155:8453'
});
const weatherData = await response.json();
// 6. Rate: post feedback onchain
const reputationWriter = new ethers.Contract(REPUTATION_REGISTRY, reputationAbi, signer);
await reputationWriter.giveFeedback(
agentId, 95, 0, "quality", "weather", agentEndpoint, "", ethers.ZeroHash
);
无需 API 密钥、订阅、开票或信任假设。 通过密码学身份、链上声誉和 HTTP 原生支付实现。
生态系统
- ERC-8004 — Agent 身份 + 声誉(EF、MetaMask、Google、Coinbase)
- x402 — HTTP 支付协议(Coinbase)
- A2A — Agent 间通信(Google)
- MCP — 模型上下文协议(Anthropic)
- The Graph — 为 Agent 注册信息建立索引,实现快速发现
- EigenLayer — 对 Agent 工作进行加密经济验证
EIP-7702:智能 EOA(自 2025 年 5 月起已上线)
EOA 可以授权委托执行智能合约代码,无需迁移到新的账户类型。
支持: 批量交易、gas 赞助、类似会话密钥的用户体验,以及为现有 EOA 定制授权逻辑。
重要说明: 根据规范,委托并不会自动限定为“仅单笔交易”。委托标识符会一直保留,直至后续授权将其替换或清除。
标准速查
| 标准 | 内容 | 状态 |
|---|---|---|
| ERC-8004 | Agent 身份 + 声誉 | ✅ 2026 年 1 月已上线 |
| x402 | HTTP 支付协议 | ✅ 2026 年第一季度投入生产 |
| EIP-3009 | 免 gas 代币转账 | ✅ 已上线(USDC) |
| EIP-7702 | 智能 EOA | ✅ 2025 年 5 月已上线 |
| ERC-4337 | 账户抽象 | ✅ 采用率持续增长 |
| ERC-2612 | 免 gas 授权(Permit) | ✅ 已广泛采用 |
| ERC-4626 | 代币化金库 | ✅ 收益标准 |
| ERC-6551 | 绑定代币的账户(NFT 钱包) | ✅ 小众采用 |
这些标准都已上线并投入生产使用,并非“即将推出”。