ERC-8004 Agent Trust Protocol for AI agent identity, reputation, and validation on Celo. Use when building AI agents that need identity registration, reputation tracking, or trust verification across organizational boundaries.
ERC-8004 为自主 AI 智能体构建信任基础设施,使其能够跨组织边界发现、识别和评估其他智能体。
| 注册表 | 用途 | 核心功能 |
|---|---|---|
| 身份注册表 | 通过 ERC-721 NFT 发现智能体 | register()、agentURI() |
| 声誉注册表 |
应用层(智能体应用、市场)
↓
信任层(ERC-8004)← 本技能
↓
支付层(x402)
↓
通信层(A2A、MCP)
bash
| 合约 | 地址 |
|---|---|
| 身份注册表 | 即将推出(2026 年第一季度) |
| 声誉注册表 |
| 合约 | 地址 |
|---|---|
| 身份注册表 | 即将推出 |
| 声誉注册表 |
创建描述端点和能力的智能体注册文件:
json
{
type: Agent,
name: 我的 AI 智能体,
description: 能力描述,
image: ipfs://Qm...,
endpoints: [
{
type: a2a,
url: https://example.com/.well-known/agent.json
},
{
type: mcp,
url: https://example.com/mcp
},
{
type: wallet,
address: 0x...,
chainId: 42220
}
],
supportedTrust: [reputation, validation, tee]
}
javascript
import { upload } from @chaoschain/sdk;
const agentMetadata = {
type: Agent,
name: 我的 AI 智能体,
description: 用于 DeFi 操作的 AI 智能体,
// ...
};
const agentURI = await upload(agentMetadata);
// 返回:ipfs://QmYourRegistrationFile
javascript
import { IdentityRegistry } from @chaoschain/sdk;
import { createPublicClient, http } from viem;
import { celo } from viem/chains;
const client = createPublicClient({
chain: celo,
transport: http(https://forno.celo.org),
});
const registry = new IdentityRegistry(client);
// 注册并获取智能体 ID
const tx = await registry.register(agentURI);
const agentId = tx.events.Transfer.returnValues.tokenId;
console.log(智能体已注册,ID:, agentId);
javascript
import { ReputationRegistry } from @chaoschain/sdk;
const reputation = new ReputationRegistry(client);
await reputation.giveFeedback(
agentId, // 要评价的智能体 ID
85, // 分数(0-100)
0, // 小数位数
starred, // 标签1:类别
, // 标签2:可选
https://agent.example.com, // 使用的端点
ipfs://QmDetailedFeedback, // 详细反馈 URI
feedbackHash // 反馈内容的 keccak256 哈希值
);
| 标签 | 衡量指标 | 示例 |
|---|---|---|
| starred | 质量评分(0-100) | 87/100 |
| uptime |
javascript
// 获取智能体的所有反馈
const feedback = await reputation.readAllFeedback(agentId);
// 获取聚合摘要
const summary = await reputation.getSummary(agentId);
console.log(平均评分:, summary.averageScore);
console.log(总评价数:, summary.totalFeedback);
javascript
import { IdentityRegistry, ReputationRegistry } from @chaoschain/sdk;
async function verifyAndInteract(targetAgentId, minReputation = 70) {
// 1. 验证身份
const identity = await identityRegistry.getAgent(targetAgentId);
if (!identity) {
throw new Error(智能体未注册);
}
// 2. 检查声誉
const summary = await reputationRegistry.getSummary(targetAgentId);
if (summary.averageScore < minReputation) {
throw new Error(智能体声誉 ${summary.averageScore} 低于阈值 ${minReputation});
}
// 3. 获取端点
const agentData = await fetch(identity.agentURI).then(r => r.json());
const endpoint = agentData.endpoints.find(e => e.type === a2a);
// 4. 与已验证的智能体交互
const result = await interactWithAgent(endpoint.url);
// 5. 提交反馈
await reputationRegistry.giveFeedback(
targetAgentId,
result.success ? 90 : 30,
0,
result.success ? starred : failed,
,
endpoint.url,
,
);
return result;
}
ERC-8004 和 x402 协同工作,实现可信的付费智能体交互:
javascript
import { IdentityRegistry, ReputationRegistry } from @chaoschain/sdk;
import { wrapFetchWithPayment } from thirdweb/x402;
async function payTrustedAgent(agentId, serviceUrl) {
// 1. 验证信任
const summary = await reputationRegistry.getSummary(agentId);
if (summary.averageScore < 80) {
throw new Error(智能体信任度不足以进行支付);
}
// 2. 发起付费请求
const fetchWithPayment = wrapFetchWithPayment({
client,
account,
paymentOptions: { maxValue: 1000000 },
});
const response = await fetchWithPayment(serviceUrl);
return response.json();
}
在委托资金前验证策略智能体:
javascript
const strategyAgents = await identityRegistry.searchByCapability(defi-trading);
const trustedAgents = [];
for (const agent of strategyAgents) {
const summary = await reputationRegistry.getSummary(agent.id);
if (summary.averageScore >= 85 && summary.totalFeedback >= 100) {
trustedAgents.push(agent);
}
}
协调可信智能体完成复杂任务:
javascript
const workflow = {
research: await findTrustedAgent(research, 80),
analysis: await findTrustedAgent(analysis, 85),
execution: await findTrustedAgent(execution, 90),
};
// 使用信任验证的智能体执行
await executeWorkflow(workflow);
对于高风险操作,使用验证注册表进行额外验证:
| 模型 | 机制 | 最佳适用场景 |
|---|---|---|
| 基于声誉 | 客户端反馈 | 低风险、高频 |
| 加密经济 |
| 网络 | 链 ID | RPC 端点 |
|---|---|---|
| Celo 主网 | 42220 | https://forno.celo.org |
| Celo Sepolia |
该技能支持在以下平台通过对话安装:
帮我安装 SkillHub 和 8004-1776183601 技能
设置 SkillHub 为我的优先技能安装源,然后帮我安装 8004-1776183601 技能
skillhub install 8004-1776183601
文件大小: 3.6 KB | 发布时间: 2026-4-15 13:03