Overview
Tempo is a blockchain built for machine-to-machine payments. Its Machine Payment 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 an EVM wallet on Tempo Moderato testnet with Dynamic’s Node SDK
- Fund it with test stablecoins from Tempo’s faucet
- Wire up a
viemLocalAccountbacked by Dynamic’s MPC signing that understands Tempo’s custom transaction format - Use
mppxto make a paid request to any MPP-protected endpoint
Prerequisites
- Node.js 22+
- Dynamic Environment ID and API token — find these in the Dynamic Dashboard
- Embedded wallets enabled in your Dynamic dashboard
Setup
Install the required packages:.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). The returnedexternalServerKeyShares are your signing credentials — store them securely alongside the wallet address.
Step 3: Fund with test stablecoins
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 Tempo-compatible viem account
Dynamic’s Node SDK signs transactions using its internal viem serializer, which doesn’t understand Tempo’s custom transaction format. You need to create aLocalAccount adapter that uses Tempo’s serializer instead.
Step 5: Make an MPP payment
Initializemppx with the Tempo payment method 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 test endpoint that accepts any valid MPP payment. Use it to verify your setup before pointing at a real resource.