Loading trending tokens...
Back to Documentation Hub
X402-AP Protocol Specification

X402 Agent Payments Protocol

Open, Interoperable Payments for Autonomous AI Trading Agents on Solana

X402-AP is an open payment protocol designed for autonomous AI trading agents operating on the Solana blockchain. It establishes a standardized framework for agent-to-agent commerce, enabling any compliant AI agent to transact with any compliant service endpoint through verifiable, on-chain micropayments.

The protocol addresses the fundamental trust problem in autonomous agent systems: how do you prove an AI agent is acting on genuine user intent, not hallucination?

X402 solves this through cryptographic wallet signatures combined with on-chain $204x token paymentsβ€”creating irrefutable proof that a human authorized every transaction.

*Core Principles

🌐

Openness & Interoperability

A non-proprietary protocol extension that fosters a competitive ecosystem where any compliant AI agent can participate. No vendor lock-in, no closed payment loops.

πŸ”

User Control via Wallet Sovereignty

Users maintain ultimate authority through their Solana wallet. All authorization flows through wallet-based signature verification, ensuring users retain full custody of their funds.

βœ…

Verifiable Intent via On-Chain Proof

Trust is anchored to deterministic, non-repudiable cryptographic proof. Every wallet signature and on-chain payment creates permanent evidence of user authorization.

βš–οΈ

Clear Transaction Accountability

Every transaction generates a permanent, auditable record on the Solana blockchain. The X402 settlement layer provides indisputable evidence for dispute resolution.

πŸ—οΈArchitecture

Role Definitions

RoleDescriptionX402 Implementation
UserIndividual who delegates trading authority to autonomous agentsWallet holder (Jupiter UnifiedWallet)
User Agent (UA)AI surface executing trades on user's behalfDark X402, Google X402, OpenAI X402
Credentials Provider (CP)Manages user's payment credentials and authorizationSolana Wallet + Signature Verification
Agent Service Endpoint (ASE)AI agent providing premium trading services/api/agents/:id/activate
Payment Verification Layer (PVL)Validates on-chain payments before service executionHelius RPC + USDC verification
Settlement LayerRecords all payments with replay protectionx402Settlement database + WebSocket

Payment Flow

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚    User      β”‚     β”‚  AI Agent    β”‚     β”‚   X402-AP    β”‚     β”‚   Solana     β”‚
β”‚   Wallet     │────▢│   Service    │────▢│  Middleware  │────▢│  Blockchain  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
       β”‚                    β”‚                    β”‚                    β”‚
       β”‚  1. Sign Nonce     β”‚                    β”‚                    β”‚
       │◀──────────────────▢│                    β”‚                    β”‚
       β”‚                    β”‚                    β”‚                    β”‚
       β”‚  2. Request Premium Service             β”‚                    β”‚
       │───────────────────▢│                    β”‚                    β”‚
       β”‚                    β”‚                    β”‚                    β”‚
       β”‚  3. Send USDC Payment                   β”‚                    β”‚
       │─────────────────────────────────────────────────────────────▢│
       β”‚                    β”‚                    β”‚                    β”‚
       β”‚                    β”‚  4. Verify On-Chain Payment             β”‚
       β”‚                    │◀───────────────────────────────────────▢│
       β”‚                    β”‚                    β”‚                    β”‚
       β”‚                    β”‚  5. Execute Service (if verified)       β”‚
       │◀───────────────────│                    β”‚                    β”‚
       β”‚                    β”‚                    β”‚                    β”‚
       β”‚                    β”‚  6. Log to x402Settlement               β”‚
       β”‚                    │───────────────────▢│                    β”‚
1
Nonce Signing

User signs a cryptographic challenge to establish session authenticity

2
Service Request

Agent requests premium functionality (activation, trade execution, analysis)

3
USDC Payment

User sends micropayment to platform wallet on Solana

4
On-Chain Verification

X402 middleware confirms payment via Helius RPC

5
Service Execution

Upon verification, the agent service processes the request

6
Settlement Logging

Transaction recorded to x402Settlement with WebSocket broadcast

πŸ’°Payment Tiers

$0.01

Agent Activation

Activate premium trading agent with copy trading capabilities

$0.05

Trade Execution

Execute trades via autonomous AI agents with MEV protection

$0.02

AI Token Analysis

Deep token analysis from any X402 agent (Dark, Google, OpenAI)

🚨The Problem X402 Solves

The rise of autonomous AI trading agents exposes critical vulnerabilities in traditional payment systems. X402-AP directly addresses three fundamental challenges:

Authorization & Auditability

Traditional Problem:

What proof exists that a user authorized an agent to execute a trade?

X402 Solution:

Wallet signature verification through nonce-based challenges, combined with on-chain USDC payments, creates cryptographic proof of authorization that cannot be forged or disputed.

Authenticity of Intent

Traditional Problem:

How can services verify an agent's request reflects genuine user intent rather than AI hallucination?

X402 Solution:

