{"uid":"cap__92LjMHTHcf2Pszekre0y","slug":"x402-pre-trade-check-299f3f08","name":"x402 Pre-Trade Check","description":"Pre-trade context bundle for autonomous crypto agents: wallet balances, ERC-20 allowance to a spender, current gas/base fee, realtime price, 24h statistics and best bid/ask spread. Use immediately before swaps, recurring payments or automated execution. This endpoint provides data only and never submits a trade.","url":"https://x402-gateway-production-1f21.up.railway.app/agent/pretrade?utm_source=zero.xyz","method":"POST","headers":{},"bodySchema":{"type":"object","$schema":"https://json-schema.org/draft/2020-12/schema","required":["input"],"properties":{"input":{"type":"object","required":["type","method","bodyType","body"],"properties":{"body":{"type":"object","required":["address","spender","token_contract","product_id"],"properties":{"address":{"type":"string","pattern":"^0x[a-fA-F0-9]{40}$"},"network":{"enum":["base","ethereum"],"type":"string","default":"base"},"spender":{"type":"string","pattern":"^0x[a-fA-F0-9]{40}$"},"product_id":{"type":"string","pattern":"^[A-Za-z0-9]{2,15}-[A-Za-z0-9]{2,15}$"},"balance_tokens":{"type":"array","items":{"type":"string","pattern":"^0x[a-fA-F0-9]{40}$"},"maxItems":20},"token_contract":{"type":"string","pattern":"^0x[a-fA-F0-9]{40}$"}},"additionalProperties":false},"type":{"type":"string","const":"http"},"method":{"enum":["POST"],"type":"string"},"bodyType":{"enum":["json","form-data","text"],"type":"string"}},"additionalProperties":false},"output":{"type":"object","required":["type"],"properties":{"type":{"type":"string"},"example":{"type":"object"}}}}},"responseSchema":{"type":"json","example":{"status":"ready"}},"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.01","displayCostAsset":"USDC","priceDynamic":false,"priceHint":null,"priceStatus":"priced","priceSource":"registry","requiresHandshake":false,"reviewCount":0,"rating":{"score":"0.00","successRate":"0.00","reviews":0,"stars":null,"state":"unrated"},"availabilityStatus":"unknown","priceObserved":null,"sessionDeposit":null,"pricing":{"kind":"static","summary":"$0.01/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.01","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.01","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_wvmfS41Da5EnwdC_K0WXn","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.01","costPer":"request","priority":0,"asset":null,"unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Performs a pre-trade readiness check by verifying token allowances, balances, and approval status for a given wallet address and spender before executing an on-chain trade or payment.","exampleAgentPrompt":"Before executing the swap, check if my wallet 0xAbC1234567890abcdef1234567890abcdef123456 has approved spender 0xDEF987654321fedcba9876543210fedcba987654 to spend token 0x833589fcd6edb6e08f4c7c32d4f71b54bda02913 on Base, product ID ETH-USD.","exampleUseCases":[{"title":"Pre-swap allowance check on Base","prompt":"Before I do the swap, can you verify that my wallet 0xAbC1234567890abcdef1234567890abcdef123456 has enough allowance set for spender 0xDEF987654321fedcba9876543210fedcba987654 on token contract 0x833589fcd6edb6e08f4c7c32d4f71b54bda02913 on Base for product USDC-ETH?"},{"title":"DeFi bot pre-trade readiness check","prompt":"My trading bot needs to verify that wallet 0x1111222233334444555566667777888899990000 is approved to let spender 0xAAAABBBBCCCCDDDDEEEEFFFF0000111122223333 move token 0x4200000000000000000000000000000000000006 on Base before it executes the BTC-USD trade — can you run that pre-trade check?"},{"title":"Ethereum allowance verification before payment","prompt":"Check if wallet 0x9999888877776666555544443333222211110000 has given approval to spender 0xCCCCDDDDEEEEFFFF0000111122223333AAAABBBB for token contract 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48 on Ethereum for product ID PAY-USD, and also check balances for tokens 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48 and 0xdAC17F958D2ee523a2206206994597C13D831ec7."}],"resultDescription":"Returns a JSON object with a status field (e.g. 'ready') indicating whether the wallet is pre-cleared for the trade, including allowance and balance validation results for the specified token contract, spender, and product on the target network.","failureModes":["Invalid Ethereum address format returns validation error","Unknown or unsupported product_id pattern causes rejection","Network not specified defaults to Base but may cause mismatch if Ethereum intended","Token contract not deployed on specified network returns error","Allowance insufficient returns non-ready status","Rate limiting or payment failure (x402 payment not accepted) blocks the call"],"whenToPreferThis":"Use this endpoint when an AI agent or automated trading system needs to confirm on-chain readiness (token approvals, allowances, balances) before executing a DeFi trade or on-chain payment on Base or Ethereum. Prefer this over general blockchain RPC calls when you need a single structured pre-trade check that combines allowance and balance verification in one machine-payable call.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-10-10T12:34:02.299Z","isFirstParty":false,"canonicalSlug":"x402-pre-trade-check-299f3f08"}