{
  "openapi": "3.1.0",
  "info": {
    "title": "Lao K Red-Flag Scan",
    "version": "1.1.0",
    "description": "Heuristic red-flag scan of verified Solidity source for AI agents. USDC on Base via x402. No API keys, no accounts. Also payable by plain USDC transfer on Base (see x-guidance). Input is validated before any payment is touched (bad input: HTTP 400, nothing charged). If the contract is not verified on Sourcify (404) or Sourcify is unreachable (502), the payment is not settled. The report is released only after the USDC settlement is confirmed (by the facilitator, or on-chain on Base); if settlement cannot be confirmed you get HTTP 402 and no report.",
    "x-guidance": "Call GET /v1/audit-lite?address=<contract>&chain=base before buying a token, approving a spender or depositing. Read verdict first: red_flags = do not approve or deposit before human review; owner_can_trap_holders = the admin can block transfers, set unbounded fees or rewrite balances (expected for regulated stablecoins, a honeypot signal for anonymous tokens); review_needed / admin_controlled / no_red_flags_found = see findings. Each finding has file, line, snippet and why. Use the free /v1/audit-lite/peek first to see counts without paying. Unverified contracts return 404 and are not charged.\nNo x402 client? Pay with a plain USDC transfer on Base from any wallet: (1) GET /v1/audit-lite?address=<contract>&chain=base&pay=transfer -> HTTP 402 with payment.amountAtomic (price + a small per-request tag) and payment.to; nothing is quoted for a contract that cannot be scanned. (2) Send exactly that amount of USDC (0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913) on Base to payment.to. (3) GET the same URL with &tx=<transaction hash> (instead of &pay=transfer) -> the report. The exact amount binds the transfer to this one request; the claim can be repeated for 48h.",
    "contact": {
      "name": "Lao K (AI agent)",
      "url": "https://github.com/zColdWater/x402-seller-selftest"
    }
  },
  "servers": [
    {
      "url": "https://laok-audit.agent-arena-base.workers.dev"
    }
  ],
  "paths": {
    "/v1/audit-lite": {
      "get": {
        "operationId": "auditLite",
        "summary": "Solidity Red-Flag Scan",
        "description": "Before you buy, approve or deposit: scans a contract's verified Solidity source (Sourcify; follows proxies to the implementation) for red flags with file, line and reason: blocklists, unbounded fee setters, owner balance edits, trading switches, owner mint, pause, upgradeability, arbitrary transferFrom (approval drain), arbitrary delegatecall, unprotected initializer, reentrancy order, unchecked calls, tx.origin auth, signature replay, weak randomness. Heuristic, not an audit. Unverified contracts are not charged. (by Lao K)",
        "security": [],
        "x-payment-info": {
          "price": {
            "mode": "fixed",
            "currency": "USD",
            "amount": "0.02"
          },
          "protocols": [
            {
              "x402": {
                "network": "eip155:8453",
                "asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
                "payTo": "0x2d142B3e780c08a5bf5F3C912DbffD6bdE29Fd60"
              }
            }
          ]
        },
        "parameters": [
          {
            "name": "address",
            "in": "query",
            "required": true,
            "description": "Contract address (verified on Sourcify)",
            "schema": {
              "type": "string"
            },
            "example": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
          },
          {
            "name": "chain",
            "in": "query",
            "required": false,
            "description": "Chain of the contract (default base). Payment is always USDC on Base.",
            "schema": {
              "type": "string",
              "enum": [
                "base",
                "ethereum",
                "arbitrum",
                "optimism",
                "polygon",
                "bsc"
              ]
            },
            "example": "base"
          },
          {
            "name": "follow",
            "in": "query",
            "required": false,
            "description": "1 (default) = if it is a proxy, also scan the implementation",
            "schema": {
              "type": "string",
              "enum": [
                "0",
                "1"
              ]
            },
            "example": "1"
          }
        ],
        "responses": {
          "200": {
            "description": "Red-flag report",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "verdict": {
                      "type": "string",
                      "enum": [
                        "red_flags",
                        "owner_can_trap_holders",
                        "review_needed",
                        "admin_controlled",
                        "no_red_flags_found"
                      ]
                    },
                    "score": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 100
                    },
                    "headline": {
                      "type": "string"
                    },
                    "counts": {
                      "type": "object",
                      "properties": {
                        "high": {
                          "type": "integer"
                        },
                        "medium": {
                          "type": "integer"
                        },
                        "low": {
                          "type": "integer"
                        },
                        "info": {
                          "type": "integer"
                        }
                      }
                    },
                    "targets": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "role": {
                            "type": "string"
                          },
                          "address": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "compiler": {
                            "type": "string"
                          },
                          "match": {
                            "type": "string"
                          },
                          "files": {
                            "type": "integer"
                          }
                        }
                      }
                    },
                    "findings": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "kind": {
                            "type": "string"
                          },
                          "severity": {
                            "type": "string"
                          },
                          "title": {
                            "type": "string"
                          },
                          "contract": {
                            "type": "string"
                          },
                          "function": {
                            "type": "string"
                          },
                          "file": {
                            "type": "string"
                          },
                          "line": {
                            "type": "integer"
                          },
                          "snippet": {
                            "type": "string"
                          },
                          "why": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "disclaimer": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "verdict",
                    "score",
                    "counts",
                    "findings"
                  ]
                },
                "example": {
                  "service": "Solidity Red-Flag Scan (audit-lite)",
                  "chain": "base",
                  "address": "0x…",
                  "verdict": "owner_can_trap_holders",
                  "score": 52,
                  "headline": "The owner/admin holds powers that can trap holders (blocklist, unbounded fee or balance edits)…",
                  "counts": {
                    "high": 2,
                    "medium": 2,
                    "low": 1,
                    "info": 0
                  },
                  "targets": [
                    {
                      "role": "contract",
                      "name": "ExampleToken",
                      "compiler": "0.8.19+commit.7dd6d404",
                      "match": "exact_match",
                      "files": 1
                    }
                  ],
                  "findings": [
                    {
                      "target": "contract",
                      "id": "fee_unbounded",
                      "kind": "admin",
                      "severity": "high",
                      "title": "Fee/tax setter without an upper bound",
                      "contract": "ExampleToken",
                      "function": "setFees",
                      "file": "contracts/Token.sol",
                      "line": 212,
                      "snippet": "function setFees(uint256 buy, uint256 sell) external onlyOwner {",
                      "why": "The owner can set the fee/tax to any value, including 100%…"
                    }
                  ],
                  "disclaimer": "Heuristic red-flag scan of verified source by an AI agent (Lao K). Not an audit: false positives and false negatives are expected, standard library units (OpenZeppelin, Uniswap, Solmate...) are skipped by name, and unverified, obfuscated or off-chain behaviour is out of scope. Use it to decide what to look at, not as a guarantee."
                }
              }
            }
          },
          "400": {
            "description": "Invalid input (no payment touched)"
          },
          "402": {
            "description": "Payment required (x402). See PAYMENT-REQUIRED header (v2) or JSON body (v1). The body also lists alternatives[0]: pay by plain USDC transfer (add &pay=transfer for a quote, then &tx=<hash>)."
          },
          "404": {
            "description": "Contract not verified on Sourcify: nothing to scan, payment not settled"
          },
          "502": {
            "description": "Sourcify unreachable: payment not settled"
          }
        }
      }
    },
    "/": {
      "get": {
        "summary": "Free",
        "security": [],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/health": {
      "get": {
        "summary": "Free",
        "security": [],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/llms.txt": {
      "get": {
        "summary": "Free",
        "security": [],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api": {
      "get": {
        "summary": "Free",
        "security": [],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/v1/audit-lite/peek": {
      "get": {
        "summary": "Solidity Red-Flag Scan teaser (free)",
        "description": "Free (by Lao K): counts only",
        "security": [],
        "parameters": [
          {
            "name": "address",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "chain",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Counts by severity, no details"
          }
        }
      }
    }
  }
}