About X402 Express

Project Overview

This project demonstrates how to use X402 payment system with Express.js, allowing API endpoints to charge for access using Solana USDC payments.

Project Structure

Protected Route

The /api/protected endpoint requires a payment of 100 USDC to access. It uses X402 middleware to automatically verify and process payments.

Configuration

Payment configuration is centralized in src/config.ts. The following environment variables can be set to customize the payment settings:

Client Usage

The client demonstrates how to automatically pay for API access using X402:

  1. Load your Solana keypair
  2. Create a payment handler with X402
  3. Wrap fetch to automatically handle payments
  4. Call the protected endpoint (payment happens automatically)

X402 Middleware

X402 middleware is configured using centralized settings in src/config.ts:

The middleware automatically:

Development

For detailed setup instructions, deployment guides, and code examples, please refer to the GitHub repository README.