In your browser
Open the Paychannels demo and select Get test money. The page creates a wallet in your browser, funds it from the demo faucet, and deposits it with the hub. That deposit is the only onchain step. Start with Try one payment: one click buys a response from a live x402 endpoint, and the page breaks the round trip into stages so you can see how much of it happens inside the hub. Then pick a use case:
Every use case has a Try with your agent button that copies a prompt for that flow. The demo’s explorer shows live traffic, a running check that every deposit is backed, settlement batches, and your own signed payment history. The benchmarks page explains the 45 million payments per second fleet run.
With your agent
The demo publishes a step-by-step payment guide for agents at PAYING.md. Paste this prompt into a coding agent with shell access:Buy one API response
From your terminal
In this tutorial you will pay for an API endpoint through the demo hub. You will start with a single direct payment, then open a channel and make three payments that need no onchain transaction at all. By the end you will have:- A payer wallet funded with test USDC.
- A paid response from a
402-gated endpoint. - An open channel and three channel payments, each confirmed by a hub receipt.
Before you start
You need a terminal withcurl, jq, openssl, and python3 (3.8 or newer), plus cast from Foundry for the channel steps.
Run every block below in the same shell session. Later steps read variables that earlier steps set.
Point your shell at the demo hub
Set the demo URLs, then read the hub’s configuration from the facilitator’s/meta endpoint:
/meta or your own wallet, so nothing is hardcoded.
The demo sits behind a CDN that rejects requests without a
User-Agent. Every curl call here sends -A x402-agent for that reason.Create a wallet
Download the demo’s signing helper. It is a single dependency-free Python file that generates keys and signs x402 payments locally:.wallets/payer.key and never leaves your machine.
Get test funds
Ask the dispenser for gas and test USDC:"usdc":"1000000000", which is 1,000 test USDC (USDC has 6 decimals), along with the two funding transactions.
Make a one-off payment
Before opening a channel, buy one response with a direct x402 payment. The helper fetches the endpoint’s402, signs a transfer authorization, and retries with the payment attached:
"status": 200, a receipt with "success": true and a transaction hash, and the endpoint’s response body. This payment was one onchain transfer. That works for occasional purchases, but each one waits for a block. A channel removes that wait.
Open a channel
A channel needs a second key. The session key signs every payment, while your payer key stays in control of the funds:status 1 (success). These are the only onchain transactions you will send from here on. Wait about ten seconds for the hub to confirm the deposit before you pay.
Read the endpoint’s price
Request the paid endpoint without a payment and pick out the channel offer:402 lists two offers: exact (the direct payment you used earlier) and batch-settlement (the channel). The price is in USDC base units, so 100 is $0.0001.
Pay through the channel
Each channel payment is a voucher that states the new running total you have paid this merchant. Paste this function once:HTTP 200 lines, each followed by a receipt:
cumulative climbs by the price each time while delta stays at 100, and that the full x402 response has "transaction": null. The hub verified each voucher and returned a receipt without touching the chain. Your payments will be included in the hub’s next settlement.
What you built
You funded a wallet, paid once onchain, and then opened a channel and paid three more times with nothing but a signature. Runpay as many times as you like: every call costs the payer no gas.
Your running total lives in .wallets/cum.txt. Keep that file. If you lose it, the next payment is declined with unauthorized-cumulative, and you need to read your current total back from the hub before paying again.
Next steps
- How Paychannels work: what happened at each step.
- Accept Paychannels payments: charge for your own endpoint.
- Trust model: what your deposit and signatures commit you to.
- The demo also publishes a full agent recipe at PAYING.md, including concurrent payments, resyncing your running total, and verifying payments in the explorer.