Skip to main content
The smallest Xenarch agent. No framework. One call fetches the URL, pays the 402 if there is one, and returns the content.

Setup

The wallet needs USDC on Base. It does not need ETH.

Code

main.py

Run

Replace the URL with a page gated by Xenarch.

Output

What happens

  1. Request. The payer requests the URL. A Xenarch-gated page answers HTTP 402 with an x402 version 1 body that includes gate_id, accepts and facilitators.
  2. Checks. The price is compared with XenarchBudgetPolicy. With XENARCH_API_TOKEN set, the payer also calls POST /v1/agent/preflight on the Xenarch API to check your caps, scope rules and pause switch.
  3. Sign and settle. The payer signs an EIP-3009 USDC transferWithAuthorization from your wallet to the seller’s wallet and sends it to a facilitator from the gate’s list. The facilitator submits it on Base and pays the gas.
  4. Retry. The payer requests the URL again with X-Xenarch-Gate-Id and X-Xenarch-Tx-Hash. The seller’s integration verifies the transfer with Xenarch and returns the content.
If XENARCH_API_TOKEN is not set, step 2 uses only the local budget.