# x402 Pre-Trade Check

> x402 Pre-Trade Check is a paid API for AI agents from x402-gateway-production-1f21.up.railway.app, paid per call via x402, $0.01/call, status unknown (last checked 2026-10-10).

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.

## Facts

- Endpoint: POST https://x402-gateway-production-1f21.up.railway.app/agent/pretrade?utm_source=zero.xyz
- Price: $0.01/call
- Payment: x402
- Status: unknown
- Last checked: 2026-10-10
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/x402-pre-trade-check-299f3f08
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap__92LjMHTHcf2Pszekre0y

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-pre-trade-check-299f3f08 -d '<json body>'
```

Example prompt: Before executing the swap, check if my wallet 0xAbC1234567890abcdef1234567890abcdef123456 has approved spender 0xDEF987654321fedcba9876543210fedcba987654 to spend token 0x833589fcd6edb6e08f4c7c32d4f71b54bda02913 on Base, product ID ETH-USD.

## When to prefer this

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.

## Known failure modes

- 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

## How this service works

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.

## Output

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.

## Request schema (JSON Schema)

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

## Response schema (JSON Schema)

```json
{
 "type": "json",
 "example": {
  "status": "ready"
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/x402-pre-trade-check-299f3f08/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from x402-gateway-production-1f21.up.railway.app](https://www.zero.xyz/host/x402-gateway-production-1f21.up.railway.app/llms.txt)
