{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/blockvectra/json-schema/blockvectra-event-history-page-schema.json",
  "title": "EventHistoryPage",
  "x-generated": "2026-11-02",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/push.yaml#/components/schemas/EventHistoryPage",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "events",
    "next_page_token"
  ],
  "properties": {
    "events": {
      "type": "array",
      "maxItems": 100,
      "items": {
        "$ref": "#/$defs/DeliveredEvent"
      }
    },
    "next_page_token": {
      "type": [
        "string",
        "null"
      ]
    }
  },
  "$defs": {
    "Address": {
      "type": "string",
      "pattern": "^0x[0-9a-f]{40}$"
    },
    "Amount": {
      "type": "string",
      "pattern": "^(0|[1-9][0-9]*)$"
    },
    "BlockNumber": {
      "type": "integer",
      "minimum": 0
    },
    "DeliveredEvent": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "event",
        "replay_epoch",
        "orphaned",
        "delivered_at"
      ],
      "properties": {
        "event": {
          "oneOf": [
            {
              "$ref": "#/$defs/NativeTransfer"
            },
            {
              "$ref": "#/$defs/TokenTransfer"
            },
            {
              "$ref": "#/$defs/LogEvent"
            }
          ]
        },
        "replay_epoch": {
          "type": "integer",
          "minimum": 0,
          "description": "Replay epoch of the stream: 0 at first, plus one at each replay, at each automatic re-delivery after a reorg and at each re-delivery after a chain reorg is cleared."
        },
        "orphaned": {
          "type": "boolean",
          "description": "true when the block of this row was later replaced by a reorg and is no longer canonical."
        },
        "delivered_at": {
          "$ref": "#/$defs/Timestamp"
        }
      }
    },
    "EventId": {
      "type": "string",
      "pattern": "^evt_[a-z2-7]{26}$"
    },
    "Hash32": {
      "type": "string",
      "pattern": "^0x[0-9a-f]{64}$"
    },
    "HexData": {
      "type": "string",
      "pattern": "^0x([0-9a-f]{2})*$"
    },
    "LogEvent": {
      "type": "object",
      "additionalProperties": false,
      "description": "Any other log that names a watched address, as the emitting contract or in topics[1] to topics[3] (left-padded to 32 bytes).",
      "required": [
        "id",
        "type",
        "ref",
        "address",
        "topics",
        "data",
        "block_number",
        "block_hash",
        "block_timestamp",
        "tx_hash",
        "tx_index",
        "log_index",
        "matched"
      ],
      "properties": {
        "id": {
          "$ref": "#/$defs/EventId"
        },
        "type": {
          "const": "log"
        },
        "ref": {
          "type": "string",
          "pattern": "^eip155:[0-9]+:0x[0-9a-f]{64}:[0-9]+$"
        },
        "address": {
          "$ref": "#/$defs/Address"
        },
        "topics": {
          "type": "array",
          "maxItems": 4,
          "items": {
            "$ref": "#/$defs/Hash32"
          }
        },
        "data": {
          "$ref": "#/$defs/HexData"
        },
        "block_number": {
          "$ref": "#/$defs/BlockNumber"
        },
        "block_hash": {
          "$ref": "#/$defs/Hash32"
        },
        "block_timestamp": {
          "$ref": "#/$defs/Timestamp"
        },
        "tx_hash": {
          "$ref": "#/$defs/Hash32"
        },
        "tx_index": {
          "type": "integer",
          "minimum": 0
        },
        "log_index": {
          "type": "integer",
          "minimum": 0
        },
        "matched": {
          "type": "array",
          "minItems": 1,
          "maxItems": 4,
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "address",
              "role"
            ],
            "properties": {
              "address": {
                "$ref": "#/$defs/Address"
              },
              "role": {
                "type": "string",
                "enum": [
                  "emitter",
                  "topic1",
                  "topic2",
                  "topic3"
                ]
              }
            }
          }
        }
      }
    },
    "NativeTransfer": {
      "type": "object",
      "additionalProperties": false,
      "description": "Successful top-level transaction with value > 0 where a watched address is from or to (for a contract creation, to is the new contract). Internal transfers are not delivered.",
      "required": [
        "id",
        "type",
        "ref",
        "from",
        "to",
        "amount",
        "block_number",
        "block_hash",
        "block_timestamp",
        "tx_hash",
        "tx_index",
        "matched"
      ],
      "properties": {
        "id": {
          "$ref": "#/$defs/EventId"
        },
        "type": {
          "const": "native.transfer"
        },
        "ref": {
          "type": "string",
          "pattern": "^eip155:[0-9]+:0x[0-9a-f]{64}:tx$"
        },
        "from": {
          "$ref": "#/$defs/Address"
        },
        "to": {
          "$ref": "#/$defs/Address"
        },
        "amount": {
          "$ref": "#/$defs/Amount"
        },
        "block_number": {
          "$ref": "#/$defs/BlockNumber"
        },
        "block_hash": {
          "$ref": "#/$defs/Hash32"
        },
        "block_timestamp": {
          "$ref": "#/$defs/Timestamp"
        },
        "tx_hash": {
          "$ref": "#/$defs/Hash32"
        },
        "tx_index": {
          "type": "integer",
          "minimum": 0
        },
        "matched": {
          "type": "array",
          "minItems": 1,
          "maxItems": 2,
          "items": {
            "$ref": "#/$defs/TransferMatch"
          }
        }
      }
    },
    "Timestamp": {
      "type": "string",
      "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$"
    },
    "TokenTransfer": {
      "type": "object",
      "additionalProperties": false,
      "description": "ERC-20 Transfer (3 topics), ERC-721 Transfer (4 topics) or ERC-1155 TransferSingle / TransferBatch of any contract, where a watched address is from or to. One event per (id, value) of a TransferBatch (batch_index from 0).",
      "required": [
        "id",
        "type",
        "ref",
        "standard",
        "token",
        "from",
        "to",
        "token_id",
        "amount",
        "batch_index",
        "block_number",
        "block_hash",
        "block_timestamp",
        "tx_hash",
        "tx_index",
        "log_index",
        "matched"
      ],
      "properties": {
        "id": {
          "$ref": "#/$defs/EventId"
        },
        "type": {
          "const": "token.transfer"
        },
        "ref": {
          "type": "string",
          "pattern": "^eip155:[0-9]+:0x[0-9a-f]{64}:[0-9]+(:[0-9]+)?$"
        },
        "standard": {
          "type": "string",
          "enum": [
            "erc20",
            "erc721",
            "erc1155"
          ]
        },
        "token": {
          "$ref": "#/$defs/Address"
        },
        "from": {
          "$ref": "#/$defs/Address"
        },
        "to": {
          "$ref": "#/$defs/Address"
        },
        "token_id": {
          "type": [
            "string",
            "null"
          ],
          "pattern": "^(0|[1-9][0-9]*)$",
          "description": "null for erc20."
        },
        "amount": {
          "$ref": "#/$defs/Amount"
        },
        "batch_index": {
          "type": [
            "integer",
            "null"
          ],
          "minimum": 0,
          "description": "Only for an ERC-1155 TransferBatch."
        },
        "block_number": {
          "$ref": "#/$defs/BlockNumber"
        },
        "block_hash": {
          "$ref": "#/$defs/Hash32"
        },
        "block_timestamp": {
          "$ref": "#/$defs/Timestamp"
        },
        "tx_hash": {
          "$ref": "#/$defs/Hash32"
        },
        "tx_index": {
          "type": "integer",
          "minimum": 0
        },
        "log_index": {
          "type": "integer",
          "minimum": 0
        },
        "matched": {
          "type": "array",
          "minItems": 1,
          "maxItems": 2,
          "items": {
            "$ref": "#/$defs/TransferMatch"
          }
        }
      }
    },
    "TransferMatch": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "address",
        "role"
      ],
      "properties": {
        "address": {
          "$ref": "#/$defs/Address"
        },
        "role": {
          "type": "string",
          "enum": [
            "from",
            "to"
          ]
        }
      }
    }
  }
}