A demo server with both MPP and x402 gated endpoints, powered by Surfpool.
- Node.js 20+
pnpm install
pnpm dev # watch mode — restarts on file changes
pnpm start # single runBy default the server connects to the public Surfpool sandbox at 402.surfnet.dev:8899. No local setup needed.
If you prefer to run a local Surfpool instance:
# Install and start Surfpool
curl -sL https://run.surfpool.run/ | bash
surfpool start
# Point the server at localhost
RPC_URL=http://localhost:8899 pnpm devThen use --local with pay:
pay --local curl http://localhost:3402/mpp/quote/SOLpay --sandbox curl http://localhost:3402/mpp/quote/AAPL
pay --sandbox curl http://localhost:3402/mpp/weather/parispay --sandbox curl http://localhost:3402/x402/joke
pay --sandbox curl http://localhost:3402/x402/factcurl http://localhost:3402/health| Variable | Default | Description |
|---|---|---|
RPC_URL |
https://402.surfnet.dev:8899 |
Surfpool RPC endpoint |
PORT |
3402 |
Server port |
NETWORK |
localnet |
Solana network |
SECRET_KEY |
test-secret-key-for-dev |
MPP secret key |
FEE_PAYER_KEY |
(generated) | Base58 keypair for fee payer |
RECIPIENT |
(fee payer) | Payment recipient address |
- MPP endpoints use
@solana/mppwith thewww-authenticate/Authorizationheader flow - x402 endpoints use
x402-expresswith theX-PAYMENT-REQUIRED/X-PAYMENTheader flow - An embedded local facilitator runs on port 3403 to handle x402 verify/settle without needing an external service
- Both are configured to accept USDC payments with server-sponsored fees
- On startup, the server bootstraps the fee payer with 100 SOL + 1000 USDC via surfnet cheatcodes