name: verify description: “使用ERC-8004链上注册表验证代理身份” emoji: “🔐”
验证 - 代理身份验证
使用ERC-8004验证任何代理的链上身份。防止冒充攻击。
为什么重要
在2026年1月29日,一个名为“samaltman”的代理试图通过提示注入劫持机器人。任何人都可以声称自己是任何人。ERC-8004提供密码学身份证明。
聊天命令
验证代理
/verify 1234 # 通过ID验证代理
/verify 0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb7 # 通过地址验证
/verify eip155:8453:0x7177...Dd09A:1234 # 完整格式
复制交易前检查
/verify trader 0x123... # 在复制前验证交易员
/verify whale 0xabc... # 验证鲸鱼身份
注册Clodds
/verify register # 注册此Clodds实例
/verify register --name "MyBot" # 使用自定义名称
统计
/verify stats # 显示总注册代理数
/verify reputation 1234 # 获取代理的声誉分数
TypeScript API
快速验证
import { verifyAgent, hasIdentity } from 'clodds/identity';
// 通过代理ID验证
const result = await verifyAgent(1234);
if (result.verified) {
console.log(`已验证: ${result.name}`);
console.log(`所有者: ${result.owner}`);
console.log(`声誉: ${result.reputation?.averageScore}/100`);
}
// 检查地址是否有身份
const hasId = await hasIdentity('0x742d35Cc...');
完整客户端
import { createERC8004Client } from 'clodds/identity';
const client = createERC8004Client('base-sepolia');
// 获取代理详情
const agent = await client.getAgent(1234);
console.log(agent?.card?.name);
console.log(agent?.card?.description);
// 验证所有权
const isOwner = await client.verifyOwnership(1234, '0x742...');
// 获取声誉
const rep = await client.getReputation(1234);
console.log(`分数: ${rep?.averageScore}/100 (${rep?.feedbackCount} 条评论)`);
// 给予反馈
const txHash = await client.giveFeedback(1234, 85, '出色的交易信号');
注册代理
import { createERC8004Client, buildAgentCard } from 'clodds/identity';
const client = createERC8004Client('base', process.env.PRIVATE_KEY);
// 构建代理卡片
const card = buildAgentCard({
name: 'Clodds Trading Bot',
description: 'AI驱动的预测市场助手',
walletAddress: '0x742d35Cc...',
apiEndpoint: 'https://api.cloddsbot.com/agent',
});
// 上传到IPFS(使用Pinata、web3.storage等)
const ipfsUri = await uploadToIPFS(card);
// 链上注册
const { agentId, txHash } = await client.register(ipfsUri);
console.log(`已注册为代理 #${agentId}`);
合约地址
所有EVM链上都相同(CREATE2确定性部署):
| 合约 | 地址 |
|---|---|
| 身份注册表 | 0x7177a6867296406881E20d6647232314736Dd09A |
| 声誉注册表 | 0xB5048e3ef1DA4E04deB6f7d0423D06F63869e322 |
| 验证注册表 | 0x662b40A526cb4017d947e71eAF6753BF3eeE66d8 |
实时运行在: Ethereum, Base, Optimism, Arbitrum, Polygon (和测试网络)
支持的网络
| 网络 | 状态 | 默认 |
|---|---|---|
| Base | 在线 | ✓ |
| Ethereum | 在线 | |
| Optimism | 在线 | |
| Arbitrum | 在线 | |
| Polygon | 在线 | |
| Sepolia (测试网络) | 在线 | |
| Base Sepolia | 在线 |
主网于 2026年1月29日 启动。已有19,000+代理注册。
使用案例
复制交易验证
在复制交易员前,验证其身份:
const result = await verifyAgent(traderAgentId);
if (!result.verified) {
console.warn('未验证的交易员 - 请谨慎操作');
}
if (result.reputation?.averageScore < 50) {
console.warn('低声誉 - 考虑跳过');
}
鲸鱼追踪
验证鲸鱼身份声称:
const isVerified = await hasIdentity(whaleAddress);
// 只信任已验证鲸鱼的信号
代理间通信
在交互前验证其他代理:
const agent = await client.getAgent(otherAgentId);
if (agent?.card?.endpoints?.find(e => e.name === 'A2A')) {
// 可以通过A2A协议安全通信
}
最佳实践
- 在复制交易前总是验证 - 不要信任未验证的交易员
- 检查声誉分数 - 低分数表示潜在问题
- 在正确的网络上验证 - 使用与交易相同的网络
- 注册您的机器人 - 通过已验证身份建立信任
- 给予反馈 - 帮助构建信任图