x402 Protocol
Welcome to x402. The foundation of the AVALANCHE Chain open payment standard.
Architecture Overview
Section titled “Architecture Overview”
What is x402 ?
Section titled “What is x402 ?”The x402 Protocol is a lightweight, on-chain payment standard designed for the autonomous web. Think of it as a native HTTP 402 “Payment Required” status, but for Web3. It allows services, APIs, and agents to programmatically request and receive micro-payments before delivering data or executing a task.
Instead of complex subscription models or pre-paid credits, x402 enables a true pay-as-you-go economy. It’s the engine that powers “autonomous earners”—applications and agents that can charge for their services on demand.
x402 on the AI Agent App
Section titled “x402 on the AI Agent App”On the AI Agent Application, x402 payments are baked in to everything you build. This transforms your code, templates, and agents from static projects into active, monetizable assets. Our platform integrates x402 to create a “Vibe-to-Earn” ecosystem, where every deployment is a potential revenue stream.
This integration allows for a seamless flow of value, enabling your creations to charge for API calls, data access, compute, or any other service you can imagine.
Getting Started: 1-Line Monetization
Section titled “Getting Started: 1-Line Monetization”Our SDK handles all the complexity, allowing you to require a “Digital Dollar” (USDC) payment for any incoming request.
Just add the paymentMiddleware to your server logic, pointing to your wallet and defining the price for your endpoint:
// Add this to your Vibe app's server logicpaymentMiddleware("0xYourWalletAddress", {"/my-premium-api": "$0.01"});// That’s it! If a request arrives at /my-premium-api without a valid payment, the platform automatically responds with:
HTTP/1.1 402 Payment RequiredThis standard response prompts the client (or agent) to pay and retry the request. The x402 protocol allows any web developer to accept crypto payments without the complexity of having to interact with the blockchain.
How It Works: The x402 Flow
Section titled “How It Works: The x402 Flow”Our SDK (which handles x402 and ERC-8004 receipts) abstracts away the complexity, but the flow is simple:
-
Request: A user (or another agent) attempts to access your x402-protected resource (e.g., calls your API).
-
Challenge: Your app, via the Vibe platform, automatically returns an x402 “challenge” detailing the required payment (e.g., 0.001 USDC).
-
Payment: The user’s wallet (or the calling agent’s wallet) prompts them to approve the micro-payment.
-
Receipt & Access: Upon payment, an on-chain receipt (like an ERC-8004 receipt) is generated, and the user is granted access to the resource.
This entire process happens in seconds, creating a fluid, permissionless marketplace for your digital services.
Developer Guides
Section titled “Developer Guides”Ready to integrate x402?
- Integration Guide: Add x402 payments to your app.
- API Reference: interact with the facilitator API.