โก x402 โ Internet-Native Payments Protocol with AI Agent ๐ค A next-generation payment protocol enabling seamless, programmable internet transactions powered by AI agents. Designed for automation, micro-payments, and intelligent on-chain interactions across decentralized ecosystems.
multi-chain-x402-payment-protocol is an early-stage TypeScript project in the AI payments / x402 ecosystem, focused on bnb, eth, evm, on-chain. It currently has 1 GitHub stars and 0 forks, and sits alongside related tools like tdm-sdk, Task-router-x402, Ros-X402-Node.
The x402 protocol enables instant, programmable micropayments on the internet. Credit Cards are high friction, hard to accept, have minimum payments that are far too high, and don't fit into the programmatic nature of the internet.
It's time for an open, internet-native form of payments. A payment rail that doesn't have high minimums + % based fee. Payments that are amazing for humans and AI agents.
"1 line of code to accept digital dollars. Near-zero fees, instant settlement, $0.001 minimum payment."
This protocol supports multiple blockchain networks:
app.use(
// How much you want to charge, and where you want the funds to land
paymentMiddleware("0xYourAddress", { "/your-endpoint": "$0.01" })
);
// That's it! See examples/typescript/servers/express.ts for a complete example.
// Minimal Solana x402 server - see examples/solana for complete implementation
app.get('/premium', async (req, res) => {
const payment = req.headers['x-payment'];
if (payment) {
// Verify transaction on Solana
const verified = await verifyPayment(payment);
if (verified) return res.json({ data: 'Premium content!' });
}
// Return 402 with payment requirements
return res.status(402).json({
payment: {
recipientWallet: WALLET.toBase58(),
mint: USDC_MINT.toBase58(),
amount: 1000000, // 1 USDC
cluster: 'devnet'
}
});
});
x402 enables a wide range of micropayment and pay-per-use scenarios:
The key advantage on Solana: fractions of a cent per transaction enabling true micropayments, plus instant settlement for real-time access control.
The BSC-x402 protocol is a chain agnostic standard for payments on top of HTTP, leverage the existing 402 Payment Required HTTP status code to indicate that a payment is required for access to the resource.
It specifies:
PaymentRequirements)X-PAYMENT that is set by clients paying for resourcesX-PAYMENT headerfacilitator)X-PAYMENT-RESPONSE header that can be used by resource servers to communicate blockchain transactions details to the client in their HTTP responsePayment Required Response
{
// Version of the x402 payment protocol
x402Version: int,
// List of payment requirements that the resource server accepts. A resource server may accept on multiple chains, or in multiple currencies.
accepts: [paymentRequirements]
// Message from the resource server to the client to communicate errors in processing payment
error: string
}
paymentRequirements
{
// Scheme of the payment protocol to use
scheme: string;
// Network of the blockchain to send payment on
network: string;
// Maximum amount required to pay for the resource in atomic units of the asset
maxAmountRequired: uint256 as string;
// URL of resource to pay for
resource: string;
// Description of the resource
description: string;
// MIME type of the resource response
mimeType: string;
// Output schema of the resource response
outputSchema?: object | null;
// Address to pay value to
payTo: string;
// Maximum time in seconds for the resource server to respond
maxTimeoutSeconds: number;
// Address of the EIP-3009 compliant ERC20 contract
asset: string;
// Extra information about the payment details specific to the scheme
// For `exact` scheme on a EVM network, expects extra to contain the records `name` and `version` pertaining to asset
extra: object | null;
}
Payment Payload (included as the X-PAYMENT header in base64 encoded json)
{
// Version of the x402 payment protocol
x402Version: number;
// scheme is the scheme value of the accepted `paymentRequirements` the client is using to pay
scheme: string;
// network is the network id of the accepted `paymentRequirements` the client is using to pay
network: string;
// payload is scheme dependent
payload: <scheme dependent>;
}
A facilitator server is a 3rd party service that can be used by a resource server to verify and settle payments, without the resource server needing to have access to a blockchain node or wallet.
POST /verify. Verify a payment with a supported scheme and network:
{
x402Version: number;
paymentHeader: string;
paymentRequirements: paymentRequirements;
}
{
isValid: boolean;
invalidReason: string | null;
}
POST /settle. Settle a payment with a supported scheme and network:
Request body JSON:
{
x402Version: number;
paymentHeader: string;
paymentRequirements: paymentRequirements;
}
Response:
{
// Whether the payment was successful
success: boolean;
// Error message from the facilitator server
error: string | null;
// Transaction hash of the settled payment
txHash: string | null;
// Network id of the blockchain the payment was settled on
networkId: string | null;
}
GET /supported. Get supported payment schemes and networks:
{
kinds: [
{
"scheme": string,
"network": string,
}
]
}
A scheme is a logical way of moving money.
Blockchains allow for a large number of flexible ways to move money. To help facilitate an expanding number of payment use cases, the BSC-x402 protocol is extensible to different ways of settling payments via its scheme field.
Each payment scheme may have different operational functionality depending on what actions are necessary to fulfill the payment.
For example exact, the first scheme shipping as part of the protocol, would have different behavior than upto. exact transfers a specific amount (ex: pay $1 to read an article), while a theoretical upto would transfer up to an amount, based on the resources consumed during a request (ex: generating tokens from an LLM).
See specs/schemes for more details on schemes, and see specs/schemes/exact/scheme_exact_evm.md to see the first proposed scheme for exact payment on EVM chains.
Because a scheme is a logical way of moving money, the way a scheme is implemented can be different for different blockchains. (ex: the way you need to implement exact on Ethereum is very different from the way you need to implement exact on Solana).
Clients and facilitators must explicitly support different (scheme, network) pairs in order to be able to create proper payloads and verify / settle payments.
Requirements: Node.js v24 or higher
From examples/typescript run pnpm install and pnpm build to ensure all dependent packages and examples are setup.
Select a server, i.e. express, and cd into that example. Add your server's ethereum address to get paid to into the .env file, and then run pnpm dev in that directory.
Select a client, i.e. axios, and cd into that example. Add your private key for the account making payments into the .env file, and then run pnpm dev in that directory.
You should see activities in the client terminal, which will display a weather report.
examples/solana/npm installserver-wallet.json for the server (recipient)client-wallet.json for the client (payer)npm run servernpm run clientThe client will pay the server in USDC to access premium content. Transaction details will be displayed with Solana Explorer links.
cd typescriptpnpm installpnpm testThis will run the unit tests for the BSC-x402 packages.
Open contract-facing SDK for payable routes and gateway-backed integrations. Thin public surface for authorize, checkout, and session flows.
Task-router-x402 is a Node.js/Express service for orchestrating robots and agents with x402 payment integration.
A ROS 1 (Noetic) package that turns robot capabilities into paid API endpoints - using Solanaโs x402 protocol for pay-to-access control โ and includes tools for making and verifying payments to external services.
Open Source AI trading agent that operates autonomously across 1000+ markets - Polymarket, Kalshi, Binance, Hyperliquid, Solana DEXs, 5 EVM chains. Scans for edge, executes instantly, manages risk while you sleep. Agent commerce protocol for machine-to-machine payments. Self-hosted. Built on Claude.
Drop-in OpenAI Python client with transparent x402 payment support.
Drop-in OpenAI Typescript client with transparent x402 payment support.
TypeScript Interface for Machine Payments Protocol
Production-ready x402 facilitator server.
Rust SDK for the x402 payment protocol.