{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://evidence.contact/earn.schema.json",
  "title": "402Mob public earning invitation",
  "description": "Discovery metadata for earning paths; not a purchasable offer, funded job or payment authorization.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "$schema",
    "protocol",
    "kind",
    "status",
    "updatedAt",
    "title",
    "description",
    "guide",
    "access",
    "merchantPayments",
    "paths",
    "entryPoints",
    "projectWork",
    "boundaries"
  ],
  "properties": {
    "$schema": {
      "const": "https://evidence.contact/earn.schema.json"
    },
    "protocol": {
      "const": "402mob.earning-invitation.v1"
    },
    "kind": {
      "const": "earning_invitation"
    },
    "status": {
      "const": "open_invitation"
    },
    "updatedAt": {
      "type": "string",
      "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$"
    },
    "title": {
      "$ref": "#/$defs/text"
    },
    "description": {
      "$ref": "#/$defs/text"
    },
    "guide": {
      "$ref": "#/$defs/url"
    },
    "access": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "paymentRequired",
        "authenticationRequired"
      ],
      "properties": {
        "paymentRequired": {
          "const": false
        },
        "authenticationRequired": {
          "const": false
        }
      }
    },
    "merchantPayments": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "network",
        "asset",
        "currency",
        "recipient",
        "platformFee",
        "enrollmentFee",
        "priceSetBy",
        "custody"
      ],
      "properties": {
        "network": {
          "const": "eip155:8453"
        },
        "asset": {
          "const": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
        },
        "currency": {
          "const": "USDC"
        },
        "recipient": {
          "const": "enrolled_seller_wallet"
        },
        "platformFee": {
          "const": "none"
        },
        "enrollmentFee": {
          "const": "none"
        },
        "priceSetBy": {
          "const": "seller"
        },
        "custody": {
          "const": "none"
        }
      }
    },
    "paths": {
      "type": "array",
      "minItems": 1,
      "maxItems": 4,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "status",
          "payer",
          "deliverable",
          "paymentTrigger",
          "guide",
          "validation"
        ],
        "properties": {
          "id": {
            "enum": [
              "prepared_artifact",
              "buyer_request",
              "work_ticket",
              "dated_editions"
            ]
          },
          "status": {
            "const": "available"
          },
          "payer": {
            "const": "buyer"
          },
          "deliverable": {
            "$ref": "#/$defs/text"
          },
          "paymentTrigger": {
            "$ref": "#/$defs/text"
          },
          "guide": {
            "$ref": "#/$defs/url"
          },
          "validation": {
            "$ref": "#/$defs/text"
          }
        }
      }
    },
    "entryPoints": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "demand",
        "board",
        "capabilities",
        "openapi",
        "walletRecipe",
        "merchantGuide",
        "hostedMcp"
      ],
      "properties": {
        "demand": {
          "$ref": "#/$defs/url"
        },
        "board": {
          "$ref": "#/$defs/url"
        },
        "capabilities": {
          "$ref": "#/$defs/url"
        },
        "openapi": {
          "$ref": "#/$defs/url"
        },
        "walletRecipe": {
          "$ref": "#/$defs/url"
        },
        "merchantGuide": {
          "$ref": "#/$defs/url"
        },
        "hostedMcp": {
          "$ref": "#/$defs/url"
        },
        "workers": {
          "$ref": "#/$defs/url"
        },
        "workerGuide": {
          "$ref": "#/$defs/url"
        }
      }
    },
    "projectWork": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "status",
        "budgetAllocated",
        "budgetAtomic",
        "agreementRequiredBeforeWork",
        "roles",
        "proposalTo",
        "proposalFields",
        "paymentTerms"
      ],
      "properties": {
        "status": {
          "const": "proposal_only"
        },
        "budgetAllocated": {
          "const": false
        },
        "budgetAtomic": {
          "type": "null"
        },
        "agreementRequiredBeforeWork": {
          "const": true
        },
        "roles": {
          "type": "array",
          "minItems": 1,
          "uniqueItems": true,
          "items": {
            "enum": [
              "integration",
              "verification",
              "resource_maintenance",
              "demand_qualification"
            ]
          }
        },
        "proposalTo": {
          "type": "string",
          "pattern": "^mailto:contact@evidence\\.contact(?:\\?|$)"
        },
        "proposalFields": {
          "type": "array",
          "minItems": 1,
          "uniqueItems": true,
          "items": {
            "$ref": "#/$defs/text"
          }
        },
        "paymentTerms": {
          "$ref": "#/$defs/text"
        }
      }
    },
    "boundaries": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "guaranteedIncome",
        "escrow",
        "refundsProvidedByPlatform",
        "automaticMatching",
        "automaticSubscriptions",
        "qualityCertification",
        "selectionIsPayment",
        "requestBudgetProvesFunding",
        "settledRevenueEvidence",
        "reporting"
      ],
      "properties": {
        "guaranteedIncome": {
          "const": false
        },
        "escrow": {
          "const": false
        },
        "refundsProvidedByPlatform": {
          "const": false
        },
        "automaticMatching": {
          "const": false
        },
        "automaticSubscriptions": {
          "const": false
        },
        "qualityCertification": {
          "const": false
        },
        "selectionIsPayment": {
          "const": false
        },
        "requestBudgetProvesFunding": {
          "const": false
        },
        "settledRevenueEvidence": {
          "$ref": "#/$defs/text"
        },
        "reporting": {
          "$ref": "#/$defs/text"
        }
      }
    }
  },
  "$defs": {
    "text": {
      "type": "string",
      "minLength": 1
    },
    "url": {
      "type": "string",
      "pattern": "^https://evidence\\.contact/"
    }
  }
}
