
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
Server middleware with unified payment verification
Client SDK for on-chain USDC payments
Unified verification for both on-chain and channel payments
Payment Channel Packages
Channel management with automatic X402 fallback
Client SDK for creating and managing payment channels
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
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)
- USDC transactions on Solana
- No setup required
- Works across any API
- Best for sporadic use
Channels (channel)
- 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
Channel Payment Flow
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
When to Use Payment Channels
Payment channels provide instant, zero-fee payments for high-frequency scenarios
On-Chain (scheme: 'exact')
✓ Perfect for sporadic usage
✓ Multi-API access
✓ No setup required
Channels (scheme: 'channel')
✓ 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.