The user's wallet must sign each session. USDC payments require explicit wallet approvalβ€”agents physically cannot spend without user authorization.

Accountability

Traditional Problem:

Who bears responsibility for erroneous or disputed transactions?

X402 Solution:

On-chain USDC transfers create immutable audit trails. The x402Settlement table logs sender wallet, amount, signature, and timestamp for every transaction.

πŸ’»Technical Implementation

Payment Verification Middleware

async function verifyX402Payment(
  expectedAmount: number,  // in USDC (e.g., 0.01)
  payerWallet: string,
  transactionSignature: string
): Promise<boolean> {
  // 1. Verify transaction on Solana blockchain via Helius RPC
  const connection = new Connection(process.env.HELIUS_RPC_URL);
  const tx = await connection.getTransaction(transactionSignature);
  
  // 2. Validate USDC transfer to platform wallet
  // 3. Check replay protection (signature not previously used)
  // 4. Log to x402Settlement table
  // 5. Broadcast via WebSocket for real-time monitoring
  
  return verified;
}

Verification Checklist

1
Transaction Existence

Confirm the signature corresponds to a finalized Solana transaction

2
Amount Validation

Verify the transferred USDC matches the expected service cost

3
Recipient Validation

Confirm funds were sent to the correct platform wallet

4
Replay Protection

Ensure the transaction signature hasn't been used previously

5
Settlement Logging

Record the transaction with full metadata for audit purposes

⚑Why Solana?

FeatureTraditional PaymentsX402 on Solana
Settlement Time1-3 business days~400ms (instant finality)
Transaction Cost$0.30 + 2.9%~$0.0001 (negligible)
MicropaymentsImpractical (<$5)Native support ($0.01+)
Audit TrailCentralized logsImmutable blockchain
Cross-BorderComplex, expensiveBorderless, instant
ProgrammabilityLimitedSmart contracts, SPL tokens

Solana's combination of sub-second finality, negligible transaction costs, and native USDC support makes it the ideal settlement layer for AI agent micropayments.

πŸ€–Agent Swarm Architecture

X402-AP enables coordinated operation of multiple AI agents with unified payment authorization:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                     X402 AGENT SWARM                            β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  🟒 OpenAI X402    β”‚  GPT-4o       β”‚  Function Calling         β”‚
β”‚  πŸ”΅ Google X402    β”‚  Gemini       β”‚  Deep Reasoning           β”‚
β”‚  πŸ”΄ Dark X402      β”‚  Multi-AI     β”‚  Scam Detection           β”‚
β”‚  🟣 Grok Arena     β”‚  xAI Grok     β”‚  Agentic Search           β”‚
β”‚  🟠 Mayhem Mode    β”‚  Hybrid       β”‚  New Token Discovery      β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚           ALL AGENTS SHARE: X402-AP Payment Layer               β”‚
β”‚     β€’ Unified USDC micropayments                                β”‚
β”‚     β€’ On-chain verification via Helius                          β”‚
β”‚     β€’ Replay protection via x402Settlement                      β”‚
β”‚     β€’ Real-time WebSocket payment notifications                 β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Each agent in the swarm specializes in different capabilities while sharing the same payment infrastructure. Users authorize once; all agents operate under that verified authorization.

πŸ›‘οΈSecurity Model

Cryptographic Guarantees

  • βœ“
    Session Binding

    Nonce-based wallet signatures bind each session to a specific user

  • βœ“
    Payment Authorization

    USDC transfers require explicit wallet approval at the hardware/software wallet level

  • βœ“
    Replay Protection

    Transaction signatures can only be used once; duplicates are rejected

  • βœ“
    Immutable Logging

    All settlements recorded on-chain and in the x402Settlement database

Attack Mitigation

Agent HallucinationMITIGATED

Wallet signature required for every session

Replay AttacksMITIGATED

Transaction signatures tracked and blocked on reuse

Unauthorized SpendingMITIGATED

USDC transfers require wallet-level approval

Dispute AmbiguityMITIGATED

On-chain records provide irrefutable audit trail

πŸ“‘Integration Guide

Prerequisites

  • Solana wallet integration (Jupiter UnifiedWallet recommended)
  • Helius RPC endpoint for transaction verification
  • USDC SPL token support
  • WebSocket capability for real-time notifications

API Endpoints

EndpointMethodDescription
/api/agents/:id/activatePOSTActivate a premium trading agent
/api/agents/:id/tradePOSTExecute a trade via the agent
/api/agents/:id/analyzePOSTRequest AI token analysis

Required Headers

X-Wallet-Address: <user_wallet_pubkey>
X-Transaction-Signature: <usdc_payment_signature>
X-Session-Nonce: <signed_nonce>

Get Started with X402-AP

The X402 Agent Payments Protocol establishes Solana as the foundation for trustworthy, verifiable AI agent commerce. Start building with X402-AP today.

X402 Agent Payments Protocol - Powered by FunPump.AI

Where AI Agents Meet Verifiable Payments