Skip to content

mpptestkit/monetize

Repository files navigation

Monetize

Interactive demo for MPP Testkit use case: Monetize any endpoint. No billing infra needed.

Shows how any API endpoint can earn SOL per request using HTTP 402 on Solana — no Stripe, no database, no subscriptions. One function wraps your handler and handles the entire payment cycle automatically.

What it demonstrates

  • Server receives an incoming request
  • MPP middleware returns 402 Payment Required with a Payment-Request header
  • Client SDK pays automatically on-chain and retries with a Payment-Receipt header
  • Server verifies the transaction, serves the response, earns SOL

All from the server's perspective — live earnings counter, request log, step tracker.

SSE events

Event Description
init Middleware initialized with endpoint and amount
server_ready Server listening, MPP active
request_in Incoming GET request detected
challenge_sent 402 returned with Payment-Request header
payment_received Payment-Receipt header received from client
verifying Checking transaction on-chain
verified Payment confirmed
served 200 OK sent, SOL earned
done Session complete — total earnings summary

Endpoint types

ID Path Amount
weather /api/weather 0.001 SOL
translate /api/translate 0.001 SOL
summarize /api/summarize 0.002 SOL
prices /api/prices 0.001 SOL

Dev setup

npm install
npm run dev
# runs on http://localhost:5175

Related

About

Interactive demo for MPP Testkit use case: Monetize any endpoint. No billing infra needed.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors