{
  "openapi": "3.1.0",
  "info": {
    "title": "TxGuard",
    "version": "0.1.0",
    "summary": "Deterministic Base transaction and x402 payment preflight for agents, paid per call.",
    "description": "TxGuard tells an agent what a Base transaction actually does before it signs one. It decodes calldata against verified ABIs, resolves every known proxy pattern including the legacy slot Base USDC really uses, unwraps multicall wrappers recursively, classifies allowances against the token's own supply rather than a list of sentinel values, and runs the full x402 authorization check table against the quote a payment claims to satisfy. There is no model anywhere in it. When a four-byte selector matches more than one signature it returns unknown and hands back every candidate, because a confident decode of an ambiguous selector is how a preflight API becomes dangerous.",
    "contact": {
      "email": "support@schemasure.com"
    },
    "x-policy-version": "2026-08-03"
  },
  "servers": [
    {
      "url": "https://txguard.schemasure.com"
    }
  ],
  "paths": {
    "/v1/tx/preflight": {
      "post": {
        "operationId": "txguard_v1_tx_preflight",
        "summary": "Explain and check a Base transaction or x402 payment authorization before signing it",
        "description": "Explain and preflight an unsigned Base transaction, EIP-712 typed data, or an EIP-3009 x402 payment authorization before you sign it. Decodes intent against verified ABIs, resolves proxies, classifies approvals, and checks a payment authorization against the quote it claims to pay: recipient, amount, asset, chain, freshness, and nonce replay. Returns unknown rather than guessing when a selector is ambiguous. Not a guarantee that a transaction is safe or profitable.",
        "x-payment-info": {
          "x402Version": 2,
          "scheme": "exact",
          "network": "eip155:8453",
          "asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
          "amountAtomic": "10000",
          "priceUsd": 0.01,
          "payTo": "0x9876af0F6D8Ed5155Cd02d1ca56D128601612690",
          "policy": "charge only on a successful, usable result"
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$schema": "https://json-schema.org/draft/2020-12/schema",
                "title": "TxPreflightRequest",
                "type": "object",
                "additionalProperties": false,
                "description": "Send exactly one of unsigned_tx, tx_hash, typed_data, or authorization.",
                "oneOf": [
                  {
                    "required": [
                      "unsigned_tx"
                    ]
                  },
                  {
                    "required": [
                      "tx_hash"
                    ]
                  },
                  {
                    "required": [
                      "typed_data"
                    ]
                  },
                  {
                    "required": [
                      "authorization"
                    ]
                  }
                ],
                "properties": {
                  "unsigned_tx": {
                    "type": "object",
                    "additionalProperties": false,
                    "description": "A transaction you are about to sign. `to: null` is a deployment.",
                    "properties": {
                      "from": {
                        "type": "string",
                        "pattern": "^0x[0-9a-fA-F]{40}$"
                      },
                      "to": {
                        "type": [
                          "string",
                          "null"
                        ]
                      },
                      "value": {
                        "type": "string",
                        "description": "Wei."
                      },
                      "data": {
                        "type": "string",
                        "pattern": "^0x[0-9a-fA-F]*$"
                      }
                    }
                  },
                  "tx_hash": {
                    "type": "string",
                    "pattern": "^0x[0-9a-fA-F]{64}$",
                    "description": "An existing Base transaction to explain."
                  },
                  "typed_data": {
                    "type": "object",
                    "required": [
                      "domain",
                      "primaryType",
                      "message"
                    ],
                    "description": "EIP-712 payload. TransferWithAuthorization and ReceiveWithAuthorization get the x402 check table; any other primaryType is reported unrecognised, not analysed.",
                    "properties": {
                      "domain": {
                        "type": "object"
                      },
                      "types": {
                        "type": "object"
                      },
                      "primaryType": {
                        "type": "string"
                      },
                      "message": {
                        "type": "object"
                      }
                    }
                  },
                  "authorization": {
                    "type": "object",
                    "additionalProperties": false,
                    "required": [
                      "from",
                      "to",
                      "value",
                      "validAfter",
                      "validBefore",
                      "nonce"
                    ],
                    "description": "An EIP-3009 authorization, which is what an x402 `exact` payment is. value in base units, validAfter/validBefore in unix seconds, nonce 32 random bytes not a counter.",
                    "properties": {
                      "from": {
                        "type": "string",
                        "pattern": "^0x[0-9a-fA-F]{40}$"
                      },
                      "to": {
                        "type": "string",
                        "pattern": "^0x[0-9a-fA-F]{40}$"
                      },
                      "value": {
                        "type": "string"
                      },
                      "validAfter": {
                        "type": "string"
                      },
                      "validBefore": {
                        "type": "string"
                      },
                      "nonce": {
                        "type": "string",
                        "pattern": "^0x[0-9a-fA-F]*$"
                      },
                      "signature": {
                        "type": "string",
                        "pattern": "^0x[0-9a-fA-F]*$"
                      },
                      "kind": {
                        "type": "string",
                        "enum": [
                          "transfer",
                          "receive"
                        ]
                      },
                      "asset": {
                        "type": "string",
                        "pattern": "^0x[0-9a-fA-F]{40}$"
                      }
                    }
                  },
                  "expected_quote": {
                    "type": "object",
                    "description": "The x402 quote this payment claims to satisfy. Enables the comparison checks.",
                    "additionalProperties": false,
                    "properties": {
                      "scheme": {
                        "type": "string"
                      },
                      "network": {
                        "type": "string"
                      },
                      "amount": {
                        "type": "string"
                      },
                      "asset": {
                        "type": "string"
                      },
                      "payTo": {
                        "type": "string"
                      },
                      "maxTimeoutSeconds": {
                        "type": "number"
                      },
                      "extra": {
                        "type": "object"
                      }
                    }
                  },
                  "simulate": {
                    "type": "boolean",
                    "default": false,
                    "description": "Run eth_simulateV1 with asset tracing. Priced at $0.015 instead of $0.01, and targets P50 2s / P95 5s rather than the static path's 500ms / 2s."
                  }
                }
              },
              "example": {
                "unsigned_tx": {
                  "from": "0x9F2C5E4A8db1C3a7E6B0d4f8C1E2a5b7D9C0e3F4",
                  "to": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
                  "value": "0",
                  "data": "0xa9059cbb0000000000000000000000005d3e1a9b7c2f4e8a0b6d3c5f9e1a7b4d2c8f0a6e0000000000000000000000000000000000000000000000000000000000002710"
                },
                "expected_quote": {
                  "scheme": "exact",
                  "network": "eip155:8453",
                  "amount": "10000",
                  "asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
                  "payTo": "0x1a2B3c4D5E6F7a8B9c0D1e2F3A4b5C6d7E8F9a0b",
                  "maxTimeoutSeconds": 60,
                  "extra": {
                    "name": "USD Coin",
                    "version": "2"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful result envelope",
            "content": {
              "application/json": {
                "schema": {
                  "$schema": "https://json-schema.org/draft/2020-12/schema",
                  "title": "TxPreflightEnvelope",
                  "type": "object",
                  "required": [
                    "ok",
                    "verdict",
                    "confidence",
                    "risk_codes",
                    "evidence",
                    "result",
                    "policy_version",
                    "request_hash",
                    "data_versions",
                    "warnings"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "verdict": {
                      "type": "string",
                      "enum": [
                        "allow",
                        "warn",
                        "block",
                        "unknown"
                      ],
                      "description": "Precedence: block, then unknown, then warn, then allow."
                    },
                    "confidence": {
                      "type": "number",
                      "minimum": 0,
                      "maximum": 1
                    },
                    "risk_codes": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "evidence": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    },
                    "policy_version": {
                      "type": "string"
                    },
                    "request_hash": {
                      "type": "string",
                      "pattern": "^sha256:[0-9a-f]{64}$"
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "data_versions": {
                      "type": "object",
                      "required": [
                        "denylist",
                        "abi_packs",
                        "signature_index",
                        "policy",
                        "chain"
                      ]
                    },
                    "result": {
                      "type": "object",
                      "required": [
                        "input_shape",
                        "chain",
                        "intent",
                        "expected_transfers",
                        "approvals",
                        "permit_scope",
                        "spender",
                        "proxy",
                        "authorization_checks",
                        "quote_comparison",
                        "simulation",
                        "candidate_signatures",
                        "denylist_hits",
                        "unresolved",
                        "rpc"
                      ],
                      "properties": {
                        "intent": {
                          "type": "object",
                          "required": [
                            "kind",
                            "summary",
                            "decode_source",
                            "calls",
                            "truncated"
                          ],
                          "properties": {
                            "decode_source": {
                              "type": "string",
                              "enum": [
                                "verified-abi",
                                "bundled-abi",
                                "offline-index",
                                "live-lookup",
                                "unresolved"
                              ]
                            }
                          }
                        },
                        "approvals": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "scope": {
                                "type": "string",
                                "enum": [
                                  "infinite",
                                  "effectively_infinite",
                                  "bounded"
                                ]
                              }
                            }
                          }
                        },
                        "proxy": {
                          "type": "object",
                          "properties": {
                            "kind": {
                              "type": "string",
                              "enum": [
                                "none",
                                "eip1167",
                                "eip1967",
                                "eip1967-beacon",
                                "eip1822",
                                "zeppelinos",
                                "diamond",
                                "unknown"
                              ]
                            }
                          }
                        }
                      }
                    }
                  }
                },
                "example": {
                  "ok": true,
                  "verdict": "block",
                  "confidence": 1,
                  "risk_codes": [
                    "RECIPIENT_MISMATCH",
                    "RPC_UNAVAILABLE"
                  ],
                  "evidence": [
                    {
                      "code": "RECIPIENT_MISMATCH",
                      "severity": "critical",
                      "detail": "Pays 0x5D3e1a9b7c2f4E8A0b6d3c5F9E1A7b4D2C8f0a6E, but the quote names 0x1a2B3c4D5E6F7a8B9c0D1e2F3A4b5C6d7E8F9a0b. Signing this pays someone other than the party you are buying from.",
                      "source": "quote-comparison",
                      "data": {
                        "field": "payTo",
                        "expected": "0x1a2B3c4D5E6F7a8B9c0D1e2F3A4b5C6d7E8F9a0b",
                        "actual": "0x5D3e1a9b7c2f4E8A0b6d3c5F9E1A7b4D2C8f0a6E"
                      }
                    },
                    {
                      "code": "RPC_UNAVAILABLE",
                      "severity": "medium",
                      "detail": "No Base RPC endpoint is configured, so chain-dependent fields are unknown rather than assumed. See result.unresolved.",
                      "source": "rpc"
                    }
                  ],
                  "result": {
                    "input_shape": "unsigned_tx",
                    "chain": "eip155:8453",
                    "intent": {
                      "kind": "erc20_transfer",
                      "summary": "Transfer 10000 base units of token 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913 to 0x5D3e1a9b7c2f4E8A0b6d3c5F9E1A7b4D2C8f0a6E.",
                      "decode_source": "bundled-abi",
                      "selector": "0xa9059cbb",
                      "signature": "transfer(address,uint256)",
                      "function_name": "transfer",
                      "standard": "erc20",
                      "target": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
                      "value_wei": "0",
                      "args": [
                        {
                          "name": "to",
                          "type": "address",
                          "value": "0x5D3e1a9b7c2f4E8A0b6d3c5F9E1A7b4D2C8f0a6E"
                        },
                        {
                          "name": "amount",
                          "type": "uint256",
                          "value": "10000"
                        }
                      ],
                      "calls": [],
                      "depth": 0,
                      "truncated": false
                    },
                    "expected_transfers": [
                      {
                        "asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
                        "asset_kind": "erc20",
                        "from": "0x9f2C5E4a8DB1C3A7e6b0d4f8C1e2A5b7d9c0E3f4",
                        "to": "0x5D3e1a9b7c2f4E8A0b6d3c5F9E1A7b4D2C8f0a6E",
                        "amount": "10000",
                        "token_id": null,
                        "source": "decode"
                      }
                    ],
                    "approvals": [],
                    "permit_scope": null,
                    "spender": {
                      "address": null,
                      "is_contract": null,
                      "detail": "this transaction grants no allowance, so it has no spender"
                    },
                    "proxy": {
                      "address": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
                      "kind": "unknown",
                      "implementation": null,
                      "admin": null,
                      "beacon": null,
                      "upgradeable": null,
                      "slots_probed": [],
                      "detail": "no RPC endpoint is configured, so no slot could be read"
                    },
                    "authorization_checks": [],
                    "quote_comparison": {
                      "present": true,
                      "matches": false,
                      "fields": [
                        {
                          "field": "payTo",
                          "expected": "0x1a2B3c4D5E6F7a8B9c0D1e2F3A4b5C6d7E8F9a0b",
                          "actual": "0x5D3e1a9b7c2f4E8A0b6d3c5F9E1A7b4D2C8f0a6E",
                          "matches": false
                        },
                        {
                          "field": "amount",
                          "expected": "10000",
                          "actual": "10000",
                          "matches": true
                        },
                        {
                          "field": "asset",
                          "expected": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
                          "actual": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
                          "matches": true
                        },
                        {
                          "field": "chainId",
                          "expected": "8453",
                          "actual": null,
                          "matches": null
                        },
                        {
                          "field": "extra.name",
                          "expected": "USD Coin",
                          "actual": null,
                          "matches": null
                        },
                        {
                          "field": "extra.version",
                          "expected": "2",
                          "actual": null,
                          "matches": null
                        }
                      ],
                      "detail": "2 of 3 comparable fields match"
                    },
                    "simulation": {
                      "requested": false,
                      "status": "not_requested",
                      "asset_changes": [],
                      "gas_used": null,
                      "block_number": null,
                      "detail": "simulation was not requested; send simulate: true to run one"
                    },
                    "candidate_signatures": [],
                    "denylist_hits": [],
                    "unresolved": [
                      "proxy status of 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913 is unknown: no RPC endpoint is configured, so no slot could be read"
                    ],
                    "rpc": {
                      "configured": false,
                      "reachable": null,
                      "endpoints": []
                    }
                  },
                  "policy_version": "2026-08-03",
                  "request_hash": "sha256:6d5c717eb5eede165dada2645ad0944430ff492739cf58d0c2dad2b812f0ddb4",
                  "data_versions": {
                    "denylist": "2026-08-03.1",
                    "abi_packs": "2026-08-03.1",
                    "signature_index": "2026-08-03.1",
                    "policy": "2026-08-03",
                    "chain": "eip155:8453"
                  },
                  "warnings": []
                }
              }
            }
          },
          "400": {
            "description": "INPUT_INVALID",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false,
                  "properties": {
                    "error": {
                      "type": "object",
                      "required": [
                        "code",
                        "message"
                      ],
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "details": {}
                      }
                    }
                  }
                }
              }
            }
          },
          "402": {
            "description": "Payment required. Body carries the x402 challenge; see PAYMENT-REQUIRED header.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false,
                  "properties": {
                    "error": {
                      "type": "object",
                      "required": [
                        "code",
                        "message"
                      ],
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "details": {}
                      }
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "UNSUPPORTED or INDETERMINATE. Not charged.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false,
                  "properties": {
                    "error": {
                      "type": "object",
                      "required": [
                        "code",
                        "message"
                      ],
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "details": {}
                      }
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "RATE_LIMITED",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false,
                  "properties": {
                    "error": {
                      "type": "object",
                      "required": [
                        "code",
                        "message"
                      ],
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "details": {}
                      }
                    }
                  }
                }
              }
            }
          },
          "502": {
            "description": "Upstream or facilitator unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false,
                  "properties": {
                    "error": {
                      "type": "object",
                      "required": [
                        "code",
                        "message"
                      ],
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "details": {}
                      }
                    }
                  }
                }
              }
            }
          },
          "504": {
            "description": "UPSTREAM_TIMEOUT",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false,
                  "properties": {
                    "error": {
                      "type": "object",
                      "required": [
                        "code",
                        "message"
                      ],
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "details": {}
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "additionalProperties": false,
        "properties": {
          "error": {
            "type": "object",
            "required": [
              "code",
              "message"
            ],
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              },
              "details": {}
            }
          }
        }
      }
    }
  }
}