mppx SDK handles the 402 payment flow automatically.
What is MPP?
MPP (Machine Payments Protocol) is an open protocol for machine-to-machine payments over HTTP. When a resource requires payment, the server responds with402 Payment Required and payment details. The client signs a payment credential using the agent’s wallet and retries the request. Settlement happens on the Tempo blockchain using PathUSD.
Installation
@privy-io/nodeprovides server-side wallet creation and signingmppxprovides the MPP client that handles 402 payment flowsviemprovides the account interface used by Privy’s viem helper andmppx
Creating a Privy-backed account
MPP’stempo.charge() payment method expects a viem Account for signing. Use Privy’s createViemAccount helper to create a viem account backed by a Privy wallet.
Use
@privy-io/node v0.20.0 or later. Earlier versions required custom Tempo transaction
serialization logic.Making MPP payments
Pass the Privy-backed account to the MPP client’stempo.charge() method. The client automatically handles 402 responses, signs payment credentials, and retries requests.
Using mppx.fetch
mppx.fetch is a drop-in replacement for fetch. When a server returns 402 Payment Required, the client reads the payment requirements, signs a credential with the Privy wallet, and retries the request automatically.
Use tempo({account}) instead when the client should support both one-time charges and Tempo sessions.
Using polyfill mode
Your app can also polyfill the globalfetch so all HTTP requests handle 402 challenges automatically:
How it works
- Agent requests content: Your app calls
mppx.fetch()or the polyfilledfetch() - Server responds 402: Returns payment requirements (amount, currency, recipient)
- MPP client signs credential: Uses the Privy-backed account to sign a payment credential
- Retry with credential: Request repeats with the signed credential attached
- Server verifies and settles: Verifies the credential and settles payment on Tempo
- Server delivers: Returns content with
200 OK
Creating an MPP-enabled service
Themppx/nextjs package provides middleware for adding payment requirements to API routes:
402 Payment Required. With a valid credential, it verifies the payment, settles on Tempo, and returns the data.
Full example
Learn more
- MPP Protocol documentation - Protocol specification and guides
- mppx SDK - Client and server SDK for MPP
- Privy server wallets - Creating and managing server-side wallets
- Full demo application - Complete Next.js example

