Technical Documentation

x402 Protocol

Overview & Integration Guide

What is x402?

x402 is a privacy-preserving transaction protocol that allows AI agents, apps, and users to exchange value, data, or proofs securely and confidentially.

It's designed for the new era of machine-to-machine and agent-to-agent payments, where transactions must be verifiable but not publicly traceable.

In simple terms, x402 provides a way for agents to:

  • Send and receive payments without exposing full on-chain details.
  • Keep sensitive metadata off the public ledger.
  • Maintain optional, verifiable proofs for compliance or trust.

x402 doesn't replace blockchains — it operates as a privacy layer on top of them. It orchestrates how payments are prepared, signed, proven, and logged across compatible networks such as Solana, Zcash, and Monero.

Why x402 Exists

Traditional blockchain transactions are fully transparent. Anyone can see who paid whom, how much, and when.

That's fine for open-ledger systems but unsuitable when agents:

  • Handle private business logic or data.
  • Perform micro-transactions that need confidentiality.
  • Manage user balances, fees, or revenue shares without revealing proprietary algorithms.

x402 fixes this by introducing privacy-aware transaction orchestration, using cryptography and off-chain proofs to preserve confidentiality while keeping an auditable link if needed.

How x402 Works (Simplified)

The protocol coordinates four key layers:

1. Computation Layer

Your AI agent or DApp defines what action requires a payment (e.g., executing a model, generating data, sending output).

2. Transaction Preparation Layer

x402 converts the required value (expressed in SOL) into the chosen privacy rail (Zcash or Monero). It fetches real-time conversion rates from trusted oracles, then prepares a shielded transfer request.

3. Execution Layer

The user's wallet (or agent enclave) signs and broadcasts the shielded transaction. For Zcash, x402 can attach metadata that supports view-key selective disclosure. For Monero, x402 generates standard private transactions using ring signatures and stealth addresses.

4. Proof Layer

After the transaction is confirmed, x402 creates a lightweight proof object (proof_hash) that confirms payment occurred, links to the agent action, and stores only the minimum info: timestamp, SOL equivalent, privacy rail used, and transaction status. No raw wallet or address data is stored on the x402 servers.

Supported Privacy Rails

RailTypeKey FeatureIntegration
Zcash (shielded)zk-SNARKsOptional view-keys for selective disclosurePreferred for agents that need compliance-ready audit proofs
Monero (private-by-default)RingCT, stealth addressesStrong anonymity, no native audit keysSuitable for maximum privacy or peer-to-peer agent payments

Both rails are optional. You can build x402 agents that use:

  • • Only Zcash (for privacy + auditability)
  • • Only Monero (for maximum privacy)
  • • A mixed setup where small payments use Monero and large/regulated ones use Zcash

Integration During Agent Creation

When a developer or user creates an agent:

1

Enable x402 Privacy

Toggles the privacy layer in the setup wizard.

2

Choose Privacy Rail

Zcash (shielded) — recommended default. Monero (private-by-default) — optional for ultra-private mode.

3

Set Thresholds (in SOL)

Defines when x402 applies different privacy or disclosure rules (micro, standard, or KYC-required).

4

Client-side Signing

The user's wallet or enclave signs transactions. The platform never handles raw private keys.

5

Proof Registration

x402 records a proof-hash on its relay to confirm the agent's operation without revealing sensitive details.

6

Optional Disclosure (Zcash only)

If the user allows it, x402 stores a temporary encrypted view-key for compliance or audit requests.

Data Handling & Security

x402 follows a privacy-by-design model:

No private keys stored — signing happens locally or inside HSM/MPC infrastructure.
End-to-end encryption for metadata and proofs.
Short retention — proof records kept for a limited period (default 90 days).
Immutable audit log — all disclosures or key accesses are logged and timestamped.
User consent required — for every view-key or disclosure action.

Typical Use Cases

Private AI Inference Payments

Agents charging per inference request can accept shielded micro-payments with x402 proofs.

Agent-to-Agent Collaboration

Two AI agents exchange tasks and payments privately, using Monero rail through x402.

Enterprise Data APIs

Companies can offer pay-per-call APIs with Zcash shielded billing to protect customer usage patterns.

Creator Economy

Creators can tokenize and receive revenue privately while still showing public proof of earnings if needed (via Zcash view-key).

Example Flow (simplified)

1
Agent requests payment → 1.5 SOL equivalent
2
x402 converts to 0.0023 ZEC using oracle
3
Wallet signs shielded transaction locally
4
Zcash node confirms transaction
5
x402 records proof_hash (no sensitive data)
6
Agent executes action → delivers result
7
Optional: user generates temporary view-key for audit

What Developers Need to Know

  • All API calls are REST/JSON based (/api/x402/prepare, /api/x402/proof, etc.).
  • Proofs can be verified using x402 public endpoints or SDK functions.
  • Each agent has a unique agent_xid used for linking proofs and actions.
  • Compliance modules (if enabled) can query audit events through /api/x402/audit.

Compliance Reminder

x402 enables privacy but is not designed to evade regulation. Transactions remain verifiable through cryptographic proofs or selective disclosure when legally required. Agents using Monero should clearly communicate that full auditability may not be available, depending on jurisdiction.

Summary

x402 = Privacy layer for AI and Web3 agents.
It bridges transparent blockchains (like Solana) with privacy rails (Zcash / Monero), letting agents operate confidentially while staying compliant.