{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://lopw.com/docs/schemas/offer.json",
  "title": "Offer",
  "description": "The seller's signed promise shown with the 402 response (Rust: lopw_types::Offer). This is the signed body; the signature travels beside it in SignedOffer. offer_hash = SHA-256('LOPW/OFFER/v1' || network_id || XDR(registry) || XDR(offer)).",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "version",
    "service_id",
    "registry",
    "terms_hash",
    "price",
    "asset",
    "max_claim",
    "valid_until",
    "offer_nonce",
    "key_version"
  ],
  "properties": {
    "version": {
      "type": "integer",
      "minimum": 0,
      "maximum": 4294967295,
      "description": "Protocol version, 1",
      "const": 1
    },
    "service_id": {
      "type": "string",
      "pattern": "^[0-9a-f]{64}$",
      "description": "Assigned by the Bond Registry at registration: SHA-256(XDR(registry address) || XDR(counter))"
    },
    "registry": {
      "type": "string",
      "pattern": "^[GC][A-Z2-7]{55}$",
      "description": "Bond Registry contract that holds the stake"
    },
    "terms_hash": {
      "type": "string",
      "pattern": "^[0-9a-f]{64}$",
      "description": "Hash of the registered terms the buyer pays under"
    },
    "price": {
      "type": "string",
      "pattern": "^-?[0-9]+$",
      "description": "Price of this call, in the asset's smallest unit"
    },
    "asset": {
      "type": "string",
      "pattern": "^[GC][A-Z2-7]{55}$",
      "description": "Token contract of the payment asset"
    },
    "max_claim": {
      "type": "string",
      "pattern": "^-?[0-9]+$",
      "description": "Most a single receipt can pay out"
    },
    "valid_until": {
      "type": "integer",
      "minimum": 0,
      "maximum": 18446744073709551615,
      "description": "Unix seconds after which the offer must not be paid"
    },
    "offer_nonce": {
      "type": "string",
      "pattern": "^[0-9a-f]{64}$",
      "description": "Random, unique per offer"
    },
    "key_version": {
      "type": "integer",
      "minimum": 0,
      "maximum": 4294967295,
      "description": "Which registered signing key signed this offer"
    }
  },
  "$defs": {
    "SignedOffer": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "offer",
        "signature"
      ],
      "properties": {
        "offer": {
          "$ref": "#"
        },
        "signature": {
          "type": "string",
          "pattern": "^[0-9a-f]{128}$",
          "description": "Ed25519 signature over offer_hash by the service signing key"
        }
      },
      "description": "Rust: lopw_types::SignedOffer. On the wire it travels as base64 ScVal XDR in PaymentRequired.extensions.lopw.info.offer"
    }
  }
}
