Skip to main content

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:
  1. Create a server wallet with Dynamic’s Node SDK (Tempo or Solana)
  2. Fund it for test payments
  3. Adapt Dynamic’s MPC signing to the MPP client for that chain
  4. Use mppx to make a paid request to any MPP-protected endpoint
On Tempo, settlement uses Tempo’s custom transaction format via 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:
Create a .env file with your credentials:
.env
Use node --env-file=.env to load the file automatically, or a library like dotenv.

Step 1: Initialize the Dynamic wallet client


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.

Step 3: Fund the wallet

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

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

Initialize mppx 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.
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


Additional Resources

Last modified on August 19, 2026