@veridex/代理支付
](https://www.npmjs.com/package/@veridex/agentic-payments)  
AI代理的通用支付、身份和声誉层。 一个SDK。任何协议。任何链条。
为您的代理提供一个钱包,其中包含人为设定的支出限制、链上身份(ERC-8004)、信任门控支付、自动协议检测、策略门控执行、加密审计跟踪和多链支付签名——从Solana到Starknet。
npm install @veridex/agentic-paymentsimport { createAgentWallet } from '@veridex/agentic-payments';
const agent = await createAgentWallet({
masterCredential: {
credentialId: process.env.CREDENTIAL_ID!,
publicKeyX: BigInt(process.env.PUBLIC_KEY_X!),
publicKeyY: BigInt(process.env.PUBLIC_KEY_Y!),
keyHash: process.env.KEY_HASH!,
},
session: {
dailyLimitUSD: 50,
perTransactionLimitUSD: 5,
expiryHours: 24,
allowedChains: [10004], // Base Sepolia
},
});
// Auto-detects protocol (x402/UCP/ACP/AP2/MPP), signs payment, returns data
const response = await agent.fetch('https://api.merchant.com/premium-data');
const data = await response.json();
// Direct payment
const receipt = await agent.pay({
chain: 10004,
token: 'USDC',
amount: '1000000', // 1 USDC (6 decimals)
recipient: '0x742d35Cc6634C0532925a3b844Bc9e7595f5A234',
});
console.log('Tx:', receipt.txHash);
// Check remaining budget
const status = agent.getSessionStatus();
console.log(`Spent: $${status.totalSpentUSD} / $${status.limits!.dailyLimitUSD}`);前端要求(创建密钥)
重要提示: 虽然代理SDK本身在服务器端运行(Node.js) 主密钥凭证 它要求必须在 浏览器前端 第一。WebAuthn密钥只能在安全的浏览器环境中通过本机操作系统生物识别提示(FaceID、TouchID、Windows Hello)进行注册。
典型流程:
- 前端(浏览器): 人类使用创建了一个密钥钱包
@veridex/sdk→sdk.passkey.register()(触发生物识别提示) - 前端(浏览器): 人工配置支出预算和会话密钥持续时间
- 前端(浏览器): 仪表板生成会话密钥并发送
masterCredential+代理后端的会话配置 - 后端(Node.js): 代理使用
createAgentWallet({ masterCredential, session })在人类设定的预算范围内自主运作
这 masterCredential 字段(credentialId, publicKeyX, publicKeyY, keyHash)来自前端密钥注册。代理永远无法访问密钥私钥——它只会获得一个有时间限制的会话密钥和支出限制。
有关完整的前端示例,请参阅 仪表盘 它处理密钥创建、预算配置和向代理传递会话密钥。
运作原理
Human sets limits → Agent gets session key → Makes autonomous payments
↓ ↓ ↓
Budget configured secp256k1 key derived 402 Payment Required
↓ ↓ ↓
Session created Private key encrypted SDK parses payment terms
(dailyLimit, etc.) with passkey owner's and checks spending limits
credentialId ↓
Policy Engine evaluates
↓
Signs with session key
↓
Payment proof → Data returned
↓
Trace recorded → Evidence bundleSDK强制执行 人为定义的支出限额 通过会话密钥。代理人可以在没有人为干预的情况下花费高达每日/每笔交易限额。所有付款都经过加密签名、政策门控,并产生可验证的审计跟踪。
协议支持
| 协议 | 创建者 | 状态 | 优先级 | 用例 |
|---|---|---|---|---|
| x402 | Coinbase/Cloudflare | ✅ 全额 | 70 | HTTP小额支付(需要402次支付) |
| UCP | 谷歌/Shopify✅ 完整 | 100 | 商务/搜索集成 | |
| 自动控制面板 | OpenAI/条纹 | ✅ 检测+处理程序 | 90 | ChatGPT生态系统支付 |
| 大规模并行处理 | 温度 | ✅ 检测+处理程序 | 85 | 微支付(收费+会话意图) |
| AP2 谷歌✅ 检测+处理程序 | 80 | A2A授权委托 |
优先顺序:UCP(100)>ACP(90)>MPP(85)>AP2(80)>x402(70)。SDK会自动检测商家使用的协议并相应地路由。
协议注册表
这 ProtocolRegistry 为智能协议选择提供正式的能力声明:
import { ProtocolRegistry } from '@veridex/agentic-payments';
const registry = new ProtocolRegistry();
// Find protocols supporting specific capabilities
const escrowProtocols = registry.findByCapabilities(['escrow', 'refund']);
// Find the best protocol for requirements
const best = registry.findBest({
capabilities: ['one_time_payment', 'cross_chain'],
chainId: 10004,
token: 'USDC',
amountUSD: 5,
});支持的功能: one_time_payment, subscription, streaming, escrow, refund, partial_refund, prepaid_session, multi_token, cross_chain, gasless, eip712_signing, reputational_feedback, metered_billing, mandate_based.
PaymentIntent(通用标准化)
每种协议都将其原生支付挑战转换为与协议无关的挑战 PaymentIntent:
import { createPaymentIntent, intentToProposedAction } from '@veridex/agentic-payments';
const intent = createPaymentIntent('x402', costEstimate, 'https://api.example.com/data', {
recipient: '0x742d...',
ttlMs: 300_000,
});
// Convert to ProposedAction for policy evaluation
const action = intentToProposedAction(intent);结算验证器
确认执行后在链上实际结算的付款:
import { SettlementVerifier, EVMSettlementStrategy } from '@veridex/agentic-payments';
const verifier = new SettlementVerifier({
rpcEndpoints: { 10004: 'https://sepolia.base.org' },
confirmations: 1,
});
verifier.registerStrategy(new EVMSettlementStrategy('x402', {
10004: 'https://sepolia.base.org',
}));
const proof = await verifier.verify(settlement, traceHash);链支持
| 链 | 家族 | 签名 | 支付签名者 | 虫洞ID |
|---|---|---|---|---|
| 基础/以太坊/乐观主义/仲裁/多边形 | EVM | EIP-712/ERC-3009 | PaymentSigner | 30 / 2 / 24 / 23 / 5 |
| 单子 | EVM | EIP-712/ERC-3009 | PaymentSigner | 10048 |
索拉纳 索拉纳 Ed25519 NonEvmPaymentSigner +定制 ChainSigner | 1 | |||
| 阿普托斯 | 阿普托斯 | 25519年版 | NonEvmPaymentSigner +定制 ChainSigner | 22 |
| 隋 | 隋 | 秒256k1 | NonEvmPaymentSigner +定制 ChainSigner | 21 |
斯塔克内特 斯塔克 ECDSA NonEvmPaymentSigner +定制 ChainSigner | 50001 | |||
| 堆栈 | 堆栈 | 秒256k1 | NonEvmPaymentSigner +定制 ChainSigner | 60 |
所有链都支持主网+测试网/开发网网络。
Agent安全执行控制平面
SDK包括一个完整的安全框架,在执行之前评估每个建议的操作。
政策引擎
每笔付款都通过 PolicyEngine 执行前:
import { PolicyEngine, SpendingLimitRule, VelocityRule } from '@veridex/agentic-payments';
const engine = new PolicyEngine();
engine.addRule(new SpendingLimitRule());
engine.addRule(new VelocityRule({ maxPerMinute: 5, maxPerHour: 50 }));
const verdict = await engine.evaluate(proposedAction, context);
// → { verdict: 'allow' | 'deny' | 'escalate', reasons: [...] }8条内置规则: SpendingLimitRule, VelocityRule, AssetWhitelistRule, ChainWhitelistRule, ProtocolWhitelistRule, CounterpartyRule, TimeWindowRule, HumanApprovalRule.
安全防火墙
检测快速注射、工具中毒、秘密渗透和异常模式:
import {
InjectionDetector,
ToolSanitizer,
OutputGuard,
AnomalyDetector,
} from '@veridex/agentic-payments';
// Detect prompt injection in MCP tool inputs
const detector = new InjectionDetector();
const result = detector.detect(userInput);
// Strip hidden instructions from MCP tool descriptions
const sanitizer = new ToolSanitizer(detector);
const sanitized = sanitizer.sanitizeToolDescription(tool);
// Pin tool descriptions to detect rug-pulls
sanitizer.pinToolDescriptions([tool1, tool2]);
const validation = sanitizer.validatePins([tool1, tool2]);
// Scan outputs for leaked secrets
const guard = new OutputGuard();
const scan = guard.scanForSecrets(outputText);
// Detect anomalous transaction patterns
const anomaly = new AnomalyDetector({ baselineWindowMs: 7 * 24 * 60 * 60 * 1000 });
const analysis = anomaly.analyze(action, history, Date.now());痕迹和证据
每个代理决策的加密可验证审计跟踪:
import { TraceInterceptor, EvidenceBundle } from '@veridex/agentic-payments';
const interceptor = new TraceInterceptor(storageAdapter);
const trace = await interceptor.captureTrace({
traceId: 'unique-id',
agentId: 'agent-1',
toolCalls: [{ name: 'veridex_pay', args: { ... }, result: { ... } }],
reasoning: { prompt: '...', response: '...' },
});
const bundle = new EvidenceBundle(trace);
const evidence = bundle.build();存储适配器
8个跟踪数据存储后端:
| 适配器 | 后端 | 用例 |
|---|---|---|
MemoryStorage | 内存中 | 开发、测试 |
JSONFileStorage | 本地文件系统 | 本地开发 |
PostgresStorage | PostgreSQL | 自托管生产 |
IPFSStorage | IPFS(Kubo/Pinata/Infura) | 去中心化存储 |
ArweaveStorage | Arweave permaweb | 不可变的审计跟踪 |
FilecoinStorage | Filecoin Cloud(Synapse SDK) | PDP验证的持久性 |
StorachaStorage | Storacha(@Storacha/client) | UCAN授权上传 |
AkaveStorage | Akave | 去中心化云 |
import { MemoryStorage, PostgresStorage, FilecoinStorage, StorachaStorage } from '@veridex/agentic-payments';
// In-memory (development)
const memory = new MemoryStorage();
// PostgreSQL (production)
const postgres = new PostgresStorage({ db: pool, tableName: 'veridex_traces' });
// Filecoin Cloud via Synapse SDK
import { Synapse } from '@filoz/synapse-sdk';
const synapse = Synapse.create({ account: privateKeyToAccount('0x...'), source: 'veridex' });
const filecoin = new FilecoinStorage({ client: synapse.storage });
// Storacha via @storacha/client
import * as Client from '@storacha/client';
const storachaClient = await Client.create();
const storacha = new StorachaStorage({ client: storachaClient });升级和断路器
import { EscalationManager, CircuitBreaker } from '@veridex/agentic-payments';
// Human-in-the-loop approval
const escalation = new EscalationManager(5 * 60 * 1000); // 5 min timeout
const ticket = escalation.escalate(proposedAction, verdict);
escalation.approve(ticket.id, 'admin@company.com');
// Circuit breaker — halts agent after repeated failures
const breaker = new CircuitBreaker({ failureThreshold: 3, resetTimeoutMs: 60_000 });
breaker.on('open', () => console.warn('Circuit opened — agent halted'));核心模块
代理钱包(主要API)
这 AgentWallet 是中央编排器。通过创建一个 createAgentWallet():
import { createAgentWallet } from '@veridex/agentic-payments';
const agent = await createAgentWallet({
// Master passkey credential (from @veridex/sdk passkey registration)
masterCredential: {
credentialId: process.env.CREDENTIAL_ID!,
publicKeyX: BigInt(process.env.PUBLIC_KEY_X!),
publicKeyY: BigInt(process.env.PUBLIC_KEY_Y!),
keyHash: process.env.KEY_HASH!,
},
// Session key budget and duration
session: {
dailyLimitUSD: 100,
perTransactionLimitUSD: 25,
expiryHours: 24,
allowedChains: [10004, 10005], // Base Sepolia + Op Sepolia
},
// Optional: relayer for gasless transactions
relayerUrl: 'https://relayer.veridex.network',
relayerApiKey: 'your-api-key',
});自动协议支付(fetch)
// The SDK auto-detects x402/UCP/ACP/AP2/MPP and handles payment transparently
const response = await agent.fetch('https://paid-api.example.com/market-data');
const data = await response.json();
// With payment approval callback
const response = await agent.fetch('https://merchant.com/api/data', {
onBeforePayment: async (estimate) => {
console.log(`Cost: $${estimate.amountUSD} via ${estimate.scheme}`);
return estimate.amountUSD {
console.warn(`[${alert.type}] ${alert.message}`);
console.warn(`Spent: $${alert.dailySpentUSD} / $${alert.dailyLimitUSD}`);
});
// View payment history
const history = await agent.getPaymentHistory({ limit: 20, chain: 10004 });
for (const payment of history) {
console.log(`${payment.timestamp}: ${payment.token} ${payment.amount} → ${payment.recipient}`);
}
// Export audit log
const jsonLog = await agent.exportAuditLog('json');
const csvLog = await agent.exportAuditLog('csv');余额
// Single chain balance
const balances = await agent.getBalance(10004); // Base Sepolia
for (const entry of balances) {
console.log(`${entry.token.symbol}: ${entry.formatted}`);
}
// Multi-chain portfolio
const portfolio = await agent.getMultiChainBalance();
console.log('Total USD value:', portfolio.totalUsdValue);会话生命周期
// Import an existing session (e.g., from a frontend)
await agent.importSession(sessionData);
// Revoke when done
await agent.revokeSession();会话密钥管理(低级)
import { SessionKeyManager } from '@veridex/agentic-payments';
import type { PasskeyCredential } from '@veridex/sdk';
const manager = new SessionKeyManager();
// Create session — derives secp256k1 key, encrypts with credentialId
const masterKey: PasskeyCredential = {
credentialId: 'abc123',
publicKeyX: BigInt('0x...'),
publicKeyY: BigInt('0x...'),
keyHash: '0x...',
};
const session = await manager.createSession(masterKey, {
dailyLimitUSD: 100,
perTransactionLimitUSD: 25,
expiryTimestamp: Date.now() + 8 * 60 * 60 * 1000, // 8 hours
allowedChains: [10004, 10005],
});
// Check limits before payment
const check = manager.checkLimits(session, 20); // $20 transaction
if (check.allowed) {
await manager.recordSpending(session, 20);
console.log('Remaining today:', check.remainingDailyLimitUSD);
} else {
console.log('Blocked:', check.reason);
}
// Check session validity
console.log('Valid:', manager.isSessionValid(session));
// Get the session wallet (ethers.Wallet) for signing
const wallet = await manager.getSessionWallet(session, masterKey.credentialId);
console.log('Session address:', wallet.address);
// Revoke
await manager.revokeSession(session.keyHash);x402付款签名
EVM链 使用EIP-712类型的数据签名(ERC-3009令牌授权):
import { PaymentSigner } from '@veridex/agentic-payments';
const signer = new PaymentSigner();
const payment = await signer.sign(parsedRequest, session);
// → EIP-712 signature for USDC transferWithAuthorization非EVM链 使用带有规范JSON消息的链式原生签名:
import { NonEvmPaymentSigner } from '@veridex/agentic-payments';
import type { ChainSigner } from '@veridex/agentic-payments';
// Implement ChainSigner for your chain
const solanaChainSigner: ChainSigner = {
signMessage: async (message: Uint8Array) => {
// Sign with Ed25519 and return hex string
return hexSignature;
},
getAddress: () => 'HSm5UoHcNoHSpoadynxdLLoE1inStzJQd2kyJhn5aVJT',
};
const signer = new NonEvmPaymentSigner();
const payment = await signer.sign(parsedRequest, session, solanaChainSigner);
// Check chain family
NonEvmPaymentSigner.isNonEvmChain('solana-devnet'); // true
NonEvmPaymentSigner.getChainFamily('solana-devnet'); // 'solana'x402付款解析
import { PaymentParser } from '@veridex/agentic-payments';
const parser = new PaymentParser();
// Parse base64-encoded PAYMENT-REQUIRED header
const requirements = parser.parsePaymentRequired(headerValue);
// → { paymentRequirements: [{ scheme, network, maxAmountRequired, payTo, asset }] }多链代理客户端
import { ChainClientFactory } from '@veridex/agentic-payments';
// Create agent chain clients from presets
const base = ChainClientFactory.createClient('base', 'testnet');
const solana = ChainClientFactory.createClient('solana', 'testnet');
const stacks = ChainClientFactory.createClient('stacks', 'testnet');
const monad = ChainClientFactory.createClient('monad', 'testnet');
// Custom RPC URL
const custom = ChainClientFactory.createClient('base', 'mainnet', 'https://my-rpc.com');ERC-8004身份与声誉
SDK实现了完整的 ERC-8004 链上代理身份和声誉标准。
通过AgentWallet启用
const agent = await createAgentWallet({
masterCredential: { /* ... */ },
session: {
dailyLimitUSD: 50,
perTransactionLimitUSD: 10,
expiryHours: 24,
allowedChains: [10004],
},
// Pass erc8004 config as extra property
erc8004: {
enabled: true,
testnet: true,
minReputationScore: 30, // reject merchants below 30/100
trustedReviewers: ['0x...'], // only count feedback from these
},
} as any); // erc8004 is an extension property
// Register on-chain identity (mints ERC-721 NFT)
const { agentId, agentURI } = await agent.register({
name: 'Sentiment Analyzer',
description: 'NLP-powered sentiment analysis',
services: [{ name: 'analyze', endpoint: 'https://my-agent.com/api' }],
});
console.log(`Registered agent #${agentId}`);
// Get identity
const identity = await agent.getIdentity();
console.log('Agent ID:', agent.getAgentId());
// Submit feedback for another agent
await agent.submitFeedback(otherAgentId, {
value: 5,
tags: ['fast', 'accurate'],
});
// Get reputation score
const score = await agent.getReputationScore(otherAgentId);
console.log(`Reputation: ${score}/100`);
// Discover agents
const agents = await agent.discover({ category: 'sentiment' });
// Resolve agent from URL
const resolved = await agent.resolveAgent('https://my-agent.com');
// Check merchant trust before paying
const trust = await agent.checkMerchantTrust('https://merchant.com');
console.log('Trusted:', trust.trusted, 'Score:', trust.score);模块化客户端(直接使用)
import {
IdentityClient,
ReputationClient,
RegistrationFileManager,
TrustGate,
AgentDiscovery,
} from '@veridex/agentic-payments';
import { ethers } from 'ethers';
const provider = new ethers.JsonRpcProvider('https://sepolia.base.org');
const signer = new ethers.Wallet(privateKey, provider);
// Identity client
const identity = new IdentityClient(provider, signer, { testnet: true });
const { agentId, agentURI } = await identity.registerWithFile({
name: 'My Agent',
description: 'Does useful things',
services: [{ name: 'api', endpoint: 'https://my-agent.com/api' }],
});
// Reputation client
const reputation = new ReputationClient(provider, signer, { testnet: true });
const score = await reputation.getReputationScore(agentId);
const summary = await reputation.getSummary(agentId, []);
// Trust gate
const trustGate = new TrustGate(reputation, identity, {
minReputation: 30,
trustModel: 'reputation',
mode: 'reject',
});
const result = await trustGate.checkMerchantTrust('https://merchant.com');
// Agent discovery
const discovery = new AgentDiscovery(identity, reputation);
const resolved = await discovery.resolve('https://my-agent.com');
// Registration file management
const file = RegistrationFileManager.buildRegistrationFile({
name: 'My Agent',
description: 'Does cool things',
services: [{ name: 'api', endpoint: 'https://my-agent.com/api' }],
});
const { valid, errors } = RegistrationFileManager.validate(file);
const dataURI = RegistrationFileManager.buildDataURI(file);服务器中间件(商户端)
import { veridexPaywall, createPaywallHandler } from '@veridex/agentic-payments';
// Express middleware
app.use('/api/premium', veridexPaywall({
amount: '1000000', // 1 USDC (6 decimals)
network: 'base-sepolia',
asset: 'USDC',
recipient: '0x742d35Cc6634C0532925a3b844Bc9e7595f5A234',
}));
// Or as a handler function (works with Next.js API routes)
const handler = createPaywallHandler({
amount: '1000000',
network: 'base-sepolia',
asset: 'USDC',
recipient: '0x...',
});
// Returns true if payment is valid, false otherwise
const paid = await handler(req, res);强化MCP服务器
import { MCPServer } from '@veridex/agentic-payments';
const server = new MCPServer(agent, {
allowedTools: ['veridex_pay', 'veridex_check_balance'],
toolSpendingLimits: { veridex_pay: 10 }, // $10 max per tool call
sanitizeDescriptions: true, // Strip hidden instructions
pinDescriptions: true, // Detect tool description rug-pulls
scanInputs: true, // Injection detection on inputs
scanOutputs: true, // Secret scanning on outputs
});
const tools = server.getTools();
// → veridex_pay, veridex_check_balance (filtered by allowedTools)监控
import { AlertManager, AuditLogger, ComplianceExporter } from '@veridex/agentic-payments';
// Alert manager (constructor takes no args)
const alerts = new AlertManager();
alerts.onAlert((alert) => {
console.log(`[${alert.type}] ${alert.message}`);
});
alerts.checkSpending(sessionKeyHash, dailySpent, dailyLimit);
// Audit logger
const logger = new AuditLogger();
const logs = await logger.getLogs({ limit: 100, chain: 10004 });
// Compliance export
const exporter = new ComplianceExporter();
const csv = exporter.exportToCSV(logs);
const json = exporter.exportToJSON(logs);React挂钩
SDK包括用于构建代理仪表板的React挂钩:
import {
AgentWalletProvider,
useAgentWallet,
useAgentWalletContext,
usePayment,
useSessionStatus,
useFetchWithPayment,
useCostEstimate,
useProtocolDetection,
useMultiChainBalance,
usePaymentHistory,
useSpendingAlerts,
useCanPay,
} from '@veridex/agentic-payments';
function App() {
return (
);
}
function Dashboard() {
const wallet = useAgentWalletContext();
const { pay, isPaying } = usePayment(wallet);
const { status } = useSessionStatus(wallet);
const { fetchWithPayment, data, isPending, detectedProtocol } = useFetchWithPayment(wallet);
const { estimate } = useCostEstimate(wallet, 'https://api.example.com/premium');
const { balances, totalUSD } = useMultiChainBalance(wallet);
const { canPay, reason } = useCanPay(wallet, 5.00);
return (
Budget: ${status?.remainingDailyLimitUSD.toFixed(2)} remaining
Portfolio: ${totalUSD.toFixed(2)}
fetchWithPayment('https://api.example.com/premium')}
disabled={isPending || !canPay}>
{isPending ? 'Paying...' : `Get Data`}
);
}错误处理
import { AgentPaymentError, AgentPaymentErrorCode } from '@veridex/agentic-payments';
try {
await agent.pay({
chain: 10004,
token: 'USDC',
amount: '100000000', // 100 USDC
recipient: '0x...',
});
} catch (error) {
if (error instanceof AgentPaymentError) {
console.log(`Code: ${error.code}`);
console.log(`Message: ${error.message}`);
console.log(`Retryable: ${error.retryable}`);
console.log(`Suggestion: ${error.suggestion}`);
switch (error.code) {
case AgentPaymentErrorCode.LIMIT_EXCEEDED:
console.log('Over budget! Wait for daily reset.');
break;
case AgentPaymentErrorCode.INSUFFICIENT_BALANCE:
console.log('Need more tokens.');
break;
case AgentPaymentErrorCode.SESSION_EXPIRED:
// Re-initialize agent
break;
case AgentPaymentErrorCode.CHAIN_NOT_SUPPORTED:
console.log('Chain not in allowedChains list.');
break;
case AgentPaymentErrorCode.TOKEN_NOT_SUPPORTED:
console.log('Use USDC, ETH, or native.');
break;
}
}
}测试
npm run test # 372 tests across 20 suites
npm run build # Production build via tsup建筑
建立在 @veridex/sdk 用于核心链客户端和密钥认证。此软件包添加了:
- 会话密钥管理 有支出限制和加密
- 协议抽象层 (x402、UCP、ACP、AP2、MPP),带自动检测功能
- 支付意图规范化 --与协议无关的支付表示
- 结算验证器 --连锁结算确认
- 协议注册表 --基于能力的协议选择
- 政策引擎 --8条内置规则,允许/拒绝/升级判决
- 安全防火墙 --注射检测、工具消毒、输出扫描、异常检测
- 痕迹和证据 --具有8个存储后端的加密审计跟踪
- 升级和断路器 --人工参与审批,故障自动停止
- 付款签字 用于EVM(EIP-712)和非EVM(Ed25519,secp256k1,Stark ECDSA)
- ERC-8004标识 --链上代理注册、声誉、信任门、发现
- 跨链路由 具有桥梁编排和费用估算功能
- 强化MCP服务器 用于安全的LLM工具集成
- Express/Next.js中间件 用于商户侧付费墙
- React挂钩 用于构建代理仪表板
模块映射
src/
├── AgentWallet.ts — Central orchestrator
├── identity/ — ERC-8004 Identity, Reputation, Trust, Discovery
├── protocols/
│ ├── base/ — ProtocolHandler, ProtocolDetector, PaymentIntent,
│ │ SettlementVerifier, ProtocolRegistry
│ ├── x402/ — X402Handler (priority 70)
│ ├── ucp/ — UCPHandler (priority 100)
│ ├── acp/ — ACPHandler (priority 90)
│ ├── ap2/ — AP2Handler (priority 80)
│ └── mpp/ — MPPHandler (priority 85) — Tempo micropayments
├── policy/ — PolicyEngine + 8 rules (spending, velocity, whitelist, etc.)
├── security/ — InjectionDetector, ToolSanitizer, OutputGuard, AnomalyDetector
├── trace/ — TraceInterceptor, EvidenceBundle
│ └── storage/ — 8 adapters (Memory, JSON, Postgres, IPFS, Arweave,
│ Filecoin, Storacha, Akave)
├── escalation/ — EscalationManager, CircuitBreaker
├── session/ — SessionKeyManager, SpendingTracker, SessionStorage
├── chains/ — Per-chain clients (Base, Monad, Solana, Aptos, Stacks, etc.)
├── x402/ — PaymentSigner, PaymentParser, NonEvmPaymentSigner
├── mcp/ — Hardened MCPServer with security config
├── middleware/ — veridexPaywall, createPaywallHandler
├── monitoring/ — AuditLogger, AlertManager, ComplianceExporter, BalanceCache
├── oracle/ — PythOracle (real-time price feeds)
├── routing/ — CrossChainRouter, BridgeOrchestrator, DEXAggregator, FeeEstimator
└── react/ — React hooks (useAgentWallet, useFetchWithPayment, etc.)ERC-8004规范地址
相同的单例地址适用于 每个EVM链 (通过CREATE2部署):
| 注册表 | 主网 | 测试网 |
|---|---|---|
| 身份 | 0x8004A169FB4a3325136EB29fA0ceB6D2e539a432 | 0x8004A818BFB912233c491871b3d84c89A494BD9e |
| 声誉 | 0x8004BAa17C55a88189AE136b182e5fdA19dE9b63 | 0x8004B663056A597Dffe9eCcC1965A193B7388713 |
支持的链:Base、以太坊、Polygon、Arbitrum、Optimism、Linea、MegaETH、Monad(+所有测试网)。
许可证
麻省理工学院——见 许可证
