Fund with x402
x402 is a wallet-signed route for adding USDC to an authenticated AmpleRun account. It is an alternative funding workflow, not a substitute for an API key, a free-credit offer, or a payment authorization by itself.
Request requirements without paying
Section titled “Request requirements without paying”Without a payment signer, the TypeScript SDK returns payment requirements for inspection. This example does not sign or send funds:
import { createAmpleRun } from '@amplerun/sdk';
const api = createAmpleRun({ baseUrl: 'https://amplerun-api.spiry.org', apiKey: process.env.AMPLERUN_API_KEY,});const result = await api.billing.topUp('5000000');if (result.status !== 'payment_required') { throw new Error(`Inspect unexpected top-up status: ${result.status}`);}console.log(result.payment_required.accepts);The corresponding REST operation is POST /api/v1/billing/x402/top-up?amount_micro=5000000. An unpaid request normally returns HTTP 402 and the currently offered requirements. If the feature is disabled, the route can return 404; if no supported payment route is configured, it can return an availability error.
Authorize only a specific payment
Section titled “Authorize only a specific payment”Before signing, inspect the selected network, asset contract, amount, payTo, validity window, and signing domain. Choose one currently offered entry. The flow uses x402 v2 and an EIP-3009 transfer authorization; a wallet signs locally and the client repeats the request with PAYMENT-SIGNATURE.
The TypeScript SDK’s optional x402 signer can make these payments automatically. Configuring it is a spending decision: use a dedicated wallet and a per-payment limit within the operator’s approved total budget. A wallet signature authorizing a transfer is not the same as the sign-in message used to register an agent account.
Hosted MCP does not hold a payment wallet and returns instructions. Local MCP can pay when a payment-wallet file is configured and AMPLERUN_MCP_ALLOW_SPEND=1; leave both disabled for a quote-only workflow.
Confirm the account credit
Section titled “Confirm the account credit”A settlement response or transaction hash is not a usable-balance check. Inspect the returned state, then poll billing until spendable_micro covers the rental budget. Keep the original payment authorization and result for retry recovery; do not sign a new payment solely because a response was delayed.
For the simpler wallet-or-exchange route, use deposit addresses.
Official AmpleRun documentation · Contract v3 · Last reviewed · Revision 52fe29de · Open AmpleRun · View Markdown · For agents