Get started in three steps
Transform your API into a revenue stream with Solana micropayments in minutes.Step 1: Install CheapPay
Choose your package manager
Choose your package manager
Install CheapPay using your preferred package manager:
For Next.js projects, use
@cheapay/x402-next
instead of @cheapay/x402-express
Available packages
Available packages
CheapPay provides framework-specific packages for seamless integration:
@cheapay/x402
- Core types and utilities@cheapay/x402-express
- Express.js middleware@cheapay/x402-next
- Next.js middleware
Start with the core package and your framework-specific middleware.
Step 2: Set up payment middleware
Express.js setup
Express.js setup
Add payment protection to your Express API in seconds:
Next.js setup
Next.js setup
For Next.js projects, create a
middleware.ts
file:Your Next.js API routes are now payment-protected automatically!
Step 3: Test your integration
Start earning from API calls
Start earning from API calls
- Start your server and navigate to your protected endpoint
- See the payment prompt - CheapPay automatically shows a beautiful paywall
- Connect your Solana wallet (Phantom, Solflare, or Backpack)
- Complete the payment - Users pay $0.01 USDC to access your API
- Receive instant payment - USDC appears in your wallet immediately
Testing tip: Use Solana devnet for free testing with fake USDC tokens. Switch to
solana-mainnet
and TokenMint.USDC.mainnet
for production.Next steps
Now that you have payments working, explore these advanced features:Configure wallets
Customize wallet options and user experience.
Custom pricing
Set up dynamic pricing and multiple payment tiers.
Analytics dashboard
Track earnings and monitor API usage.
Production deployment
Deploy your payment-enabled API to production.
Environment setup
For production use, set up these environment variables:Security reminder: Never expose private keys in your code. CheapPay only
needs your public wallet address to receive payments.