name: 验证 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 "我的机器人" # 带自定义名称
统计信息
/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交易机器人',
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 |
在以下网络上实时: 以太坊,Base,Optimism,Arbitrum,Polygon(和测试网)
支持的网络
| 网络 | 状态 | 默认 |
|---|---|---|
| Base | 实时 | ✓ |
| 以太坊 | 实时 | |
| 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协议安全通信
}
最佳实践
- 在复制交易前始终验证 - 不要信任未经验证的交易者
- 检查声誉分数 - 低分数表示潜在问题
- 在正确的网络上验证 - 使用与交易相同的网络
- 注册你的机器人 - 通过验证的身份建立信任
- 提供反馈 - 帮助建立信任图