SDKs
Agent SDK

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-payments

Quick 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:

ToolDescription
veridex_create_sessionCreate a new bounded session
veridex_list_sessionsList active sessions
veridex_revoke_sessionRevoke a specific session
veridex_transferExecute a governed transfer
veridex_balanceCheck wallet balance
veridex_statusGet 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


Universal Protocol Layer

The Agent SDK supports multiple payment protocols out of the box:

ProtocolDescription
x402HTTP 402-based micropayments
UCPUnified Communication Protocol
ACPAgent Communication Protocol
AP2Agent Payment Protocol v2
MPPMulti-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:

ChainClient
EVM (Base, Ethereum, Optimism, Arbitrum, Polygon)EVMChainClient
SolanaSolanaChainClient
AptosAptosChainClient
SuiSuiChainClient
StarknetStarknetChainClient
StacksStacksChainClient
MonadMonadChainClient
AvalancheAvalancheChainClient

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',
});