Visitar URL original
Welcome to x402 | BANK OF AI | Developer Guide
Skip to main content

Welcome to x402

x402 is an open blockchain payment standard built on the HTTP 402 Payment Required status code. It enables web services to charge for APIs or content through a “pay-before-response” mechanism — without relying on traditional account systems or session management.

x402 currently supports TRON, BNB Smart Chain (BSC), and Base, with plans to expand to a broader multi-chain ecosystem in the future.

Interested in contributing to the documentation?
Feel free to submit a PR to the GitHub repository. Our only principle is to maintain neutrality — aside from essential resource links, please avoid promotional or branded content.

Building with x402? Install the published @bankofai/x402-tron packages together with the official @x402/* packages in your TypeScript app. The x402 repository ships runnable client → server → facilitator examples under examples/typescript/ for reference — exact, gasfree, upto, and batch-settlement.


Why Use x402?​

x402 addresses the core pain points of existing payment systems:

  • High fees and complex workflows in traditional credit card and fiat payment channels
  • Poor support for machine-to-machine (M2M) payments, such as autonomous AI agent transactions
  • Lack of efficient micro-payment infrastructure, making usage-based monetization difficult
  • Leveraging blockchain’s fast and low-cost transaction capabilities

Who Is x402 For?​

  • Sellers: Service providers who want to monetize APIs or content. With minimal configuration, x402 enables direct, programmatic payments from clients.
  • Buyers: Developers and AI agents who want to access paid services without registration flows or manual intervention.

Buyers and sellers interact directly through HTTP requests, while payments are executed transparently and automatically on-chain by the protocol.


What Can You Build?​

x402 supports a wide range of use cases:

  • Pay-per-request APIs
  • AI agents capable of autonomously paying for APIs
  • Digital content paywalls
  • Microservices monetized via microtransactions
  • API aggregation services that do not resell underlying capabilities

How It Works​

At a high level, the workflow is straightforward:

  1. Request Initiated: The buyer requests a protected resource from the server.
  2. Payment Required: If payment is required, the server returns a 402 Payment Required response along with payment instructions.
  3. Payment Submitted: The buyer generates and submits a signed payment payload.
  4. Payment Verified: The server calls the Facilitator’s /verify endpoint to validate the signed payload.
  5. Settlement Executed: The server calls the Facilitator’s /settle endpoint to submit the transaction on-chain.
  6. Resource Delivered: Once settlement succeeds, the server delivers the requested resource.
x402 payment flow, from the first request to the delivered resourcex402 payment flow, from the first request to the delivered resource

To explore further:

Our goal is to build a low-barrier, permissionless, developer-friendly programmable commerce layer on blockchain.


Network Support​

x402 currently supports the following networks:

  • TRON Mainnet (tron:728126428)
  • TRON Shasta Testnet (tron:2494104990) — SDK/CLI only; not settled by the official facilitator
  • TRON Nile Testnet (tron:3448148188)
  • BSC Mainnet (eip155:56)
  • BSC Testnet (eip155:97)
  • Base Mainnet (eip155:8453)
  • Base Sepolia Testnet (eip155:84532)

Base Mainnet payments use official USDC with the exact scheme and EIP-3009 authorization.

Since x402 v2.0.0, TRON identifiers use decimal chain IDs; the older hex forms (tron:0x2b6653dc, tron:0x94a9059e, tron:0xcd8690dc) are still accepted as input aliases.

SDK (TypeScript-only): x402 is a TypeScript-only SDK: the TRON mechanism and TRON resource-sponsoring extension ship as @bankofai/x402-tron and @bankofai/x402-tron-extensions, on top of the official @x402/* packages (core, evm, fetch, express, hono, fastify, next, axios, mcp, extensions). The source is maintained in a pnpm/turbo monorepo, but application development should install the published packages. It defines five named schemes: exact (ERC-3009 / Permit2), upto, batch-settlement, exact_gasfree (TRON), and the currently client-only auth-capture (EVM). The previous-generation Python + TypeScript SDK archive was removed in x402 v2.0.0, and the compatibility npm packages under typescript/packages/legacy/ in v2.1.0. See the SDK Feature Matrix for the full breakdown.


Quick Start​

Ready to build? Start here: