What x402 is?
Have you heard about HTTP 402 Error?
You’ve probably seen 401 or 403 errors if you have experience building something that includes HTTP interaction. But what about 402? I’ve never seen a 402 response in production, even though I’ve been developing servers for over a decade. It means “Payment Required”—that’s where x402 gets its name.
Changing paradigm
In the very beginning of internet, only one consensus existed - the active entity of the internet must be a human being.
However, after early of 2024, many humans are making conversation with virtual entity called AI agents. We share our worries with them. We might seeing the beginning of new era - virtual entities are regarded as another one. (Like a movie “Her”.)
Then, what would happen if those AI agents are available to make purchase for real? For now, those actions are only available for mankind. Because the purchasing methods on online are hardly bonding on user identifier. For example, if someone named Juwoong has the card number 1234-1234-1234-1234, you’d need Juwoong’s personal information to make any payment with it.
But since blockchain appeared, this assumption is no longer natural. Traditionally, proving authorization required verifying human identity through methods like phone verification or personal information checks. However, blockchain enables us to cryptographically prove that an entity authorized a transaction—without needing to verify their real-world identity. This means anyone with a funded wallet, even a virtual entity, can now make purchases with real assets.
Anyone who has enough budget on their wallet - even if they’re a virtual entity - now can make purchase with real asset.
x402 elegantly addresses both of these contexts.
How x402 Works?
According to whitepaper, x402 protocol generally return information for purchase with HTTP 402 status code.
When client request to endpoint at first time, server will return payload like this -
{
"maxAmountRequired": "0.10",
"resource": "/api/market-data",
"description": "Access to real-time market data requires payment.",
"payTo": "0xABCDEF1234567890ABCDEF1234567890ABCDEF12",
"asset": "0xA0b86991C6218b36c1d19D4a2e9Eb0cE3606EB48",
"network": "ethereum-mainnet"
}
Then client will create cryptographic signature for purchase with EIP-712 standards. This signature includes following datas.
- Requested JSON data
- Purchased amount
- Timestamp
- Payment signature.
When signature is ready, client will re-request to the endpoint, with X-Payment header. Then server check it, and response data if the signature valid.
Impact of the idea
With this idea, it would be much easier to accept payments from users. But the biggest advantage is that it enables payments between AI agents. This means AI could more easily purchase goods, make reservations that require upfront payment, and even create services where AI agents exchange data for a fee.
Right now, this is closer to a proposed idea, but I believe once we find one solid use case, adoption could explode. This goes beyond just a single technology—it represents the beginning of infrastructure that allows AI to participate as a new economic actor on the internet.