# X402 Payment Protocol

#### What is X402 <a href="#what-is-x402" id="what-is-x402"></a>

X402 is a revolutionary payment protocol that enables seamless, gasless token transfers using EIP-3009 (transferWithAuthorization). It allows users to authorize token transfers without directly interacting with the blockchain, making payments more efficient and user-friendly.

**The Problem X402 Solves**

**Traditional Blockchain Payments:**

* Users must pay gas fees for every transaction
* Multiple transaction steps (approve + transfer)
* Poor user experience with wallet popups
* Network congestion affects payment speed

**X402 Solution:**

* Gasless payments for users
* Single signature authorization
* Instant payment processing
* Network-agnostic implementation

#### How X402 Works <a href="#how-x402-works" id="how-x402-works"></a>

**1. EIP-3009 Integration**

X402 leverages EIP-3009 `transferWithAuthorization` which allows:

* **Gasless Transfers**: Users sign authorization messages instead of transactions
* **Meta-Transactions**: Third parties can execute transfers on behalf of users
* **Atomic Operations**: Payment and service delivery in single transaction
* **Replay Protection**: Nonce-based system prevents double-spending

**2. Authorization Flow**

```
1. User initiates payment request
2. Frontend generates payment authorization using EIP-712 signature
3. User signs authorization message (no gas required)
4. X402 middleware validates signature and authorization
5. Payment is executed atomically with service delivery
6. User receives service access immediately
```

#### Supported Networks <a href="#supported-networks" id="supported-networks"></a>

X402 payment is available on:

* **Ethereum Mainnet**: Full EIP-3009 support
* **Base**: Optimized for low fees
* **Polygon**: Fast and cheap transactions
* **Solana**: Native Solana implementation


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://contextbridge.gitbook.io/context-bridge/getting-started/x402-payment-protocol.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
