{
  "openapi": "3.1.0",
  "info": {
    "title": "Base Pre-Sign Guard by Agentropolis",
    "version": "0.1.0",
    "summary": "Simulate a Base transaction (or decode a Permit / Permit2 signature) before an agent signs it: signer asset changes, approvals granted (unlimited, Permit2, setApprovalForAll) and drainer-pattern flags → ok / warn / block. Missing data defaults to warn.",
    "description": "Runs eth_simulateV1 with traceTransfers on Base public RPC at the latest block (nothing is signed or broadcast), decodes approve / increaseAllowance / setApprovalForAll / permit / Permit2 calldata plus approvals emitted inside multicalls, checks whether each spender is a contract or a plain wallet and whether it is a well-known router, and flags sweeper patterns (several assets out, nothing back). Missing or unreadable data always yields warn, never ok. Not investment advice.",
    "contact": {
      "name": "Agentropolis",
      "url": "https://agentropolis.io",
      "email": "hello@agentropolis.io"
    },
    "x-guidance": "POST {\"chain\":\"base\",\"from\":\"0x...\",\"to\":\"0x...\",\"data\":\"0x...\",\"value\":\"0\"} (or {\"typedData\":{...},\"signer\":\"0x...\"}); pay the x402 402; do not sign when verdict is block; review warn flags."
  },
  "servers": [
    {
      "url": "https://seenly-token-preflight.vercel.app"
    }
  ],
  "paths": {
    "/api/presign-guard": {
      "post": {
        "operationId": "presignGuard",
        "summary": "Simulate a Base transaction (or decode a Permit / Permit2 signature) before an agent signs it",
        "tags": [
          "Crypto"
        ],
        "description": "$0.02 USDC per call on Base mainnet. Invalid input → 4xx before payment. Settles only on success. 30 req/min per client.",
        "x-payment-info": {
          "price": {
            "mode": "fixed",
            "currency": "USD",
            "amount": "0.02"
          },
          "protocols": [
            {
              "x402": {}
            }
          ],
          "rails": [
            {
              "protocol": "x402",
              "version": 2,
              "scheme": "exact",
              "network": "eip155:8453",
              "networkName": "Base mainnet",
              "asset": "USDC",
              "assetAddress": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
              "amount": "20000",
              "priceUsd": "0.02",
              "payTo": "0xeE6239F3E17bEBe5e89F21F29D74D68CAa0d78CE",
              "facilitator": "Coinbase CDP (gas sponsored; payer needs no ETH)",
              "header": "PAYMENT-SIGNATURE"
            }
          ]
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Request"
              },
              "example": {
                "chain": "base",
                "from": "0xcaA54748dA198081A89b6f369d798Ad78FC35B83",
                "to": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
                "data": "0x095ea7b30000000000000000000000001111111111111111111111111111111111111111ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
                "value": "0"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Result"
                }
              }
            }
          },
          "402": {
            "description": "Payment required (x402 v2 PAYMENT-REQUIRED header)"
          },
          "422": {
            "description": "invalid_address | unsupported_chain | invalid_request (not charged)"
          },
          "429": {
            "description": "rate_limited"
          },
          "503": {
            "description": "analysis_failed (not charged)"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Request": {
        "type": "object",
        "description": "Either a transaction (from, to, data, value) or an EIP-712 typedData object to be signed.",
        "properties": {
          "chain": {
            "type": "string",
            "enum": [
              "base"
            ],
            "default": "base"
          },
          "from": {
            "type": "string",
            "pattern": "^0x[0-9a-fA-F]{40}$",
            "description": "Signer address (transaction mode)."
          },
          "to": {
            "type": "string",
            "pattern": "^0x[0-9a-fA-F]{40}$"
          },
          "data": {
            "type": "string",
            "pattern": "^0x([0-9a-fA-F]{2})*$",
            "default": "0x"
          },
          "value": {
            "type": "string",
            "description": "Wei, decimal or 0x hex.",
            "default": "0"
          },
          "typedData": {
            "type": "object",
            "description": "EIP-712 {domain, types, primaryType, message}. Decodes Permit (EIP-2612) and Permit2 PermitSingle/PermitBatch."
          },
          "signer": {
            "type": "string",
            "pattern": "^0x[0-9a-fA-F]{40}$",
            "description": "Signer address (typedData mode, optional)."
          },
          "requestKey": {
            "type": "string",
            "maxLength": 128
          }
        }
      },
      "Result": {
        "type": "object",
        "properties": {
          "verdict": {
            "type": "string",
            "enum": [
              "ok",
              "warn",
              "block"
            ],
            "description": "block = known drainer pattern; warn = risk or missing data (default when data is missing); ok = no known risk pattern."
          },
          "summary": {
            "type": "string"
          },
          "flags": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "code": {
                  "type": "string"
                },
                "level": {
                  "type": "string"
                },
                "text": {
                  "type": "string"
                }
              }
            }
          },
          "approvals": {
            "type": "array",
            "items": {
              "type": "object"
            },
            "description": "Approvals granted: kind, token, spender, amount, unlimited, spender_is_contract, spender_label."
          },
          "asset_changes": {
            "type": "array",
            "items": {
              "type": "object"
            },
            "description": "Signer-side asset changes from the simulation: asset, symbol, sent, received, direction."
          },
          "simulation": {
            "type": "object"
          },
          "as_of_block": {
            "type": [
              "string",
              "null"
            ]
          },
          "disclaimer": {
            "type": "string"
          }
        },
        "required": [
          "verdict",
          "summary",
          "flags",
          "approvals",
          "asset_changes"
        ]
      }
    }
  }
}