x402 autonomous top-up
Let an agent fund its own account — order, sign, submit, done.
x402 top-up is the programmatic version of the crypto wallet flow: the same order machinery, but driven by code instead of a browser dialog. This page is the human-readable overview; the full protocol reference (endpoints, challenge schema, error codes) lives in x402 protocol.
The four calls
- Create an order — authenticated with your API key (or an agent key):
curl -X POST https://linkex.ai/api/user/topup/x402/orders \
-H "Authorization: Bearer sk-YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{"amount_usd": 5}'The response contains an x402 v2 challenge: network, token contract, atomic amount, recipient (payTo), and a 10-minute expiry.
-
Sign it with any x402 v2-capable wallet:
- Binance Agentic Wallet (
baw x402-payment preview/sign) @linkexai/agent-sdk(buildX402PaymentPayloadfor EVM,buildSvmPaymentPayloadfor Solana)- Coinbase x402 tooling, or your own EIP-3009 / Permit2 / Solana signer
- Binance Agentic Wallet (
-
Submit the signed payload — note this endpoint is public; the signature itself is the authorization:
curl -X POST https://linkex.ai/api/x402/pay/ORDER_ID \
-H "Content-Type: application/json" \
-d @signed-payload.json- Confirm — the response reports
settled(credited now) orcredit_pending(credited after on-chain confirmation). Verify with:
curl https://linkex.ai/api/user/self/balance \
-H "Authorization: Bearer sk-YOUR_KEY"Why use an agent key for this
Creating orders with a plain account key works, but an agent key adds guardrails: the order is bound to the agent wallet, and per-call / daily / total spend caps are enforced at settlement time (SPEND_CAP_EXCEEDED). That means a runaway agent cannot drain the funding wallet beyond the caps you set. See Agent credentials.
Keeping an agent funded
- Semi-automatic (browser): the console's Keep Funded page polls the balance and prompts you to sign a top-up when it drops below a threshold.
- Fully autonomous: run the funding loop in your own runtime with
@linkexai/agent-sdk, or thelinkex/funderDocker image — pollGET /api/user/self/balance, create an order when low, sign, submit.