Pay per request with x402

x402 lets an agent buy RPC requests with a single HTTP payment, with no account, dashboard or card. The agent sends a request, gets 402 Payment Required, signs a USDC transfer authorization and sends the request again. BlockReq settles the payment on Base, answers the request, and returns an RPC Endpoint Key in a response header. From then on the agent uses that key like any other RPC endpoint key until the paid requests run out.

BlockReq implements x402 v2 (x402Version: 2), scheme exact on EVM with an EIP-3009 transferWithAuthorization signature. Permit2 payloads are refused. BlockReq settles the payment itself; there is no external facilitator.

Endpoint

https://x402.blockreq.com/<network>

<network> is the network slug, for example eth-mainnet. Send a JSON-RPC POST. This host is separate from the public endpoints, whose anonymous rate limits do not change.

Price

ItemValue
Payment networkBase mainnet, eip155:8453
TokenUSDC (0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913)
One payment1 USDC, exactly one block
One block526,315 RPC requests
Validity60 days from the payment

The amount, the payTo address and the token come from the PAYMENT-REQUIRED header of every 402, so a client should read them there instead of hard-coding them. extra.blockreqBlockRequests states the number of requests one block buys.

How to pay

  1. Send the JSON-RPC request without payment. The answer is 402 with a base64 PAYMENT-REQUIRED header (PaymentRequired, spec section 5.1.2).
  2. Sign an EIP-3009 authorization for the offered amount to payTo, with validBefore no later than maxTimeoutSeconds from now. Standard clients do this for you.
  3. Send the same request again with the base64 PaymentPayload in the PAYMENT-SIGNATURE header.
  4. On success the answer is the normal JSON-RPC response (200) with these headers:
HeaderContent
PAYMENT-RESPONSEbase64 SettlementResponse with the transaction hash, network and payer
BlockReq-Endpoint-Keythe RPC Endpoint Key, only for a first payment without a key of its own

The paid request is answered even when the node returns a JSON-RPC error: the payment has settled either way, so read the key from the header on every paid answer.

# 1. Unpaid: 402 and the requirements curl -si https://x402.blockreq.com/eth-mainnet \ -H 'content-type: application/json' \ -d '{"jsonrpc":"2.0","id":1,"method":"eth_blockNumber","params":[]}'

The official clients handle steps 1 to 3. This example uses @x402/fetch and @x402/evm:

import { wrapFetchWithPayment, x402Client } from "@x402/fetch"; import { registerExactEvmScheme } from "@x402/evm/exact/client"; import { privateKeyToAccount } from "viem/accounts"; const client = new x402Client(); registerExactEvmScheme(client, { signer: privateKeyToAccount(process.env.PAYER_PRIVATE_KEY as `0x${string}`) }); const fetchWithPayment = wrapFetchWithPayment(fetch, client); const response = await fetchWithPayment("https://x402.blockreq.com/eth-mainnet", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ jsonrpc: "2.0", id: 1, method: "eth_blockNumber", params: [] }), }); const endpointKey = response.headers.get("BlockReq-Endpoint-Key"); // keep it

Use the key

Save the BlockReq-Endpoint-Key value. It is the same kind of key as the one in a dashboard endpoint, so the agent can call the chain hosts with it and does not pay again until the block is used up. A later payment that presents the key tops up the same account instead of creating a new one.

Replays

An authorization can be spent once, so a payment is never charged twice. Sending the same PAYMENT-SIGNATURE again does not serve a second request. BlockReq answers:

HTTP/1.1 200 OK PAYMENT-RESPONSE: <base64 settlement> BlockReq-Endpoint-Key: <the key of this payment> Cache-Control: no-store {"status":"payment_already_settled","action":"use_endpoint_key"}

There is no JSON-RPC result in this body. It is a 200 on purpose: a 402 would make a standard x402 client sign and pay again. If an answer was lost on the way, resend the same signature to get the key back, then use the key.

When the outcome is unclear

If an answer carries "action": "resend_same_signature" (a 402 settlement_pending, or a 503 after a payment attempt), send the same PAYMENT-SIGNATURE again, after Retry-After when given. Do not sign a new authorization: the first one may still execute, and a second signature is a second, separate 1 USDC payment. If the authorization never executes, the replay answers 402 payment_expired and no money moved.

Failures

The body of a failure is {"error": "<code>", "action": "<sign_new | resend_same_signature | retry_later>"}.

StatuserroractionMeaning
402payment_invalidsign_newWrong shape, signature, amount, payTo or network, or the payer cannot be accepted
402payment_expiredsign_newvalidBefore passed or is less than 20 seconds away
402authorization_window_invalidsign_newvalidAfter is in the future or validBefore is too far ahead
402insufficient_fundssign_newThe payer holds less USDC than the amount
402payment_reversedsign_newThe authorization was cancelled, the transfer reverted, or the credit was reversed
402settlement_pendingresend_same_signatureThe transaction is not confirmed yet; PAYMENT-RESPONSE carries its hash
429anonymous_rate_limited, payer_limitedretry_laterToo many new accounts per hour, or a payer with 3 unconfirmed blocks or repeated reverts
502unexpected_settle_errorretry_laterA failure before anything was signed; nothing was charged
503settlement_pending, unexpected_settle_errorresend_same_signatureSettlement is still being confirmed
503noneretry_laterSettlement is paused; see Retry-After

A 402 that carries a PAYMENT-REQUIRED header is safe to answer with a new signature; the ones without it are not, because a payment may already be in flight.

Credit and confirmation

A payment credits one block as soon as the transfer is on chain (provisional) and confirms after 30 confirmations. The Dashboard shows the block as a normal request balance. A credit that the chain later reverses is reversed here too.