Agent Identity (ERC-8004)
ERC-8004 defines a standard for AI agent on-chain identity. This skill handles registration, reputation management, and validation queries for autonomous agents operating in DeFi and governance contexts.
What ERC-8004 Provides
- - Agent Registry — on-chain map of agent IDs to metadata (name, version, capabilities)
- Reputation Scores — mutable scores (0–100) updated by authorized validators
- Validation Registry — check if an agent is registered and trusted
- Attestations — signed claims about agent behavior and purpose
Prerequisites
- - cast — Foundry tool for on-chain calls
- Wallet — EOA or smart wallet with gas for writes
- RPC URL — from Infura, Alchemy, or a public RPC
- ERC-8004 registry contract address — deployed on your target chain
Configuration
CODEBLOCK0
Core Operations
Register an Agent
CODEBLOCK1
Query Registration
CODEBLOCK2
Update Reputation (Validator Only)
CODEBLOCK3
Query Reputation
CODEBLOCK4
Add Attestation
CODEBLOCK5
Use Cases
Trust Gate for DeFi Protocol
Before executing a high-value tx, check the agent's reputation:
CODEBLOCK6
Cross-Agent Trust
When two agents need to cooperate:
CODEBLOCK7
Governance Participation
Agents voting in a DAO can prove identity:
CODEBLOCK8
Notes
- - ERC-8004 is an emerging standard — verify contract interface matches the deployed version
- Reputation is subjective — always check validator source and credibility
- Gas costs apply for all write operations (registration, reputation update, attestation)
- Test on testnet (Sepolia, Holesky) before mainnet deployment
- Common chains: Ethereum mainnet, Arbitrum, Optimism, Base
References
代理身份 (ERC-8004)
ERC-8004 定义了AI代理链上身份的标准。该技能处理在DeFi和治理环境中运行的自主代理的注册、声誉管理和验证查询。
ERC-8004 提供的内容
- - 代理注册表 — 代理ID到元数据(名称、版本、能力)的链上映射
- 声誉评分 — 由授权验证者更新的可变评分(0-100)
- 验证注册表 — 检查代理是否已注册且可信
- 认证 — 关于代理行为和目的的签名声明
前提条件
- - cast — Foundry 链上调用工具
- 钱包 — 具有gas支付能力的EOA或智能钱包
- RPC URL — 来自Infura、Alchemy或公共RPC
- ERC-8004注册表合约地址 — 在目标链上部署
配置
bash
export AGENTREGISTRYADDRESS=0x... # ERC-8004注册表地址
export WEB3RPCURL=https://eth-mainnet.alchemy.io/... # 或ETHRPCURL
export AGENTWALLETPRIVATE_KEY=0x... # 用于写入交易
核心操作
注册代理
bash
cast send $AGENTREGISTRYADDRESS \
register((string,string,bytes32,uint256)) \
(MyAgent,v1.0,0x...,1710000000) \
--rpc-url $WEB3RPCURL \
--private-key $AGENTWALLETPRIVATE_KEY
查询注册
bash
检查代理是否已注册
cast call $AGENT
REGISTRYADDRESS \
isRegistered(address) $AGENT_ADDRESS \
--rpc-url $WEB3
RPCURL
获取代理元数据
cast call $AGENT
REGISTRYADDRESS \
getAgent(address) $AGENT_ADDRESS \
--rpc-url $WEB3
RPCURL
更新声誉(仅限验证者)
bash
验证者更新声誉评分(0-100)
cast send $AGENT
REGISTRYADDRESS \
updateReputation(address,uint256) \
$AGENT_ADDRESS 85 \
--rpc-url $WEB3
RPCURL \
--private-key $VALIDATOR
PRIVATEKEY
查询声誉
bash
cast call $AGENTREGISTRYADDRESS \
getReputation(address) $AGENT_ADDRESS \
--rpc-url $WEB3RPCURL
添加认证
bash
提交签名认证
cast send $AGENT
REGISTRYADDRESS \
addAttestation(address,bytes) \
$AGENT_ADDRESS $SIGNATURE \
--rpc-url $WEB3
RPCURL \
--private-key $ATTESTER
PRIVATEKEY
使用场景
DeFi协议的信任网关
在执行高价值交易前,检查代理的声誉:
bash
REPUTATION=$(cast call $AGENTREGISTRYADDRESS getReputation(address) $AGENTID --rpc-url $WEB3RPC_URL)
[ $REPUTATION -lt 70 ] && echo 声誉低 — 标记为人工审核
跨代理信任
当两个代理需要协作时:
bash
ISREGISTERED=$(cast call $AGENTREGISTRYADDRESS isRegistered(address) $PARTNERAGENT --rpc-url $WEB3RPCURL)
治理参与
在DAO中投票的代理可以证明身份:
bash
cast call $AGENTREGISTRYADDRESS getAgent(address) $PROPOSERAGENT --rpc-url $WEB3RPC_URL
注意事项
- - ERC-8004是一个新兴标准 — 验证合约接口与部署版本匹配
- 声誉是主观的 — 始终检查验证者来源和可信度
- 所有写入操作(注册、声誉更新、认证)均需支付gas费用
- 在主网部署前先在测试网(Sepolia、Holesky)测试
- 常见链:以太坊主网、Arbitrum、Optimism、Base
参考