
An agent tops up its PacketExchange balance with one signed USDC payment on Base, then spends it on voice and SMS. No card on file, no account manager, no gas to hold.
Three HTTP steps, about as long as a normal API call. An x402 client such as x402-fetch, or our MCP tool, runs all of them for you.
Your agent calls POST /topups/x402 with the amount it wants to add. With no payment attached, the API answers HTTP 402 with the exact terms: network, USDC amount in atomic units, receiving address and the EIP-712 domain to sign.
The wallet signs an EIP-3009 transferWithAuthorization for exactly those terms (the "exact" scheme), base64-encodes it into an X-PAYMENT header and retries the same request. No gas on your side: our relayer broadcasts it.
We verify the signature, settle the USDC on-chain to our address and credit your balance through the same ledger as every other top-up. The response carries an X-PAYMENT-RESPONSE receipt with the transaction hash, and the agent can start sending traffic.
Wrap fetch with an x402 helper and the 402, sign and retry steps happen on their own. The call returns once your balance is credited, with the settlement transaction hash. Agents on MCP can do the same through the MCP tool wmmn_topup_x402.
import { wrapFetchWithPayment } from "x402-fetch";
import { createWalletClient, http } from "viem";
import { privateKeyToAccount } from "viem/accounts";
import { base } from "viem/chains";
// Your agent's wallet: holds USDC on Base. No ETH needed, gas is covered for you.
const account = privateKeyToAccount(process.env.AGENT_PRIVATE_KEY);
const wallet = createWalletClient({ account, chain: base, transport: http() });
// wrapFetchWithPayment auto-handles the 402 -> sign -> retry handshake
const fetchWithPay = wrapFetchWithPayment(fetch, wallet);
const res = await fetchWithPay("https://packetexchange.io/api/v1/topups/x402", {
method: "POST",
headers: { "Authorization": "Bearer wmmn_live_sk_...", "Content-Type": "application/json" },
body: JSON.stringify({ amountUsd: 25 }),
});
console.log(await res.json()); // { status: "confirmed", txHash, newBalance, ... }Network. USDC on Base mainnet. Every 402 challenge names the network and the USDC contract, so your wallet always signs for the right chain.
For wallets and agents. x402 needs an on-chain wallet to sign, so it is a rail for software rather than a checkout page. People top up from the dashboard by card, crypto deposit or wire.
Same money, same rules. x402 credits the identical USD balance as every other method, with the same double-entry ledger, receipts and limits. Nothing about billing changes downstream.
Settlement. Our relayer broadcasts your signed authorization and covers the gas, so you never need ETH. USDC moves straight from your wallet to our receiving address; we never take custody of your private keys.