# x402 Chain Tools – ERC-20 Wallet Preflight Check

> x402 Chain Tools – ERC-20 Wallet Preflight Check is a paid API for AI agents from blockchain-api.x402-chain-tools.workers.dev, paid per call via x402, $0.002/call, status unknown (last checked 2026-09-14).

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.

## Facts

- Endpoint: POST https://blockchain-api.x402-chain-tools.workers.dev/chain/wallet-preflight
- Price: $0.002/call
- Payment: x402
- Status: unknown
- Last checked: 2026-09-14
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/x402-chain-tools-erc-20-wallet-preflight-check-29917afa
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_WWJj5iYxWhnXl-_4Ouiz_

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability x402-chain-tools-erc-20-wallet-preflight-check-29917afa -d '<json body>'
```

Example prompt: 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?

## When to prefer this

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.

## Known failure modes

- 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

## How this service works

Check read-only ERC-20 wallet readiness for a planned token spend.

## Output

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.

## Request schema (JSON Schema)

```json
{
 "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."
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "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
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/x402-chain-tools-erc-20-wallet-preflight-check-29917afa/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from blockchain-api.x402-chain-tools.workers.dev](https://www.zero.xyz/host/blockchain-api.x402-chain-tools.workers.dev/llms.txt)
