{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://oxyon.io/xl1/api/v1/address.schema.json",
  "title": "oxyon.xl1.api.address.v1",
  "description": "Stable v1 contract for GET /api/xl1/v1/{net}/address. Fields listed are promised; others may appear (additive changes only).",
  "type": "object",
  "required": [
    "meta",
    "address",
    "balance",
    "history"
  ],
  "properties": {
    "address": {
      "type": "string",
      "pattern": "^[0-9a-f]{40}$"
    },
    "balance": {
      "type": [
        "object",
        "null"
      ],
      "required": [
        "atto",
        "range"
      ],
      "properties": {
        "atto": {
          "type": "string",
          "pattern": "^[0-9]+$"
        },
        "head": {
          "type": [
            "string",
            "null"
          ]
        },
        "range": {
          "type": "array",
          "items": {
            "type": "integer",
            "minimum": 0
          }
        }
      },
      "additionalProperties": true
    },
    "history": {
      "type": "object",
      "required": [
        "items",
        "range",
        "oldest",
        "more"
      ],
      "properties": {
        "items": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "block",
              "epoch",
              "tx",
              "transfer",
              "direction",
              "kind",
              "amount",
              "counterparties"
            ],
            "properties": {
              "block": {
                "type": "integer",
                "minimum": 0
              },
              "epoch": {
                "type": [
                  "integer",
                  "null"
                ],
                "minimum": 0
              },
              "tx": {
                "type": [
                  "string",
                  "null"
                ],
                "pattern": "^[0-9a-f]{64}$"
              },
              "transfer": {
                "type": [
                  "string",
                  "null"
                ],
                "pattern": "^[0-9a-f]{64}$"
              },
              "direction": {
                "enum": [
                  "in",
                  "out"
                ]
              },
              "kind": {
                "enum": [
                  "mint",
                  "transfer"
                ]
              },
              "amount": {
                "type": "string",
                "pattern": "^[0-9]+$"
              },
              "counterparties": {
                "type": "array",
                "items": {
                  "type": "object",
                  "required": [
                    "address",
                    "amount"
                  ],
                  "properties": {
                    "address": {
                      "type": "string",
                      "pattern": "^[0-9a-f]{40}$"
                    },
                    "amount": {
                      "type": "string",
                      "pattern": "^[0-9]+$"
                    }
                  },
                  "additionalProperties": true
                }
              }
            },
            "additionalProperties": true
          }
        },
        "range": {
          "type": "array",
          "items": {
            "type": "integer",
            "minimum": 0
          }
        },
        "oldest": {
          "type": [
            "integer",
            "null"
          ],
          "minimum": 0
        },
        "more": {
          "type": "boolean"
        }
      },
      "additionalProperties": true
    },
    "meta": {
      "type": "object",
      "required": [
        "net",
        "source",
        "generatedAt",
        "apiVersion",
        "schema"
      ],
      "properties": {
        "net": {
          "enum": [
            "sequence",
            "mainnet"
          ]
        },
        "source": {
          "enum": [
            "official",
            "observed",
            "derived",
            "telemetry",
            "rpc"
          ]
        },
        "generatedAt": {
          "type": "integer",
          "minimum": 0
        },
        "apiVersion": {
          "const": 1
        },
        "schema": {
          "const": "oxyon.xl1.api.address.v1"
        }
      },
      "additionalProperties": true
    }
  },
  "additionalProperties": true
}
