{"uid":"cap_WWJj5iYxWhnXl-_4Ouiz_","slug":"x402-chain-tools-erc-20-wallet-preflight-check-29917afa","name":"x402 Chain Tools – ERC-20 Wallet Preflight Check","description":"Check read-only ERC-20 wallet readiness for a planned token spend.","url":"https://blockchain-api.x402-chain-tools.workers.dev/chain/wallet-preflight","method":"POST","headers":{},"bodySchema":{"type":"object","properties":{"token":{"type":"string","pattern":"^0x[0-9a-fA-F]{40}$","description":"ERC-20 token contract address on Base."},"amount":{"type":"string","pattern":"^[0-9]+(?:\\.[0-9]+)?$","description":"Positive decimal string without scientific notation. Exact fractional precision depends on the token decimals() response."},"wallet":{"type":"string","pattern":"^0x[0-9a-fA-F]{40}$","description":"Base wallet address."},"spender":{"type":"string","pattern":"^0x[0-9a-fA-F]{40}$","description":"Planned spender address."}}},"responseSchema":{"type":"json","example":{"ok":true,"ready":false,"token":"0x0000000000000000000000000000000000000002","issues":["NO_NATIVE_GAS_BALANCE","INSUFFICIENT_TOKEN_BALANCE"],"wallet":"0x0000000000000000000000000000000000000001","network":"eip155:8453","spender":"0x0000000000000000000000000000000000000003","allowance":{"raw":"0","formatted":"0","unlimited":false,"sufficient":false},"limitations":["native gas check only verifies a non-zero ETH balance","transaction execution is not simulated"],"token_balance":{"raw":"0","formatted":"0","sufficient":false},"native_balance":{"eth":"0","wei":"0","has_native_gas_balance":false},"requested_amount":{"raw":"10500000","decimals":6,"formatted":"10.5"},"spender_is_contract":true}},"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.002","displayCostAsset":"USDC","priceDynamic":false,"priceHint":null,"priceStatus":"priced","priceSource":"probe","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.002/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.002","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.002","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_8h2jwTjoWY-JELcqfyFE6","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.002","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Checks whether a Base wallet is ready to spend a specified ERC-20 token amount by validating token balance, ETH gas balance, and spender allowance in a single read-only call.","exampleAgentPrompt":"Before submitting the payment, check if my wallet 0xABCDEF1234567890ABCDEF1234567890ABCDEF12 is ready to spend 10.5 USDC (token 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48) with spender 0x1111111111111111111111111111111111111111 on Base — does it have enough balance, gas, and allowance?","exampleUseCases":[{"title":"Pre-payment readiness for DeFi agent","prompt":"Before my agent tries to swap tokens, check if wallet 0xDEADBEEF00000000000000000000000000000001 can spend 50 USDC (token 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913) with spender contract 0xDEF1C0ded9bec7F1a1670819833240f027b25EfF — does it have enough balance, gas, and an approved allowance?"},{"title":"Troubleshoot failed ERC-20 transaction","prompt":"My transaction keeps failing — can you run a preflight on wallet 0xC0FFEE0000000000000000000000000000000001 trying to spend 100 DAI (token 0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb) via spender 0xBA12222222228d8Ba445958a75a0704d566BF2C8 and tell me what's wrong?"},{"title":"Automated allowance and balance gate before batch payout","prompt":"Before I kick off the batch payout, verify that wallet 0xBEEF000000000000000000000000000000000001 has the balance, gas, and allowance needed to send 250 USDT (token 0xfde4C96c8593536E31F229EA8f37b2ADa2699bb2) through spender 0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD."}],"resultDescription":"Returns a JSON object with an overall 'ready' boolean, a list of 'issues' (e.g. NO_NATIVE_GAS_BALANCE, INSUFFICIENT_TOKEN_BALANCE, INSUFFICIENT_ALLOWANCE), detailed token balance and native ETH balance breakdowns, allowance information (raw, formatted, unlimited, sufficient), spender contract flag, requested amount details, and metadata about limitations of the check.","failureModes":["Invalid Ethereum address format for token, wallet, or spender returns validation error","Token contract does not exist or is not a valid ERC-20 returns error or incomplete data","Network congestion may cause slow RPC responses","Amount string with scientific notation rejected by pattern validation","Wallet or token on non-Base network returns incorrect or empty results","Missing required fields returns 400-level error"],"whenToPreferThis":"Use this endpoint when an agent needs to gate an ERC-20 token spend with a single composite check — balance, gas, and allowance — rather than making three separate blockchain calls. Ideal as a preflight step before DeFi swaps, payments, or automated payouts on Base Mainnet where transaction failure is costly. Prefer this over individual balance or allowance endpoints when all three conditions must be satisfied simultaneously.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-09-14T12:32:57.877Z","isFirstParty":false}