Micro-utility store powered by x402 payments on Solana
Website: vellumlabs.app Β· X: @VellumLabsAi
Vellum is a production-ready monorepo that demonstrates how to build paid micro-services using the x402 protocol with PayAI facilitator on Solana (USDC-SPL). Each service is accessed through a single HTTP endpoint that returns 402 Payment Required, then verifies and settles payment before fulfilling the order.
Contributing? See CONTRIBUTING.md for a quick add-a-service guide.
- Single payment endpoint:
POST /x402/pay?sku=<id> - HTTP 402 payments: Standard x402 protocol with PayAI facilitator
- Solana USDC: Payments in USDC (SPL) on Solana devnet/mainnet
- 7 micro-utilities: Image generation, meme maker, background removal, upscaling, favicon generator, URL summarizer, PDF-to-text
- Supabase Storage: Results delivered via signed URLs (1hr TTL)
- Idempotency: Safe retries using transaction signatures
- Multi-Wallet Support: Connect with Phantom, Solflare, Torus, or Ledger
- Live Payments: Users can actually pay and receive services directly from the UI
- Balance Checking: Automatic USDC balance validation before transactions
- Full x402 Flow: Complete HTTP 402 β payment β fulfillment cycle
- Premium UX: Next.js 15 with Inspira UI, animated gradients, and responsive design
- Real-time Feedback: Live payment status updates and error handling
π Try it live: Visit
/toolsto connect your wallet and test any service with real devnet USDC!
/apps
/api # Express server with single /x402/pay route
/web # Next.js 15 marketing site with Inspira UI
/packages
/shared # Shared utilities (env, x402, payai, supabase, etc.)
/scripts
preflight.ts # Config validator and ATA derivation
/tests
http.curl.md # HTTP test harness
units.test.ts # Unit tests for price conversions
pnpm installCopy .env.example to .env and fill in your values:
cp .env.example .env
cp apps/web/.env.example apps/web/.envRequired values:
VAULT_OWNER: Your Solana public key (receives payments)SUPABASE_URL,SUPABASE_SERVICE_ROLE_KEY: Supabase project credentialsNEXT_PUBLIC_API_URL: API endpoint (default: http://localhost:3001)NEXT_PUBLIC_SOLANA_CLUSTER: devnet or mainnet-betaNEXT_PUBLIC_USDC_MINT_ADDRESS: USDC token mint addressGEMINI_API_KEY: Google Gemini API key for image generation
pnpm preflightThis will:
- Validate environment configuration
- Derive USDC Associated Token Account
- Display SKU catalog with prices
- Check facilitator connectivity
# Terminal 1: API server
cd apps/api
pnpm dev
# Terminal 2: Web app
cd apps/web
pnpm devAPI runs on http://localhost:3001
Web runs on http://localhost:3000
| SKU | Price | Description |
|---|---|---|
img-gen-basic |
$0.03 | Generate 768Γ768 PNG from text prompt (Gemini) |
meme-maker |
$0.03 | Create memes with templates or custom images |
bg-remove |
$0.06 | Remove background from image (PNG with alpha) |
upscale-2x |
$0.05 | Upscale image 2Γ with quality enhancement |
favicon |
$0.03 | Generate multi-size favicons (16-512px + ICO) |
urlsum |
$0.03 | Extract and summarize webpage content |
pdf2txt |
$0.04 | Extract text from PDF (β€10MB) |
- Offer: Client sends POST request, receives HTTP 402 with payment requirements
- Pay: Client signs Solana transaction, retries with
X-PAYMENTheader - Verify: Server calls PayAI
/verifyendpoint - Settle: Server calls PayAI
/settleendpoint - Fulfill: Server processes SKU and returns result with
X-PAYMENT-RESPONSEheader
Test with Real Payments on Devnet:
- Install a Solana wallet (Phantom recommended)
- Switch wallet to Devnet in settings
- Get devnet USDC from faucet: https://spl-token-faucet.com/?token-name=USDC-Dev
- Visit http://localhost:3000/tools
- Click "Connect Wallet" and select your wallet
- Choose any tool (e.g., Image Generation)
- Fill in inputs and click "Pay & Get Result"
- Approve transaction in wallet popup
- View your result instantly!
What to Test:
- β Wallet connection/disconnection
- β Balance checking (sufficient vs insufficient funds)
- β Transaction signing and submission
- β Result display with download links
- β Idempotency (same request returns cached result)
- β Error handling (rejected transaction, network issues)
See WALLET_INTEGRATION_GUIDE.md for comprehensive testing guide.
See tests/http.curl.md for curl commands that test each SKU:
# Should return 402
curl -i -X POST "http://localhost:3001/x402/pay?sku=img-gen-basic" \
-H "Content-Type: application/json" \
-d '{"prompt":"A sunset over mountains"}'cd tests
pnpm testRequires Node 20+ runtime (not edge) due to sharp dependency.
Environment variables: Copy all from .env.example
Recommended platforms:
- Railway
- Render
- Fly.io
- Digital Ocean App Platform
Standard Next.js 15 deployment:
cd apps/web
pnpm build
pnpm startRecommended platforms:
- Vercel
- Netlify
- Cloudflare Pages
vellum/
βββ apps/
β βββ api/ # Express API server
β β βββ src/
β β βββ fulfillment/ # SKU handlers (one per service)
β β βββ routes/ # x402 route handler
β β βββ index.ts # Server entry point
β βββ web/ # Next.js frontend
β βββ src/
β βββ app/ # App router pages
β βββ components/ # React components (Inspira UI)
βββ packages/
β βββ shared/ # Shared TypeScript packages
β βββ src/
β βββ env.ts # Zod environment validation
β βββ x402.ts # Payment requirements builder
β βββ payai.ts # PayAI verify/settle client
β βββ supabase.ts # Storage client
β βββ units.ts # USDC atomic helpers
β βββ validators.ts # Input validation
β βββ catalog.ts # SKU definitions
βββ scripts/
β βββ preflight.ts # Preflight checker
βββ tests/
βββ http.curl.md # HTTP test harness
βββ units.test.ts # Unit tests
-
buildPaymentRequirements()inpackages/shared/src/x402.ts- Must return identical object for 402 response AND PayAI calls
- Marked with
=== LOCKED ===comments
-
CORS headers
- Always include
Access-Control-Allow-Origin: * - Always expose
X-PAYMENT-RESPONSEheader
- Always include
-
Atomic USDC units
- All prices stored as strings with 6 decimals
- Use bigint for all calculations
-
Idempotency
- Cache results by transaction signature
- Never fulfill same tx twice
- API: Node 20, Express, TypeScript
- Frontend: Next.js 15, React 18, Tailwind CSS, Framer Motion
- Payments: x402 protocol, PayAI facilitator, Solana USDC (SPL)
- Storage: Supabase Storage with signed URLs
- AI: Google Gemini (image generation)
- Image Processing: sharp, to-ico
- PDF/HTML: pdf-parse, readability, linkedom
MIT