Agent SDK (@veridex/agentic-payments)
The Agent SDK extends the core SDK for AI agent use cases: autonomous payments, session inventory management, on-chain identity (ERC-8004), trust gates, and Model Context Protocol (MCP) tools.
Installation
npm install @veridex/agentic-paymentsQuick Start
import { AgentWallet } from '@veridex/agentic-payments';
const wallet = new AgentWallet({
chain: 'base',
network: 'testnet',
sessionConfig: {
permissions: ['transfer'],
chainScopes: [8453],
spendingLimit: { amount: 50_000_000n, token: 'USDC' },
duration: 1800,
label: 'trading-agent-001',
},
});
await wallet.init();Multi-Session Inventory
The Agent SDK manages a full session inventory for each agent:
// List all sessions for this agent
const sessions = await wallet.listSessions();
// Get status of all sessions
const statuses = await wallet.getSessionStatuses();
// Select a specific session for execution
wallet.selectSession(keyHash);
// Revoke a risky session
await wallet.revokeSession(keyHash);MCP Tools
The Agent SDK ships with Model Context Protocol tools that AI runtimes can invoke:
| Tool | Description |
|---|---|
veridex_create_session | Create a new bounded session |
veridex_list_sessions | List active sessions |
veridex_revoke_session | Revoke a specific session |
veridex_transfer | Execute a governed transfer |
veridex_balance | Check wallet balance |
veridex_status | Get agent identity and status |
Session Restoration
On init, the agent wallet attempts to restore a valid session before creating a new one:
const wallet = new AgentWallet({ /* config */ });
await wallet.init();
// If a valid session exists from a previous run, it's restored automatically.
// Otherwise, a new session is created with the configured limits.Related
- API Reference — Full method signatures and types
- Agent Identity Guide — ERC-8004 identity & reputation
- Agent Payments Guide — Payment setup walkthrough
Universal Protocol Layer
The Agent SDK supports multiple payment protocols out of the box:
| Protocol | Description |
|---|---|
| x402 | HTTP 402-based micropayments |
| UCP | Unified Communication Protocol |
| ACP | Agent Communication Protocol |
| AP2 | Agent Payment Protocol v2 |
| MPP | Multi-Party Payments |
import { createAgentWallet } from '@veridex/agentic-payments';
const agent = await createAgentWallet({
/* ... credentials and session config ... */
protocols: ['x402', 'ucp', 'acp'],
});
// Protocol is auto-selected based on the endpoint
const response = await agent.fetch('https://api.example.com/data', {
maxPayment: { amount: '0.01', currency: 'USD' },
});Multi-Chain Support
Built-in chain clients for EVM and non-EVM chains:
| Chain | Client |
|---|---|
| EVM (Base, Ethereum, Optimism, Arbitrum, Polygon) | EVMChainClient |
| Solana | SolanaChainClient |
| Aptos | AptosChainClient |
| Sui | SuiChainClient |
| Starknet | StarknetChainClient |
| Stacks | StacksChainClient |
| Monad | MonadChainClient |
| Avalanche | AvalancheChainClient |
Cross-Chain Router
import { CrossChainRouter, BridgeOrchestrator, FeeEstimator } from '@veridex/agentic-payments';
const router = new CrossChainRouter({
bridges: ['wormhole', 'layerzero', 'hyperlane'],
feeEstimator: new FeeEstimator(),
});
// Find optimal route across chains
const route = await router.findRoute({
sourceChain: 'base',
destChain: 'solana',
token: 'USDC',
amount: '1000000',
});
// Execute the bridge transfer
const orchestrator = new BridgeOrchestrator(router);
const receipt = await orchestrator.execute(route);Identity & Reputation (ERC-8004)
const agent = await createAgentWallet({
/* ... */
erc8004: { enabled: true, testnet: true },
});
// Register on-chain identity
const { agentId } = await agent.register({
name: 'Market Analyst',
description: 'Autonomous market data agent',
services: [{ name: 'analyze', endpoint: 'https://api.example.com/analyze' }],
});
// Query reputation
const rep = await agent.reputation.getSummary(agentId);Monitoring & Audit
import { AuditLogger, AlertManager, ComplianceExporter } from '@veridex/agentic-payments';
const logger = new AuditLogger({ sink: 'postgres', connectionString: process.env.DATABASE_URL });
const alerts = new AlertManager({
channels: ['slack', 'email'],
thresholds: { spendPerHour: 100, failedTxCount: 5 },
});
// Attach to agent wallet
agent.on('transaction', (tx) => logger.log(tx));
agent.on('alert', (alert) => alerts.dispatch(alert));
// Export for compliance
const exporter = new ComplianceExporter(logger);
await exporter.export({ format: 'csv', since: Date.now() - 86_400_000 });Middleware
import { veridexPaywall, nextAppRouter } from '@veridex/agentic-payments/middleware';
// Express/Hono middleware — paywall an endpoint
app.use('/api/premium', veridexPaywall({
price: { amount: '0.001', currency: 'USD' },
protocols: ['x402'],
}));
// Next.js App Router
export const middleware = nextAppRouter({
protectedRoutes: ['/api/premium/*'],
price: { amount: '0.001', currency: 'USD' },
});DeFi Integrations
import { PythOracle, DEXAggregator } from '@veridex/agentic-payments';
// Real-time price feeds
const oracle = new PythOracle();
const btcPrice = await oracle.getPrice('BTC/USD');
// DEX aggregation
const dex = new DEXAggregator({ chains: ['base', 'optimism'] });
const quote = await dex.getQuote({
tokenIn: 'USDC',
tokenOut: 'WETH',
amount: '1000000000',
});- API Reference — Full method signatures and types
- Agent Payments Guide — Autonomous payment workflows
- Agent Identity Guide — ERC-8004 on-chain identity
- Multi-Session Guide — Session management patterns