{
  "$id": "contract-object.spec.json",
  "$schema": "http://json-schema.org/schema#",
  "title": "Contract Object",
  "description": "Describes a contract consumable by Truffle, possibly including deployed instances on networks",
  "type": "object",
  "properties": {
    "contractName": {
      "$ref": "#/definitions/ContractName",
      "description": "Name used to identify the contract",
      "default": "Contract"
    },
    "abi": {
      "$ref": "abi.spec.json#",
      "description": "Interface description returned by compiler for source"
    },
    "metadata": {
      "$ref": "#/definitions/Metadata"
    },
    "bytecode": {
      "$ref": "#/definitions/Bytecode",
      "description": "Bytecode sent as contract-creation transaction data, with unresolved link references"
    },
    "deployedBytecode": {
      "$ref": "#/definitions/Bytecode",
      "description": "On-chain deployed contract bytecode, with unresolved link references"
    },
    "sourceMap": {
      "$ref": "#/definitions/SourceMap",
      "description": "Source mapping for contract-creation transaction data bytecode"
    },
    "deployedSourceMap": {
      "$ref": "#/definitions/SourceMap",
      "description": "Source mapping for contract bytecode"
    },
    "source": {
      "$ref": "#/definitions/Source"
    },
    "sourcePath": {
      "$ref": "#/definitions/SourcePath"
    },
    "ast": {
      "$ref": "#/definitions/AST"
    },
    "legacyAST": {
      "$ref": "#/definitions/LegacyAST"
    },
    "compiler": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string"
        },
        "version": {
          "type": "string"
        }
      }
    },
    "networks": {
      "type": "object",
      "patternProperties": {
        "^[a-zA-Z0-9]+$": {
          "$ref": "network-object.spec.json#"
        }
      },
      "additionalProperties": false
    },
    "schemaVersion": {
      "$ref": "#/definitions/SchemaVersion"
    },
    "updatedAt": {
      "type": "string",
      "format": "date-time"
    },
    "networkType": {
      "$ref": "#/definitions/NetworkType",
      "default": "ethereum"
    },
    "devdoc": {
      "$ref": "#/definitions/NatSpec"
    },
    "userdoc": {
      "$ref": "#/definitions/NatSpec"
    },
    "immutableReferences": {
      "$ref": "#/definitions/ImmutableReferences"
    },
    "generatedSources": {
      "$ref": "#/definitions/GeneratedSources"
    },
    "deployedGeneratedSources": {
      "$ref": "#/definitions/GeneratedSources"
    },
    "db": {
      "type": "object",
      "patternProperties": {
        "^[a-zA-Z0-9]+$": {
          "type": "object",
          "description": "Reference to @truffle/db canonical ID object for correlation purposes",
          "properties": {
            "id": {
              "type": "string"
            }
          }
        }
      }
    }
  },
  "required": [
    "abi"
  ],
  "patternProperties": {
    "^x-": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "boolean"
        },
        {
          "type": "number"
        },
        {
          "type": "object"
        },
        {
          "type": "array"
        }
      ]
    }
  },
  "additionalProperties": false,
  "definitions": {
    "ContractName": {
      "type": "string",
      "pattern": "^[a-zA-Z_][a-zA-Z0-9_]*$"
    },
    "NatSpec": {
      "type": "object"
    },
    "Metadata": {
      "type": "string"
    },
    "NetworkType": {
      "type": "string"
    },
    "Bytecode": {
      "type": "string",
      "pattern": "^0x0?$|^0x([a-fA-F0-9]{2}|__.{38})+$"
    },
    "ImmutableReferences": {
      "type": "object",
      "additionalProperties": {
       "type": "array",
       "items": {
         "type": "object",
         "properties": {
           "start": {
             "type": "integer",
             "minimum": 0
           },
           "length": {
             "type": "integer",
             "minimum": 0
           }
         },
         "additionalProperties": false
        }
      }
    },
    "GeneratedSources": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {"type": "integer", "minimum": 0},
          "language": {"type": "string"},
          "name": {"type": "string"},
          "contents": {"type": "string"},
          "ast": {"type": "object"}
        },
        "additionalProperties": false
      }
    },
    "Source": {
      "type": "string"
    },
    "SourceMap": {
      "type": "string",
      "examples": [
        "315:637:1:-;;;452:55;;;;;;;-1:-1:-1;;;;;485:9:1;476:19;:8;:19;;;;;;;;;;498:5;476:27;;452:55;315:637;;;;;;;"
      ]
    },
    "SourcePath": {
      "type": "string"
    },
    "AST": {
      "type": "object"
    },
    "LegacyAST": {
      "type": "object"
    },
    "SchemaVersion": {
      "type": "string",
      "pattern": "[0-9]+\\.[0-9]+\\.[0-9]+"
    }
  }
}
