x402ledger

Embed Rich Metadata Into Every x402 Transaction

Automatically attach invoice IDs, agent identifiers, and service descriptions to every payment — visible on-chain in Solscan, BscScan, and Etherscan. Give your agents financial memory across sessions while maintaining complete audit trails.

View Integration

Give Your AI Agents Financial Memory

Agents need to understand their spending history to operate effectively across sessions

🧠

Agents Lose Context Between Sessions

When your agent restarts, it has no memory of what it paid for yesterday. x402ledger gives agents a complete history of purchases, so they know what services they've used and why.

🎯

Better Decision Making

Agents can query their payment history to avoid duplicate purchases, understand which services performed well, and optimize spending patterns over time.

📊

Organized Operations + Human Visibility

Your agents stay organized with full transaction context, while you get automatic invoices, budget controls, and audit trails for compliance.

Everything You Need, One Line of Code

Drop in our SDK and instantly get enterprise-grade financial tracking for x402 payments

📋

Automatic Invoices

Every x402 payment generates a detailed invoice with transaction metadata and context.

📊

Real-Time Dashboard

See what your agents are spending in real-time with live updates and visual analytics.

🎯

Budget Controls

Set spending limits per agent, per day, or per month to prevent budget overruns.

🔐

Audit Trail

Complete transaction history for compliance, accounting, and financial reporting.

Get Started in 10 Minutes

1

Install SDK

One npm command. Works with Solana, Ethereum, and BNB Chain.

2

Wrap x402 Calls

Add x402ledger around your payment calls. All tracking happens automatically.

3

View Dashboard

See real-time spending, download invoices, and export to your accounting system.

See It On-Chain

Every payment is automatically tagged with invoice metadata visible on blockchain explorers

Solscan Transaction
Transaction Hash 5zK9kY3...h2mX
Memo x402ledger Invoice #INV-2024-001
Agent ID agent-001
Service API Request - GPT-4 inference
Amount 0.1 SOL
Status ✓ Automatically Invoiced
BscScan Transaction
Transaction Hash 0x3a8f2b...9c4d
Input Data x402ledger Invoice #INV-2024-045
Agent ID agent-002
Service Data Processing - Vector embeddings
Amount 0.05 BNB
Budget Tracking 2.45 BNB remaining of 5 BNB
Etherscan Transaction
Transaction Hash 0x7f2a6e...1b8c
Input Data x402ledger Invoice #INV-2024-128
Agent ID agent-003
Service Storage - IPFS pinning service
Amount 0.01 ETH
Audit Trail ✓ Logged & Exportable

All transaction metadata is permanently stored on-chain. Invoice IDs, agent information, and service descriptions are visible in blockchain explorers - making it easy to verify, audit, and export for accounting.

Drop-In Integration

Copy, paste, and start tracking x402 payments in minutes

Install the SDK:

npm install @x402ledger/sdk
Solana
BNB Chain
Ethereum
TypeScript • Solana
import { x402ledger } from '@x402ledger/sdk';
import { Connection, PublicKey } from '@solana/web3.js';

// Initialize x402ledger
const ledger = new x402ledger({
  apiKey: 'your-api-key',
  chain: 'solana',
  network: 'mainnet-beta'
});

// Track a payment
const connection = new Connection('https://api.mainnet-beta.solana.com');

async function makeTrackedPayment() {
  const payment = await ledger.trackPayment({
    agentId: 'agent-001',
    recipient: new PublicKey('7xKXt...'),
    amount: 0.1,
    token: 'SOL',
    metadata: {
      service: 'API Request',
      description: 'GPT-4 inference'
    }
  });

  // Invoice automatically generated!
  console.log('Invoice ID:', payment.invoiceId);
}
TypeScript • BNB Chain
import { x402ledger } from '@x402ledger/sdk';
import { ethers } from 'ethers';

// Initialize x402ledger for BNB Chain
const ledger = new x402ledger({
  apiKey: 'your-api-key',
  chain: 'bnb',
  network: 'mainnet'
});

// Set up provider
const provider = new ethers.providers.JsonRpcProvider(
  'https://bsc-dataseed.binance.org'
);

async function makeTrackedPayment() {
  const payment = await ledger.trackPayment({
    agentId: 'agent-002',
    recipient: '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb',
    amount: '0.05',
    token: 'BNB',
    metadata: {
      service: 'Data Processing',
      description: 'Vector embeddings generation'
    }
  });

  // Budget controls and alerts included
  console.log('Invoice ID:', payment.invoiceId);
  console.log('Remaining budget:', payment.remainingBudget);
}
TypeScript • Ethereum
import { x402ledger } from '@x402ledger/sdk';
import { ethers } from 'ethers';

// Initialize x402ledger for Ethereum
const ledger = new x402ledger({
  apiKey: 'your-api-key',
  chain: 'ethereum',
  network: 'mainnet'
});

// Set up provider
const provider = new ethers.providers.JsonRpcProvider(
  'https://mainnet.infura.io/v3/YOUR-PROJECT-ID'
);

async function makeTrackedPayment() {
  const payment = await ledger.trackPayment({
    agentId: 'agent-003',
    recipient: '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb',
    amount: ethers.utils.parseEther('0.01'),
    token: 'ETH',
    metadata: {
      service: 'Storage',
      description: 'IPFS pinning service'
    }
  });

  // Real-time dashboard updates automatically
  console.log('Invoice ID:', payment.invoiceId);
  console.log('Transaction hash:', payment.txHash);
}