# Fund with x402

Inspect payment requirements before enabling wallet-signed top-ups.

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

Without a payment signer, the TypeScript SDK returns payment requirements for inspection. This example does not sign or send funds:

```js
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

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

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](https://docs.amplerun.com/billing/deposits.md).

---
Last reviewed: 2026-10-19.
Canonical: https://docs.amplerun.com/billing/x402/
