Overview
The Machine Payments Protocol (MPP) extends the HTTP 402 “Payment Required” status code so that agents and servers can automatically pay for API access in a single round-trip. No checkout flow, no user accounts, no manual approval. This recipe shows the minimum code to:- Create a server wallet with Dynamic’s Node SDK (Tempo or Solana)
- Fund it for test payments
- Adapt Dynamic’s MPC signing to the MPP client for that chain
- Use
mppxto make a paid request to any MPP-protected endpoint
mppx’s tempo method. On Solana, settlement uses native SOL or SPL tokens via @solana/mpp.
For a full Tempo example, see the tempo-mpp-example on GitHub.
For how HTTP 402 payment flows work in general, and how MPP relates to the separate x402 stack, see the HTTP 402 overview.
Prerequisites
- Node.js 22+
- Dynamic Environment ID and API token. Find these in the Dynamic Dashboard
- Embedded wallets enabled in your Dynamic dashboard
- For Solana: Solana enabled under Chains
Setup
Install the packages for your chain:- Tempo
- Solana
.env file with your credentials:
- Tempo
- Solana
.env
Use
node --env-file=.env to load the file automatically, or a library like dotenv.Step 1: Initialize the Dynamic wallet client
- Tempo
- Solana
Step 2: Create a wallet
Wallets are created with a 2-of-2 threshold signature scheme (MPC). Persist the returned metadata (and key shares, when you hold them) securely alongside the wallet address.- Tempo
- Solana
Step 3: Fund the wallet
- Tempo
- Solana
Tempo’s Moderato testnet faucet distributes test stablecoins (pathUSD, AlphaUSD, BetaUSD, ThetaUSD). These are used as payment tokens for MPP requests.
You can also visit docs.tempo.xyz to request tokens manually.
Step 4: Build a chain-compatible signer
- Tempo
- Solana
Dynamic’s Node SDK signs transactions using its internal viem serializer, which doesn’t understand Tempo’s custom transaction format. You need to create a
LocalAccount adapter that uses Tempo’s serializer instead.Step 5: Make an MPP payment
Initializemppx with the payment method for your chain and use mppx.fetch() in place of the global fetch for any 402-protected URL. The client handles the negotiation, signs the payment, and resends the request automatically.
- Tempo
- Solana
https://mpp.dev/api/ping/paid is a public Tempo test endpoint that accepts any valid MPP payment. Use it to verify your setup before pointing at a real resource.Putting it all together
- Tempo
- Solana