Beta Version - Seeking Security Audit
HTTP 402 Payment Required Protocol on Solana
BoberPay Beaver Logo

BoberPay.
x402 Payment Channels
Payment Channels Protocol for Solana.

x402 brings HTTP 402 Payment Required to life with Solana payment channels. Our protocol enables micropayments for API requests with 99.8% cost savings compared to solana transaction, making true pay-per-use APIs economically viable.

// Server: ONE method verifies BOTH payment types
import { TransactionVerifier } from '@x402-solana/core';

const result = await verifier.verifyX402Payment(
  req.headers['x-payment'],
  {
    scheme: 'exact',    // ← On-chain USDC (400-800ms)
    // OR
    scheme: 'channel',  // ← Off-chain instant (<10ms)

    network: 'solana-devnet',
    payTo: '...',
    maxAmountRequired: '10000',
    resource: '/api/data',
  }
);

if (result.valid) {
  res.json({ data: 'Premium content' });
}

Modular NPM Packages

Choose the packages you need for your architecture

X402 Protocol Packages

@x402-solana/server

Server middleware with unified payment verification

@x402-solana/client

Client SDK for on-chain USDC payments

@x402-solana/core

Unified verification for both on-chain and channel payments

Payment Channel Packages

@solana-payment-channel/server

Channel management with automatic X402 fallback

@solana-payment-channel/client

Client SDK for creating and managing payment channels

@solana-payment-channel/core

Channel lifecycle, state management, claim generation

Use @x402-solana for on-chain only, or add @solana-payment-channel for instant, zero-fee channel payments. Server verification works with both.

Live Performance Test

Run batch transactions in parallel to see the speed and cost difference

Connecting to demo server...

Both tests will run 10 transactions simultaneously

On-Chain Payments

Payment Channels ⚡

No transactions yet. Click the buttons above to test!

All transactions are real and verified on Solana Devnet. Real-time updates via WebSocket.

Two Payment Schemes, One Verification API

Choose between on-chain or off-chain payments. Your server uses the same method for both.

On-Chain (exact)

400-800ms
~$0.0005/payment
  • USDC transactions on Solana
  • No setup required
  • Works across any API
  • Best for sporadic use

Channels (channel)

<10ms
$0/payment
  • Ed25519 signatures (instant)
  • 99.7% cost savings
  • Requires channel setup
  • Best for high-frequency

Your Server Code

verifyX402Payment()
  • ONE method for both schemes
  • Automatic scheme detection
  • Same @x402-solana/core package
  • Simple integration

Unified verification API • Choose your scheme based on your needs • Zero lock-in

Unified Verification Flow

Same API method handles both on-chain and off-chain payments

On-Chain Payment Flow

1
Client creates USDC transaction
Uses @x402-solana/client
2
X-PAYMENT header with scheme: 'exact'
Includes transaction signature
3
Server calls verifyX402Payment()
Fetches transaction from Solana RPC
4
Verifies USDC transfer amount
400-800ms verification
5
Returns content if valid
HTTP 200 OK

Channel Payment Flow

1
Client creates signed claim
Uses @solana-payment-channel/client
2
X-PAYMENT header with scheme: 'channel'
Includes Ed25519 signature
3
Server calls verifyX402Payment()
Same method, different scheme!
4
Verifies signature locally
<10ms verification
5
Returns content if valid
HTTP 200 OK

Same Server Code

Your server uses verifyX402Payment() for both schemes. The method automatically handles verification based on the scheme field.

Client Chooses

Clients decide which payment scheme to use. Use on-chain for simplicity, channels for high-frequency needs.

No Lock-In

Switch between schemes anytime. Both use the same X-PAYMENT header format and verification API.

Quick Start

Get up and running in minutes with our TypeScript-first SDK

Server: Unified Verification

import { TransactionVerifier } from '@x402-solana/core';

const verifier = new TransactionVerifier({
  rpcUrl: process.env.SOLANA_RPC_URL,
});

// ONE method handles BOTH payment types
app.post('/api/verify', async (req, res) => {
  const result = await verifier.verifyX402Payment(
    req.headers['x-payment'],
    {
      scheme: 'exact', // or 'channel'
      network: 'solana-devnet',
      payTo: 'YourAddress...',
      maxAmountRequired: '10000',
      resource: '/api/data',
    }
  );

  if (result.valid) {
    res.json({ data: 'Premium content' });
  }
});

Client SDK

// Option 1: On-chain payments
import { X402Client } from '@x402-solana/client';
const response = await client.pay({
  url: 'https://api.example.com/data',
  // Creates on-chain USDC transaction
});

// Option 2: Channel payments
import { ChannelClient } from
  '@solana-payment-channel/client';

const channelClient = new ChannelClient({
  rpcUrl: process.env.SOLANA_RPC_URL,
  wallet: myWalletKeypair,
});

const response = await channelClient.pay({
  url: 'https://api.example.com/data',
  // Creates signed channel claim
});

Key Points

  • Server-side: Use @x402-solana/core for verification (handles both schemes)
  • Client-side (on-chain): Use @x402-solana/client for USDC transactions
  • Client-side (channels): Use @solana-payment-channel/client for instant claims
  • Same API: verifyX402Payment() works for both, just different scheme parameter
  • No lock-in: Switch between schemes based on your needs
Cost Comparison: On-Chain vs Channels

When to Use Payment Channels

Payment channels provide instant, zero-fee payments for high-frequency scenarios

On-Chain (scheme: 'exact')

10,000 requests~$5
Processing time~1.5 hours
Transactions needed10,000

✓ Perfect for sporadic usage
✓ Multi-API access
✓ No setup required

Channels (scheme: 'channel')

10,000 requests~$0.0015
Processing time~10 seconds
Transactions needed2 (open + close)

✓ Instant off-chain verification
✓ Zero fees per payment
✓ 99.7% cost reduction

Ready to Get Started?

One verification API. Two payment schemes. Choose on-chain for simplicity or channels for speed.

Beta/Hackathon Version - Use at Your Own Risk

This project was built for a hackathon and is currently in beta. While functional, it has not undergone a professional security audit and should not be used in production environments with real funds.

Seeking Audit: We are actively looking for security researchers and auditors to review the smart contracts and payment channel implementation.
Devnet Only: All demos use Solana Devnet with test tokens. Do not use mainnet without thorough auditing.
Educational Purpose: This implementation demonstrates HTTP 402 concepts and payment channels - use for learning and experimentation.