{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/layerhop-com/json-schema/layerhop-com-tx-preview-schema.json",
  "title": "TxPreview",
  "x-generated": "2026-11-15",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/layerhop-com-openapi.yaml#/components/schemas/TxPreview",
  "type": "object",
  "required": [
    "kind",
    "chainId",
    "summary",
    "risk",
    "actions",
    "balanceChanges",
    "transfers",
    "approvals",
    "flags",
    "simulation",
    "community",
    "addresses"
  ],
  "properties": {
    "kind": {
      "type": "string",
      "enum": [
        "evm_tx",
        "typed_data",
        "solana_tx"
      ]
    },
    "chainId": {
      "type": "integer"
    },
    "from": {
      "type": "string"
    },
    "summary": {
      "type": "string",
      "description": "One plain sentence; starts with \"Danger:\" when a flag is `danger`."
    },
    "risk": {
      "type": "string",
      "enum": [
        "ok",
        "caution",
        "danger"
      ],
      "description": "The worst flag's level."
    },
    "actions": {
      "type": "array",
      "description": "Step by step, in plain language.",
      "items": {
        "type": "object",
        "required": [
          "text"
        ],
        "properties": {
          "text": {
            "type": "string"
          },
          "method": {
            "type": "string",
            "description": "Decoded function signature or EIP-712 primary type."
          }
        }
      }
    },
    "balanceChanges": {
      "type": "array",
      "description": "Net changes for `from` (negative = leaves the wallet).",
      "items": {
        "type": "object",
        "required": [
          "token",
          "delta"
        ],
        "properties": {
          "token": {
            "type": "string",
            "description": "Token address or mint; `native` for the chain's coin."
          },
          "symbol": {
            "type": "string"
          },
          "decimals": {
            "type": "integer"
          },
          "delta": {
            "type": "string",
            "description": "Signed integer in base units."
          },
          "tokenId": {
            "type": "string"
          },
          "standard": {
            "type": "string",
            "enum": [
              "native",
              "erc20",
              "erc721",
              "erc1155",
              "spl"
            ]
          }
        }
      }
    },
    "transfers": {
      "type": "array",
      "description": "Who gets what (at most 50).",
      "items": {
        "type": "object",
        "required": [
          "token",
          "from",
          "to",
          "amount"
        ],
        "properties": {
          "token": {
            "type": "string"
          },
          "symbol": {
            "type": "string"
          },
          "decimals": {
            "type": "integer"
          },
          "from": {
            "type": "string"
          },
          "to": {
            "type": "string"
          },
          "amount": {
            "type": "string"
          },
          "tokenId": {
            "type": "string"
          }
        }
      }
    },
    "approvals": {
      "type": "array",
      "description": "Permissions granted to spend the wallet's tokens.",
      "items": {
        "type": "object",
        "required": [
          "token",
          "spender",
          "amount",
          "unlimited",
          "via"
        ],
        "properties": {
          "token": {
            "type": "string"
          },
          "symbol": {
            "type": "string"
          },
          "decimals": {
            "type": "integer"
          },
          "spender": {
            "type": "string"
          },
          "spenderLabel": {
            "type": "string",
            "description": "A spender LayerHop can name (Permit2, LI.FI, Uniswap …)."
          },
          "spenderIsContract": {
            "type": "boolean"
          },
          "amount": {
            "type": "string",
            "description": "Base units, or `all` for setApprovalForAll."
          },
          "unlimited": {
            "type": "boolean"
          },
          "via": {
            "type": "string",
            "enum": [
              "approve",
              "increaseAllowance",
              "setApprovalForAll",
              "permit",
              "permit2"
            ]
          },
          "expiresAt": {
            "type": "integer",
            "description": "Unix seconds the permission or signature ends."
          }
        }
      }
    },
    "flags": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "code",
          "level",
          "message"
        ],
        "properties": {
          "code": {
            "type": "string",
            "enum": [
              "unlimited_approval",
              "approval_to_eoa",
              "approval_to_unknown",
              "approve_all_nfts",
              "permit_to_unknown",
              "permit_to_eoa",
              "long_permit",
              "value_to_eoa",
              "unverified_contract",
              "new_contract",
              "gives_away_assets",
              "community_reports",
              "simulation_failed",
              "unknown_function",
              "wrong_chain"
            ]
          },
          "level": {
            "type": "string",
            "enum": [
              "caution",
              "danger"
            ]
          },
          "message": {
            "type": "string"
          }
        }
      }
    },
    "simulation": {
      "type": "object",
      "required": [
        "method",
        "ok"
      ],
      "properties": {
        "method": {
          "type": "string",
          "enum": [
            "eth_simulateV1",
            "debug_traceCall",
            "eth_call",
            "decode",
            "simulateTransaction",
            "none"
          ]
        },
        "ok": {
          "type": "boolean",
          "description": "`false`: the transaction would fail (see `error`)."
        },
        "error": {
          "type": "string"
        },
        "gasUsed": {
          "type": "string"
        }
      }
    },
    "community": {
      "type": "array",
      "description": "Community reports on the addresses involved (only those with reports).",
      "items": {
        "$ref": "#/$defs/CommunityReports"
      }
    },
    "addresses": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "address",
          "role"
        ],
        "properties": {
          "address": {
            "type": "string"
          },
          "role": {
            "type": "string",
            "description": "`to`, `spender`, `recipient` or `program`."
          },
          "label": {
            "type": "string"
          },
          "isContract": {
            "type": "boolean"
          },
          "verified": {
            "type": "boolean",
            "description": "Source published on Etherscan (only when the deployment has a key)."
          }
        }
      }
    }
  },
  "$defs": {
    "CommunityNote": {
      "type": "object",
      "required": [
        "category",
        "note",
        "chainId",
        "createdAt"
      ],
      "properties": {
        "category": {
          "$ref": "#/$defs/ReportCategory"
        },
        "note": {
          "type": "string"
        },
        "txHash": {
          "type": "string"
        },
        "chainId": {
          "type": "integer"
        },
        "createdAt": {
          "type": "string",
          "format": "date-time"
        }
      }
    },
    "CommunityReports": {
      "type": "object",
      "description": "Community reports for one address or token. `count` includes reports not reviewed yet; notes\nshow only after an admin approved them. A signal from users, never a verdict.\n",
      "required": [
        "target",
        "count",
        "categories",
        "chainIds",
        "notes"
      ],
      "properties": {
        "target": {
          "type": "string",
          "description": "EVM address (lower-case) or Solana address."
        },
        "count": {
          "type": "integer",
          "description": "Reports that aren't hidden."
        },
        "approved": {
          "type": "integer",
          "description": "Of `count`, the reports an admin approved. Only approved reports raise a transaction preview's risk."
        },
        "categories": {
          "type": "object",
          "description": "Reports per category.",
          "properties": {
            "scam": {
              "type": "integer"
            },
            "phishing": {
              "type": "integer"
            },
            "poisoning": {
              "type": "integer"
            },
            "rug": {
              "type": "integer"
            }
          }
        },
        "chainIds": {
          "type": "array",
          "items": {
            "type": "integer"
          },
          "description": "Chains the reports were filed on."
        },
        "notes": {
          "type": "array",
          "description": "Newest approved notes (at most 5).",
          "items": {
            "$ref": "#/$defs/CommunityNote"
          }
        },
        "lastReportedAt": {
          "type": "string",
          "format": "date-time"
        }
      }
    },
    "ReportCategory": {
      "type": "string",
      "enum": [
        "scam",
        "phishing",
        "poisoning",
        "rug"
      ],
      "description": "`phishing` covers drainer sites and malicious approvals; `poisoning` look-alike addresses and zero-value transfers."
    }
  }
}