Json Schema

[
  {
    "$schema": "http://json-schema.org/draft-07/schema#",
    "title": "Contract",
    "description": "A contract of predicates.",
    "type": "object",
    "required": [
      "predicates",
      "salt"
    ],
    "properties": {
      "predicates": {
        "description": "The contract of predicates.",
        "type": "array",
        "items": {
          "$ref": "#/definitions/Predicate"
        }
      },
      "salt": {
        "description": "The salt used to make the contract unique.",
        "type": "array",
        "items": {
          "type": "integer",
          "format": "uint8",
          "minimum": 0.0
        },
        "maxItems": 32,
        "minItems": 32
      }
    },
    "definitions": {
      "Directive": {
        "description": "The directive for the predicate.",
        "oneOf": [
          {
            "description": "All constraints must be satisfied.",
            "type": "string",
            "enum": [
              "Satisfy"
            ]
          },
          {
            "description": "Maximize the objective value.",
            "type": "object",
            "required": [
              "Maximize"
            ],
            "properties": {
              "Maximize": {
                "type": "array",
                "items": {
                  "type": "integer",
                  "format": "uint8",
                  "minimum": 0.0
                }
              }
            },
            "additionalProperties": false
          },
          {
            "description": "Minimize the objective value.",
            "type": "object",
            "required": [
              "Minimize"
            ],
            "properties": {
              "Minimize": {
                "type": "array",
                "items": {
                  "type": "integer",
                  "format": "uint8",
                  "minimum": 0.0
                }
              }
            },
            "additionalProperties": false
          }
        ]
      },
      "Predicate": {
        "description": "An individual predicate to be solved.",
        "type": "object",
        "required": [
          "constraints",
          "directive",
          "state_read"
        ],
        "properties": {
          "constraints": {
            "description": "The programs that check constraints.",
            "type": "array",
            "items": {
              "type": "array",
              "items": {
                "type": "integer",
                "format": "uint8",
                "minimum": 0.0
              }
            }
          },
          "directive": {
            "description": "The directive for the predicate.",
            "allOf": [
              {
                "$ref": "#/definitions/Directive"
              }
            ]
          },
          "state_read": {
            "description": "The programs that read state.",
            "type": "array",
            "items": {
              "type": "array",
              "items": {
                "type": "integer",
                "format": "uint8",
                "minimum": 0.0
              }
            }
          }
        }
      }
    }
  },
  {
    "$schema": "http://json-schema.org/draft-07/schema#",
    "title": "Solution",
    "description": "A solution to predicates.",
    "type": "object",
    "required": [
      "data"
    ],
    "properties": {
      "data": {
        "description": "The input data for each predicate.",
        "type": "array",
        "items": {
          "$ref": "#/definitions/SolutionData"
        }
      }
    },
    "definitions": {
      "ContentAddress": {
        "description": "Content address of a predicate or contract.",
        "type": "array",
        "items": {
          "type": "integer",
          "format": "uint8",
          "minimum": 0.0
        },
        "maxItems": 32,
        "minItems": 32
      },
      "Mutation": {
        "description": "A mutation to a single key in state or transient data.",
        "type": "object",
        "required": [
          "key",
          "value"
        ],
        "properties": {
          "key": {
            "description": "Key to data.",
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int64"
            }
          },
          "value": {
            "description": "Value to contract the key to. Empty value means the value is being deleted.",
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int64"
            }
          }
        }
      },
      "PredicateAddress": {
        "description": "Address of a predicate.",
        "type": "object",
        "required": [
          "contract",
          "predicate"
        ],
        "properties": {
          "contract": {
            "description": "Content address of the contract with which this predicate was deployed.\n\nThis is equal to `essential_hash::content_addr(predicate_addresses)`, where `predicate_addresses` is a `&[ContentAddress]` sorted by the `ContentAddress` `Ord` implementation.",
            "allOf": [
              {
                "$ref": "#/definitions/ContentAddress"
              }
            ]
          },
          "predicate": {
            "description": "Content address of the predicate.\n\nThis is equal to `essential_hash::content_addr(predicate)` where `predicate` is a [`&Predicate`][predicate::Predicate].",
            "allOf": [
              {
                "$ref": "#/definitions/ContentAddress"
              }
            ]
          }
        }
      },
      "SolutionData": {
        "description": "The data the solver is required to provide to solve a predicate.",
        "type": "object",
        "required": [
          "decision_variables",
          "predicate_to_solve",
          "state_mutations",
          "transient_data"
        ],
        "properties": {
          "decision_variables": {
            "description": "The decision variables for the predicate.",
            "type": "array",
            "items": {
              "type": "array",
              "items": {
                "type": "integer",
                "format": "int64"
              }
            }
          },
          "predicate_to_solve": {
            "description": "Which predicate this input data is for.",
            "allOf": [
              {
                "$ref": "#/definitions/PredicateAddress"
              }
            ]
          },
          "state_mutations": {
            "description": "The state mutations being proposed.",
            "type": "array",
            "items": {
              "$ref": "#/definitions/Mutation"
            }
          },
          "transient_data": {
            "description": "The transient data being proposed.",
            "type": "array",
            "items": {
              "$ref": "#/definitions/Mutation"
            }
          }
        }
      }
    }
  },
  {
    "$schema": "http://json-schema.org/draft-07/schema#",
    "title": "Block",
    "description": "A protocol block.",
    "type": "object",
    "required": [
      "batch",
      "number",
      "timestamp"
    ],
    "properties": {
      "batch": {
        "description": "The batch of solutions.",
        "allOf": [
          {
            "$ref": "#/definitions/Batch"
          }
        ]
      },
      "number": {
        "description": "The block number.",
        "type": "integer",
        "format": "uint64",
        "minimum": 0.0
      },
      "timestamp": {
        "description": "The timestamp of the block.",
        "allOf": [
          {
            "$ref": "#/definitions/Duration"
          }
        ]
      }
    },
    "definitions": {
      "Batch": {
        "description": "A batch of solutions",
        "type": "object",
        "required": [
          "solutions"
        ],
        "properties": {
          "solutions": {
            "description": "The solutions in the batch.",
            "type": "array",
            "items": {
              "$ref": "#/definitions/Solution"
            }
          }
        }
      },
      "ContentAddress": {
        "description": "Content address of a predicate or contract.",
        "type": "array",
        "items": {
          "type": "integer",
          "format": "uint8",
          "minimum": 0.0
        },
        "maxItems": 32,
        "minItems": 32
      },
      "Duration": {
        "type": "object",
        "required": [
          "nanos",
          "secs"
        ],
        "properties": {
          "nanos": {
            "type": "integer",
            "format": "uint32",
            "minimum": 0.0
          },
          "secs": {
            "type": "integer",
            "format": "uint64",
            "minimum": 0.0
          }
        }
      },
      "Mutation": {
        "description": "A mutation to a single key in state or transient data.",
        "type": "object",
        "required": [
          "key",
          "value"
        ],
        "properties": {
          "key": {
            "description": "Key to data.",
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int64"
            }
          },
          "value": {
            "description": "Value to contract the key to. Empty value means the value is being deleted.",
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int64"
            }
          }
        }
      },
      "PredicateAddress": {
        "description": "Address of a predicate.",
        "type": "object",
        "required": [
          "contract",
          "predicate"
        ],
        "properties": {
          "contract": {
            "description": "Content address of the contract with which this predicate was deployed.\n\nThis is equal to `essential_hash::content_addr(predicate_addresses)`, where `predicate_addresses` is a `&[ContentAddress]` sorted by the `ContentAddress` `Ord` implementation.",
            "allOf": [
              {
                "$ref": "#/definitions/ContentAddress"
              }
            ]
          },
          "predicate": {
            "description": "Content address of the predicate.\n\nThis is equal to `essential_hash::content_addr(predicate)` where `predicate` is a [`&Predicate`][predicate::Predicate].",
            "allOf": [
              {
                "$ref": "#/definitions/ContentAddress"
              }
            ]
          }
        }
      },
      "Solution": {
        "description": "A solution to predicates.",
        "type": "object",
        "required": [
          "data"
        ],
        "properties": {
          "data": {
            "description": "The input data for each predicate.",
            "type": "array",
            "items": {
              "$ref": "#/definitions/SolutionData"
            }
          }
        }
      },
      "SolutionData": {
        "description": "The data the solver is required to provide to solve a predicate.",
        "type": "object",
        "required": [
          "decision_variables",
          "predicate_to_solve",
          "state_mutations",
          "transient_data"
        ],
        "properties": {
          "decision_variables": {
            "description": "The decision variables for the predicate.",
            "type": "array",
            "items": {
              "type": "array",
              "items": {
                "type": "integer",
                "format": "int64"
              }
            }
          },
          "predicate_to_solve": {
            "description": "Which predicate this input data is for.",
            "allOf": [
              {
                "$ref": "#/definitions/PredicateAddress"
              }
            ]
          },
          "state_mutations": {
            "description": "The state mutations being proposed.",
            "type": "array",
            "items": {
              "$ref": "#/definitions/Mutation"
            }
          },
          "transient_data": {
            "description": "The transient data being proposed.",
            "type": "array",
            "items": {
              "$ref": "#/definitions/Mutation"
            }
          }
        }
      }
    }
  }
]