How to buy with x402
Quick checkout for small orders
Send the trades directly with the payment request. There is no separate upload to prepare. Use this shortcut for 1–128 fills when every asset uses a plain BTC, ETH or SOL symbol. Choose FIFO or one of the three comparisons for the same 0.05 USDC per CSV.
Open quick checkout or POST your trades and selected method to the agent checkout endpoint.
Upload trades for any method
All four methods accept 1–200,000 supplied fills. Use this route for other assets, mixed books, explicit asset IDs, or more than 128 fills. Preparing the upload is free. The price is the same as quick checkout when both routes support your order.
Start with the multi-asset example. Supply one inventory, one opening balance per asset and your executed USD spot buys and sells. The upload accepts up to 256 fungible assets and 32 MiB of JSON. The CSV can be up to 16 MiB.
Download the Python client and run this command with your trade file. Your agent can resume the same unpaid order for 24 hours.
python3 bulk_upload.py prepare trades.json --method FIFO --state my-order
Authorize payment and collect the CSV
Read the exact USDC price in the offer. Use your payer address and that amount to create a signing request. The amount below is for 200,000 fills.
python3 bulk_upload.py authorize --state my-order \
--payer YOUR_BASE_ADDRESS --amount-usdc 45.00
Sign my-order/typed-data.json with your Base wallet using eth_signTypedData_v4. Save the returned hex signature in signature.txt and submit it within 60 seconds.
python3 bulk_upload.py pay --state my-order \
--signature-file signature.txt
python3 bulk_upload.py collect --state my-order \
--output workpaper.csv
Keep the order directory private. If settlement is pending, rerun collect. The client verifies every CSV part against the paid receipt. Download within one hour of confirmation.
Choose a checkout programmatically
Send your fill count, method and asset category to the pricing API. Use btc-eth-sol when every fill uses a plain BTC, ETH or SOL symbol. Use declared-assets if any other asset or explicit venue, network, contract or mint identity is present. Use OPTIMIZED_HIFO for Optimized HIFO.
For example, 20 DOGE fills with FIFO go to upload for 0.05 USDC. The same fills with HIFO also use upload at 0.05 USDC. Follow firstRequest only when checkoutAvailable is true. A different method requires a new selection.