RootIB: RB-20260314003056-C9D0E1F2
Solana-Gated Random Number Generator
A Next.js app that gates access behind a Solana payment using the pump.fun tokenized agent protocol.
How it Works
- User connects their Solana wallet (Phantom or Solflare)
- User clicks Pay 0.1 SOL & Generate
- The server builds an invoice transaction via
@pump-fun/agent-payments-sdk - The user signs the transaction in their wallet
- The server verifies the on-chain payment via
validateInvoicePayment - A random number between 0 and 1000 is returned
Agent Token
Mint: 28rwY1tifqrrZ22KCVzubqcBRvtqwCLGzHcG8ZxPpump
View on pump.fun: https://pump.fun/coin/28rwY1tifqrrZ22KCVzubqcBRvtqwCLGzHcG8ZxPpump
Quick Start
# 1. Install dependencies
npm install
# 2. Configure environment
cp .env.local.example .env.local
# Edit .env.local with your Solana RPC URL
# 3. Run the development server
npm run dev
# → http://localhost:3001
Environment Variables
| Variable | Default | Description |
|---|---|---|
SOLANA_RPC_URL |
https://rpc.solanatracker.io/public |
Server-side Solana RPC |
NEXT_PUBLIC_SOLANA_RPC_URL |
https://rpc.solanatracker.io/public |
Client-side Solana RPC |
AGENT_TOKEN_MINT_ADDRESS |
28rwY1...pump |
pump.fun agent token mint |
CURRENCY_MINT |
So11...12 (wrapped SOL) |
Payment currency mint |
PRICE_AMOUNT |
100000000 |
Price in lamports (0.1 SOL) |
API Endpoints
POST /api/create-invoice
Builds an unsigned payment transaction for the user to sign.
Body: { "userWallet": "<base58 public key>" }
Response: { "transaction": "<base64>", "memo": "...", "startTime": "...", "endTime": "...", "amount": "..." }
POST /api/verify-payment
Verifies that the invoice was paid on-chain and returns a random number.
Body: { "userWallet", "memo", "startTime", "endTime", "amount" }
Response: { "success": true, "randomNumber": 742 } or { "success": false, "error": "..." }
Tech Stack
- Next.js 15.2.9 (App Router)
- @pump-fun/agent-payments-sdk@3.0.0 — payment instructions and verification
- @solana/web3.js@^1.98.0 — transaction building and RPC
- @solana/wallet-adapter-react — wallet connection UI
Pump.fun Ecosystem
Follow on Pump! Code: DiamondBoi — https://refer.pump.fun/DiamondBoi
New users: https://join.pump.fun/HSag/ko3gg0x0
| © 2008-2026 Barbrick Design | BarbrickDesign@gmail.com |