π Solana Paywall Random Number Generator (Next.js)
A simple proof-of-concept crypto paywall app built with Next.js + Solana wallets + Pump tokenized-agents payments.
Users connect their Solana wallet, pay a small fee (e.g. 0.1 SOL), and once the payment is verified server-side they can generate a random number between 0 and 1000.
This project demonstrates how to build action-gated features powered by on-chain payments.
β¨ Features
β Solana wallet connection (Phantom / Solflare / Backpack etc.)
β On-chain payment required to unlock functionality
β Server-side invoice verification
β HTTP-only cookie access control
β Random number generator (protected endpoint)
β Built with Next.js App Router
β Uses Pump tokenized-agents payment skill
π§ Concept
This app shows a core Web3 pattern:
Pay β Verify β Unlock Feature
Instead of traditional authentication or subscriptions:
Wallet = identity
Transaction = payment
Backend verification = access control
This architecture can be used to build:
paid APIs
premium AI tools
crypto SaaS
content paywalls
games
agent-to-agent commerce
token-gated utilities
ποΈ Architecture
- Create Invoice
The backend generates payment parameters and builds an unsigned Solana transaction using the Pump payment skill.
- Wallet Signs Transaction
The frontend asks the connected wallet to sign and send the transaction.
- Backend Verifies Payment
After submission, the backend verifies:
correct wallet
correct mint / recipient
correct payment amount
valid invoice reference
If valid β grants access via secure cookie.
- Feature Unlock
User can now call protected endpoints such as:
GET /api/random
Returns a random number between 0β1000.
π Project Structure app/ page.tsx β UI (wallet connect + payment + RNG) api/ invoice/route.ts β create invoice + transaction verify/route.ts β verify payment + grant access random/route.ts β protected random number endpoint
lib/ payment.ts β PumpAgent helpers
.env.example β configuration template βοΈ Setup
- Install dependencies npm install
- Configure environment
Copy:
.env.example β .env.local
Then set:
PAYMENT_ACCESS_SECRET=your_long_random_secret NEXT_PUBLIC_RPC_URL=your_rpc_url 3. Run the app npm run dev
Open:
http://localhost:3000 π° Payment Configuration
Default settings:
Payment: 0.1 SOL
Currency: Wrapped SOL
Agent mint:
You can change:
payment amount
token mint
RPC provider
access duration logic
π Security Notes
This project demonstrates basic paywall logic.
For production you should also consider:
replay protection
access expiry / session duration
rate limiting
signature verification hardening
transaction confirmation depth
database storage of invoices
π Ideas to Extend
Token-gated AI generation
Paid API marketplace
NFT mint access
Web3 SaaS subscriptions
Agent-to-agent micro-payments
Premium trading signals
Crypto games
π License
MIT