9 min read
Overview
The Machine Payments Protocol (MPP) lets you pay for API access inline with an HTTP request. No accounts, no API keys, just a wallet and a stablecoin balance. The payment happens as part of the request itself, and the response comes back with a receipt.
This is particularly useful for accessing blockchain data. RPC providers that support MPP expose standard JSON-RPC endpoints that any wallet can call. You pay per request using stablecoins on the Tempo blockchain, and the provider verifies the payment before returning the data. Agents, scripts, and applications can start querying blockchain state immediately without going through a signup flow.
Tempo plays two roles here: it's the payment rail that settles MPP transactions, and it maintains a fork of Foundry that gives cast native MPP support. cast is Foundry's command-line tool for making RPC calls, sending transactions, and interacting with smart contracts. Once you install the Tempo fork, cast handles 402 payment challenges on its own.
This guide walks through setting up Foundry with Tempo, making paid RPC calls with cast. We'll use Quicknode's MPP endpoints as the provider throughout the examples.
What You Will Need
- Tempo CLI installed (for wallet management and
castMPP support) - Foundry installed (for the
castmethod)
What You Will Do
- Understand the Machine Payments Protocol and why it exists
- Set up a Tempo wallet and install the Foundry Tempo fork
- Make paid RPC calls with
castusing both charge and session intents - Access blockchain data from Quicknode's MPP endpoints
- Manage payment sessions and verify transactions onchain
What Is the Machine Payments Protocol (MPP)?
The Machine Payments Protocol is an open standard proposed to the IETF that adds inline payments to any HTTP endpoint. It is designed by Tempo and Stripe to solve a specific problem: programmatic clients (agents, scripts, bots) have no good way to pay for API access without a human setting up billing first.
Traditional payment flows rely on checkout forms, browser sessions, and visual CAPTCHAs, all designed for humans. MPP replaces those with a machine-readable payment negotiation built on HTTP 402 Payment Required, a status code that has existed since HTTP/1.1 but was never formally standardized until now.
How MPP Works in Practice
The protocol follows a challenge-response pattern using standard HTTP headers:
- Request - The client sends a normal HTTP request (GET, POST, etc.) to a paid endpoint.
- Challenge - The server responds with
402 Payment Requiredand aWWW-Authenticate: Paymentheader. This header describes the price, accepted currencies, recipient address, and available payment methods. - Pay - The client picks a payment method and fulfills it (signs a stablecoin transfer, pays a Stripe invoice, etc.).
- Retry - The client re-sends the original request with an
Authorization: Paymentheader containing proof of payment (the "Credential"). - Deliver - The server verifies the payment and returns the response with a
Payment-Receiptheader.
Client libraries like mppx and Foundry's Tempo fork handle steps 2-4 automatically. From your code's perspective, the request just works.
Payment Intents: Charge vs. Session
MPP defines two payment intents that control how billing works:
| Charge | Session | |
|---|---|---|
| Pattern | One-time payment per request | Pay-as-you-go via payment channel |
| Settlement | Immediate onchain transaction | Offchain vouchers, periodic onchain settlement |
| Best for | Occasional queries, simple integrations | High-frequency requests, agents, metered billing |
Sessions work by opening an onchain payment channel with an initial deposit. Each subsequent request includes a signed voucher ("I have now consumed up to X total") that the server verifies with a single ecrecover (a cryptographic signature recovery function used in EVM chains), no onchain transaction needed per request. When the session ends, the server settles the final balance onchain and refunds unused deposit.
SDKs and Tools
This guide uses two client-side tools:
- Tempo CLI - Manages your Tempo wallet (keys, balances, funding).
- Foundry (Tempo fork) - Foundry is a toolkit for EVM development, and
castis its command-line tool for making onchain RPC calls. The Tempo fork adds native MPP support tocast. It reads wallet credentials from the Tempo CLI, so the Tempo wallet needs to be set up first.
See the Tempo CLI docs, and Tempo Foundry SDK docs for full references.
Setting up Tempo Wallet and Foundry
Before you can make paid RPC calls, you need two things: a Tempo wallet (to sign payments) and the Tempo fork of Foundry (to give cast MPP support). The Foundry fork reads wallet credentials from the Tempo CLI, so the Tempo wallet must be set up first.
Step 1: Install the Tempo CLI
curl -fsSL https://tempo.xyz/install | bash
To update later, run tempoup. Verify with tempo --version.
Step 2: Create and Connect a Tempo Wallet
tempo wallet login requires a browser for the initial authentication. For agents and automated scripts, you can create scoped access keys with tempo wallet keys after the initial login. These keys have independent spending limits and don't require browser interaction to use.
tempo wallet login
This opens a browser flow to create or connect a Tempo Wallet. If you don't have one, the flow creates it. Once logged in, verify everything is ready:
tempo wallet whoami
You should see your wallet address, balance, access key, and spending limits:
Wallet: 0xb9eb3aa4bd212928fb92def7f17318e0149bfc10
Balance: 1.000000 USDC.e
Key: 0x1697b73624b7515f4e1464415d86b83b3956cae2
Chain: tempo
Expires: 29d 23h
Limit: 0.000000 / 100.000000 USDC.e (100.000000 remaining)
If you see a wallet address and a key, the wallet is set up and cast can use it for MPP payments.
Step 3: Fund the Wallet
tempo wallet fund
This opens funding options for your wallet. For mainnet, you need pathUSD or USDC.e on Tempo (Chain ID: 4217). You can also bridge USDC to Tempo or swap on the Tempo DEX.
Quicknode's MPP endpoints let you make up to 10,000 free RPC requests per intent using testnet stablecoins on Tempo Moderato (charge and session counted separately).
You can get testnet fund by running this command
curl -X POST https://docs.tempo.xyz/api/faucet \
-H "Content-Type: application/json" \
-d '{"address": "<YOUR_ADDRESS>"}'
Check your balances at any time:
tempo wallet whoami
Step 4: Install Foundry With Tempo Support
If you don't have foundryup yet, install it first:
curl -L https://foundry.paradigm.xyz | bash
Then install the Tempo fork:
foundryup -n tempo
This installs Tempo-compatible versions of forge, cast, anvil, and chisel. Verify the installation:
forge -V
The output should include -tempo in the version string (e.g. forge 1.6.0-nightly-tempo). If it does, you're on the right fork.
Accessing Blockchain Data via Quicknode MPP
Quicknode runs MPP endpoints that gives you access to 140+ blockchain networks without creating an account. We'll use the MPP endpoints for all the examples in this guide.
Quicknode MPP Endpoints
| Intent | URL pattern | Cost per request |
|---|---|---|
| Charge | https://mpp.quicknode.com/<network> | $0.001 |
| Session | https://mpp.quicknode.com/session/<network> | $0.00001 |
Replace <network> with a supported network slug. Quicknode MPP supports the same 140+ networks as Quicknode x402, including all testnets. You can fetch the full list of supported slugs dynamically via:
curl https://x402.quicknode.com/networks
Common slugs: tempo-mainnet, ethereum-mainnet, base-mainnet, polygon-mainnet, solana-mainnet, arbitrum-mainnet.
Sessions are 100x cheaper per request than charges. If you're making more than a handful of calls, sessions are the way to go.
The llms.txt Discovery File
Quicknode publishes a machine-readable description of their MPP service at:
https://mpp.quicknode.com/llms.txt
This file follows the llms.txt convention and contains supported payment methods, endpoint patterns, client setup code, pricing, rate limits, error codes, and wallet generation snippets for both Tempo and Solana. If you're building an agent that needs to discover and pay for RPC access on its own, point it at this URL. An agent reading this file has enough information to go from zero to making paid RPC calls without human help.
Payment Method Selection
When a client hits the charge endpoint, the server returns a 402 challenge listing all accepted payment methods. The client then pays based on what your wallet actually holds:
- If your wallet has mainnet stablecoins (pathUSD or USDC.e), it pays with those.
- If your wallet only has testnet pathUSD (on Tempo Moderato), it uses testnet funds. This is the free trial path, capped at 10,000 requests per wallet.
Rate Limits and Errors
| Endpoint | Limit |
|---|---|
/:network (charge) | 1,000 requests per 10 seconds per IP:network pair |
/session/:network (session) | 1,000 requests per 10 seconds per IP:session:network pair |
Common error responses:
| Status | Error code | What it means |
|---|---|---|
| 402 | (MPP challenge) | Payment required -- WWW-Authenticate header contains the challenge |
| 403 | lifetime_limit_reached | Testnet cap hit (10k requests). Switch to a mainnet wallet |
| 404 | unsupported_network | Network slug not recognized |
| 429 | rate_limit_exceeded | Too many requests. Back off and retry |
| 503 | mpp_not_configured | MPP not configured for this environment |
Making Paid RPC Calls With Cast
With the Tempo wallet set up (tempo wallet login) and Foundry's Tempo fork installed (foundryup -n tempo), you can query blockchain data through MPP endpoints. cast reads your wallet from the Tempo CLI and handles the 402 challenge-response flow automatically.
Charge (One-Time Payment)
The charge endpoint processes a one-time payment per request:
cast rpc -r https://mpp.quicknode.com/tempo-mainnet eth_blockNumber
cast receives the 402 challenge, signs a stablecoin transfer on Tempo, and retries with the payment credential. The response comes back like any normal RPC call:
0x...
You can use any standard JSON-RPC methods:
# Get the latest block
cast rpc -r https://mpp.quicknode.com/tempo-mainnet eth_getBlockByNumber "latest" false
# Get an account balance
cast rpc -r https://mpp.quicknode.com/tempo-mainnet eth_getBalance "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045" "latest"
# Get the current gas price
cast rpc -r https://mpp.quicknode.com/tempo-mainnet eth_gasPrice
Session (Pay-As-You-Go)
For repeated requests, use the session endpoint. On the first request, your wallet deposits 0.1 USDC.e into an onchain escrow contract to open a payment channel. Subsequent requests are paid using offchain signed vouchers with near-zero latency, no onchain transaction per request.
cast rpc -r https://mpp.quicknode.com/session/tempo-mainnet eth_blockNumber
At $0.00001 per request, a 0.1 USDC.e deposit covers up to 10,000 requests. Sessions make more sense for scripts or apps that fire many RPC calls in a row.
Verifying Payments on Tempo
Check your payment transactions on the Tempo block explorer:
- Mainnet: https://explore.tempo.xyz
- Testnet (Moderato): https://explore.testnet.tempo.xyz
Search for your wallet address to see the stablecoin transfers for each RPC request.
Use Cases
Now that you can make paid RPC calls with cast, here are some practical things you can do with Quicknode's MPP endpoints.
Read Accounts and Transaction Data
Query account balances, contract state, and transaction history on any supported network:
# Check an address balance on Tempo mainnet
cast rpc -r https://mpp.quicknode.com/tempo-mainnet eth_getBalance "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045" "latest"
# Read a contract's storage slot
cast rpc -r https://mpp.quicknode.com/tempo-mainnet eth_getStorageAt "0xCONTRACT_ADDRESS" "0x0" "latest"
# Get a transaction receipt
cast rpc -r https://mpp.quicknode.com/tempo-mainnet eth_getTransactionReceipt "0xTX_HASH"
Monitor Blocks and Gas
Useful for dashboards, alerting, or fee estimation:
# Latest block number
cast rpc -r https://mpp.quicknode.com/tempo-mainnet eth_blockNumber
# Full block with transactions
cast rpc -r https://mpp.quicknode.com/tempo-mainnet eth_getBlockByNumber "latest" true
# Current gas price
cast rpc -r https://mpp.quicknode.com/tempo-mainnet eth_gasPrice
Use in Foundry Scripts and Tests
Since cast handles MPP automatically, you can use Quicknode MPP endpoints anywhere you'd pass an --rpc-url in your Foundry workflow:
# Run a forge script against a live network via MPP
forge script script/Deploy.s.sol \
--rpc-url https://mpp.quicknode.com/tempo-mainnet \
--broadcast
# Run tests against a fork via MPP
forge test --fork-url https://mpp.quicknode.com/tempo-mainnet
Note: The
--broadcastflag submits a live transaction to the network. If you're just testing your script, omit--broadcastto simulate the deployment without spending gas or deploying anything onchain.
Frequently Asked Questions
What is MPP?
The Machine Payments Protocol is an open standard (proposed to the IETF) that adds inline payments to HTTP endpoints. Clients pay as part of their request using the 402 Payment Required status code and standard HTTP headers. It works with multiple payment methods including Tempo stablecoins, Solana USDC, and Stripe.
Do I need an account with the RPC provider?
No. MPP replaces account-based access. You only need a wallet with stablecoins. There's no signup, no API keys, and no billing dashboard.
What is the difference between charge and session?
Charge processes a one-time onchain payment per request (~500ms overhead). Session opens a payment channel with an initial deposit, then uses offchain vouchers for near-zero latency on subsequent requests. Use charge for occasional calls; use session for anything that makes repeated requests.
How much does Quicknode MPP cost?
Charge requests cost $0.001 each. Session requests cost $0.00001 each ($10 per million requests). Sessions are 100x cheaper because they amortize onchain settlement across many requests.
Can I try MPP for free?
Yes. Quicknode's MPP endpoints accept testnet pathUSD on Tempo Moderato, giving you 10,000 free requests per intent (charge and session counted separately). No real money needed.
What stablecoins does MPP support?
It depends on the service provider. Quicknode accepts pathUSD and USDC.e (bridged USDC) on Tempo. The server lists its accepted currencies in the 402 challenge.
How do AI agents discover MPP endpoints?
Service providers can publish a machine-readable llms.txt file describing their MPP service. Quicknode's is at https://mpp.quicknode.com/llms.txt and contains endpoint patterns, pricing, client setup code, and bootstrapping instructions for both Tempo and Solana.
What happens if the testnet request cap is exhausted?
The server returns HTTP 403 with { "error": "lifetime_limit_reached" } and no payment is taken. Switch to a mainnet-funded wallet for unlimited access.
Wrap Up
If you've made it this far, you now know what the Machine Payments Protocol is, how to set up a Tempo wallet, and how to use the Foundry Tempo fork to make paid RPC calls with cast. You can query blockchain data from Quicknode's MPP endpoints using charge for one-off requests or sessions when you need high-frequency access at a fraction of the cost.
To learn more about MPP, Tempo, and Quicknode, check out the following resources:
- Machine Payments Protocol docs
- Quicknode MPP docs
- IETF specification
- Tempo docs
- Tempo CLI reference
- Tempo Foundry SDK
- Quicknode MPP llms.txt
We ❤️ Feedback!
Let us know if you have any feedback or requests for new topics. We'd love to hear from you.