{
 "$schema": "https://json-schema.org/draft/2020-12/schema",
 "$id": "https://x402.nsgoods.org/settle/schema/settle_v1.schema.json",
 "title": "x402 Solana settlement verification envelope (settle_v1)",
 "description": "FROZEN after publication; changes only at an announced version boundary with a new schema_version. One signed verdict about one Solana transaction: did tx credit amount atomic units of mint to payee (and optionally was payer a signer). Single top-level verdict, no composition. Two refusal shapes (400 invalid subject, 503 signing unavailable) are part of the contract from the first version.",
 "$defs": {
  "asserted": {
   "type": "object",
   "additionalProperties": false,
   "required": [
    "payee",
    "amount",
    "mint"
   ],
   "properties": {
    "payee": {
     "type": "string"
    },
    "amount": {
     "type": "string"
    },
    "mint": {
     "type": "string"
    },
    "payer": {
     "type": "string"
    }
   }
  },
  "field": {
   "type": "object",
   "additionalProperties": false,
   "required": [
    "field",
    "asserted",
    "observed",
    "match"
   ],
   "properties": {
    "field": {
     "type": "string"
    },
    "asserted": {
     "type": [
      "string",
      "number",
      "null"
     ]
    },
    "observed": {
     "type": [
      "string",
      "number",
      "null"
     ]
    },
    "match": {
     "type": "boolean"
    }
   }
  }
 },
 "oneOf": [
  {
   "type": "object",
   "additionalProperties": false,
   "required": [
    "schema_version",
    "request",
    "verdict",
    "chain",
    "observed_at",
    "limitations",
    "signer",
    "manifest",
    "signature"
   ],
   "properties": {
    "schema_version": {
     "const": "settle_v1"
    },
    "request": {
     "type": "object",
     "additionalProperties": false,
     "required": [
      "tx",
      "asserted"
     ],
     "properties": {
      "tx": {
       "type": "string"
      },
      "asserted": {
       "$ref": "#/$defs/asserted"
      }
     }
    },
    "verdict": {
     "enum": [
      "VERIFIED",
      "REFUTED",
      "UNCONFIRMED",
      "NOT_FOUND",
      "not_evaluated"
     ]
    },
    "chain": {
     "const": "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp"
    },
    "observed_at": {
     "type": "string",
     "format": "date-time"
    },
    "limitations": {
     "type": "array",
     "items": {
      "type": "string"
     },
     "minItems": 1
    },
    "signer": {
     "const": "0x57fF0F084Cba33e6761503f90eEF0Da9F159350c"
    },
    "manifest": {
     "type": "object",
     "additionalProperties": false,
     "required": [
      "url",
      "entry"
     ],
     "properties": {
      "url": {
       "const": "https://x402.nsgoods.org/proof/index.json"
      },
      "entry": {
       "const": "settle"
      }
     }
    },
    "signature": {
     "type": "string",
     "pattern": "^0x[0-9a-fA-F]+$"
    },
    "fields": {
     "type": "array",
     "items": {
      "$ref": "#/$defs/field"
     }
    },
    "commitment": {
     "type": [
      "string",
      "null"
     ]
    },
    "slot": {
     "type": [
      "integer",
      "null"
     ]
    },
    "confirmations": {
     "type": [
      "integer",
      "null"
     ]
    },
    "searched_as_of_slot": {
     "type": [
      "integer",
      "null"
     ]
    },
    "reason_codes": {
     "type": "array",
     "items": {
      "type": "string"
     },
     "minItems": 1
    }
   }
  },
  {
   "type": "object",
   "required": [
    "error",
    "http_status",
    "charged",
    "schema_version",
    "reason_codes"
   ],
   "properties": {
    "error": {
     "type": "string"
    },
    "detail": {
     "type": "string"
    },
    "http_status": {
     "const": 400
    },
    "charged": {
     "const": false
    },
    "schema_version": {
     "const": "settle_v1"
    },
    "note": {
     "type": "string"
    },
    "reason_codes": {
     "type": "array",
     "items": {
      "type": "string"
     },
     "minItems": 1,
     "contains": {
      "const": "invalid_subject"
     }
    }
   },
   "additionalProperties": false
  },
  {
   "type": "object",
   "required": [
    "error",
    "http_status",
    "charged",
    "schema_version",
    "reason_codes"
   ],
   "properties": {
    "error": {
     "type": "string"
    },
    "detail": {
     "type": "string"
    },
    "http_status": {
     "const": 503
    },
    "charged": {
     "const": false
    },
    "schema_version": {
     "const": "settle_v1"
    },
    "note": {
     "type": "string"
    },
    "reason_codes": {
     "type": "array",
     "items": {
      "type": "string"
     },
     "minItems": 1,
     "contains": {
      "const": "signing_unavailable"
     }
    }
   },
   "additionalProperties": false
  }
 ]
}
