{
  "openapi": "3.1.0",
  "info": {
    "title": "Contract Safety API",
    "version": "1.0.0",
    "description": "x402 v2 paid API for on-chain EVM token contract risk signals."
  },
  "servers": [
    {
      "url": "https://node-starter--maxujon18.replit.app"
    }
  ],
  "paths": {
    "/api/check-contract": {
      "get": {
        "operationId": "checkContract",
        "summary": "Check an EVM token contract",
        "description": "Returns EIP-1967 proxy, owner control, and explorer source verification signals. Requires 0.02 USDC through x402 on Base mainnet.",
        "parameters": [
          {
            "name": "address",
            "in": "query",
            "required": true,
            "description": "Deployed EVM contract address.",
            "schema": {
              "type": "string",
              "pattern": "^0x[a-fA-F0-9]{40}$"
            },
            "example": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
          },
          {
            "name": "chain",
            "in": "query",
            "required": false,
            "description": "Network to inspect. Defaults to base.",
            "schema": {
              "type": "string",
              "enum": ["base", "bsc"],
              "default": "base"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Contract risk assessment.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ContractSafetyResult"
                }
              }
            }
          },
          "402": {
            "description": "x402 v2 payment challenge. Pay 0.02 USDC on Base and retry with an x402-compatible client."
          },
          "400": {
            "description": "Invalid address, unsupported chain, or address is not a deployed contract."
          },
          "502": {
            "description": "The selected chain RPC could not be reached."
          }
        },
        "x-x402": {
          "scheme": "exact",
          "network": "eip155:8453",
          "asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
          "amount": "20000"
        }
      }
    },
    "/api/healthz": {
      "get": {
        "operationId": "health",
        "summary": "Check service health",
        "responses": {
          "200": {
            "description": "Service is available.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["status"],
                  "properties": {
                    "status": {
                      "const": "ok"
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "ContractSafetyResult": {
        "type": "object",
        "required": ["address", "chain", "riskLevel", "signals", "checkedAt"],
        "properties": {
          "address": {
            "type": "string"
          },
          "chain": {
            "type": "string",
            "enum": ["base", "bsc"]
          },
          "riskLevel": {
            "type": "string",
            "enum": ["low", "medium", "high"]
          },
          "signals": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "checkedAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      }
    }
  }
}