Skip to main content
In a nutshell
AI agents can pay for APIs and data per request, in stablecoins, through open agent payment protocols. With Blockradar, an agent pays from a wallet whose private key never leaves Blockradar, using the Typed Data Signing endpoint you already have.

Supported Protocols

Selling to agents instead? See Accept Agent Payments.

Prerequisites

1

API Key

Get your API key from the Blockradar Dashboard. Navigate to Developers to generate one.
2

EVM Master Wallet

Create a master wallet in the dashboard on the chain the API charges on, such as Base (see Create a Master Wallet). Agent payments through Blockradar are EVM only.
3

USDC Enabled

Enable USDC on the wallet so balances and deposits are tracked. See Asset Management.

Give the Agent Its Own Budget

Signing has no per-payment spending limit
Anyone holding an API key with access to a wallet can sign a payment of any amount from that wallet or its addresses. Blockradar does not cap what an agent signs. Limit the damage a misbehaving agent or a leaked key can do by giving the agent a dedicated address that holds only what it is allowed to spend.
A child address with auto-sweep turned off works well as an agent budget. Top it up with the amount the agent may spend, and the agent can never pay more than that balance.
Keep disableAutoSweep: true on an agent’s address. With auto-sweep on, the USDC you send to fund the agent is swept to the master wallet, and the agent’s payments fail for lack of funds.
Paying from the master wallet also works. Use the master wallet endpoints in the examples below and leave out addressId. The master wallet’s whole balance is then within the agent’s reach, so do this only with a master wallet dedicated to the agent. On the Checkout plan, child address operations are not available, so use a master wallet dedicated to the agent.

How x402 Works

x402 is an open protocol that lets an API charge per request: it answers with HTTP 402 Payment Required, and the caller retries with a signed USDC payment. x402 has three parties: the buyer (your agent), the seller (the API being paid), and a facilitator that checks the payment and submits it on-chain.
1

The API asks for payment

The agent calls a paid endpoint. The API responds with 402 Payment Required and a PAYMENT-REQUIRED header listing what it accepts: network, token, amount, and the payTo address.
2

Blockradar signs the payment

The agent turns one of those options into an EIP-3009 TransferWithAuthorization and signs it with Blockradar’s typed data endpoint. Nothing is sent on-chain yet.
3

The agent retries with the signature

The agent repeats the request with the signed payment in the PAYMENT-SIGNATURE header.
4

The facilitator settles

The seller’s facilitator verifies the signature and submits the transfer on-chain, paying the gas itself. The API returns the response, with the settlement result in a PAYMENT-RESPONSE header.
The agent’s wallet needs USDC but no gas. The signature authorizes one transfer of an exact amount to an exact address, and the facilitator cannot change either.

Pay with x402

Fund the agent’s address first, as described in Give the Agent Its Own Budget.

Option 1: Use the x402 client SDK

The official @x402/fetch client handles the 402 exchange for you. It only needs a signer with an address and a signTypedData method. The adapter below implements that signer on Blockradar’s typed data endpoint, so the key stays in Blockradar.
JavaScript
Register one scheme per network the agent pays on (eip155:84532 for Base Sepolia while testing), with a wallet on that chain behind each.

Option 2: Build the payment yourself

Without the SDK, or in another language, a payment takes three HTTP calls: the first request, the signing call to Blockradar, and the paid retry. The steps below pay 0.01 USDC on Base.

Step 1: Read the payment requirements

Call the API. A 402 response carries a base64-encoded PAYMENT-REQUIRED header. Decoded, it looks like this:
Choose an entry in accepts that your wallet can pay:
  • scheme is exact.
  • network is the wallet’s chain. eip155:8453 is Base mainnet.
  • extra.assetTransferMethod is absent or eip3009. The permit2 method needs an on-chain token approval first, which costs gas, so this guide does not cover it.
amount is in the token’s smallest unit. USDC has 6 decimals, so 10000 is 0.01 USDC.

Step 2: Sign the authorization

Build the TransferWithAuthorization from the requirements and sign it from the agent’s address:
To sign from the master wallet instead, use POST /v1/wallets/{walletId}/signing/typed-data and set from to the master wallet’s address. The response is the standard typed data response; the signature is in data.signedTransaction.signature.

Step 3: Retry with the payment

Wrap the signature and authorization in a payment payload, base64-encode it, and send it in the PAYMENT-SIGNATURE header on the same request:
JavaScript

Step 4: Check the settlement

A successful response includes a base64-encoded PAYMENT-RESPONSE header:
transaction is the on-chain hash of the USDC transfer. If the payment fails, the API answers 402 again, and PAYMENT-RESPONSE carries an errorReason such as insufficient_funds.
Servers on x402 version 1 differ from the flow above in four ways:
  • The payment requirements are in the 402 response body, not a header.
  • Networks are named (base, base-sepolia) rather than eip155:<chainId>. Base is chain ID 8453; Base Sepolia is 84532.
  • The amount field is maxAmountRequired, not amount.
  • The payment goes in the X-PAYMENT header as base64-encoded JSON with x402Version: 1, scheme, network, and the same payload object, and the settlement comes back in X-PAYMENT-RESPONSE.
The signing step with Blockradar is identical.

Signing rules that trip up integrations

Every signature is recorded as a SIGNED transaction and triggers a signed.success webhook, which gives you an audit trail of every payment your agent authorized. A signature is not a payment: the USDC only moves when the seller’s facilitator settles it. When the seller is outside Blockradar, the settlement appears as an outgoing transfer from the agent’s address. To reconcile, match signed.success webhooks against the on-chain transaction in the PAYMENT-RESPONSE header.

x402 Limitations

  • EVM only. Payments are signed with EIP-712 typed data, which Blockradar supports on EVM chains only. Solana and other non-EVM x402 networks are not supported.
  • EIP-3009 exact payments only. Tokens with transferWithAuthorization, such as USDC, work. The permit2 transfer method and other schemes are not covered.
  • No Circle Gateway nanopayments. Circle’s batched sub-cent payment option has not been tested with Blockradar wallets.

Best Practices

  • Enforce limits in your agent. Blockradar signs any well-formed request from a valid API key. Put per-payment and per-day limits in your agent’s code, and cap total exposure with the balance of the agent’s address.
  • One address per agent. Separate budgets make it obvious which agent spent what, and let you cut one off by draining its address.
  • Check the price before signing. Compare amount against the most your agent should pay for that resource, and refuse anything higher.
  • Check the recipient. If your agent only pays known APIs, keep an allowlist of payTo addresses.
  • Use metadata and webhooks. Tag agent addresses with metadata, and reconcile signed.success webhooks against the on-chain transaction in each PAYMENT-RESPONSE.
  • Lock down API access. Accept API requests only from your own servers with IP Whitelisting, so a leaked key cannot be used elsewhere.
  • Test on Base Sepolia first. Use a testnet wallet, eip155:84532, and testnet USDC from the faucets before spending real funds.

API Reference