{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/assetfare/json-schema/assetfare-unsigned-action-bundle-schema.json",
  "title": "UnsignedActionBundle",
  "x-generated": "2026-10-29",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/assetfare-capabilities-api-openapi.yml#/components/schemas/UnsignedActionBundle",
  "additionalProperties": true,
  "properties": {
    "action_id": {
      "format": "uuid",
      "type": "string"
    },
    "expires_at": {
      "format": "date-time",
      "type": "string"
    },
    "payload_sha256": {
      "pattern": "^[0-9a-f]{64}$",
      "type": "string"
    },
    "server_signing": {
      "const": false
    },
    "server_submission": {
      "const": false
    },
    "signed": {
      "const": false
    },
    "step_index": {
      "minimum": 0,
      "type": "integer"
    },
    "submitted": {
      "const": false
    },
    "unsigned_action": {
      "$ref": "#/$defs/UnsignedAction"
    },
    "workflow_id": {
      "format": "uuid",
      "type": "string"
    }
  },
  "required": [
    "workflow_id",
    "action_id",
    "step_index",
    "expires_at",
    "unsigned_action",
    "payload_sha256",
    "server_signing",
    "server_submission",
    "signed",
    "submitted"
  ],
  "type": "object",
  "$defs": {
    "ActionSafetyReceiptV1": {
      "additionalProperties": false,
      "description": "Deterministically recomputed from decoded/raw unsigned action data. This is a consistency receipt, not a signature or a subjective safe=true claim.",
      "properties": {
        "action": {
          "additionalProperties": false,
          "properties": {
            "builder_version": {
              "type": [
                "string",
                "null"
              ]
            },
            "kind": {
              "enum": [
                "evm_dex",
                "solana_dex",
                "evm_cctp",
                "evm_cctp_receive",
                "solana_cctp",
                "aptos_cctp",
                "evm_layerzero",
                "solana_layerzero",
                "evm_across"
              ]
            },
            "provider": {
              "type": "string"
            }
          },
          "required": [
            "kind",
            "provider",
            "builder_version"
          ],
          "type": "object"
        },
        "approval": {
          "additionalProperties": false,
          "properties": {
            "exact_allowance_base": {
              "pattern": "^[0-9]+$",
              "type": [
                "string",
                "null"
              ]
            },
            "required": {
              "type": "boolean"
            },
            "target": {
              "type": [
                "string",
                "null"
              ]
            },
            "token": {
              "type": [
                "string",
                "null"
              ]
            },
            "transaction_index": {
              "minimum": 0,
              "type": "integer"
            }
          },
          "required": [
            "required",
            "token",
            "target",
            "exact_allowance_base"
          ],
          "type": "object"
        },
        "assetfare_service_fee": {
          "additionalProperties": false,
          "properties": {
            "amount_known_before_execution": {
              "type": "boolean"
            },
            "basis": {
              "additionalProperties": false,
              "properties": {
                "amount_base": {
                  "pattern": "^[0-9]+$",
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "kind": {
                  "type": "string"
                }
              },
              "required": [
                "kind",
                "amount_base"
              ],
              "type": "object"
            },
            "bps": {
              "maximum": 1,
              "minimum": 0,
              "type": "integer"
            },
            "exact_amount_base": {
              "pattern": "^[0-9]+$",
              "type": [
                "string",
                "null"
              ]
            },
            "formula": {
              "const": "floor(fee_basis_base * bps / 10000)"
            },
            "recipient": {
              "type": [
                "string",
                "null"
              ]
            }
          },
          "required": [
            "basis",
            "bps",
            "formula",
            "exact_amount_base",
            "amount_known_before_execution",
            "recipient"
          ],
          "type": "object"
        },
        "custody": {
          "additionalProperties": false,
          "properties": {
            "server_signing": {
              "const": false
            },
            "server_submission": {
              "const": false
            }
          },
          "required": [
            "server_signing",
            "server_submission"
          ],
          "type": "object"
        },
        "destination": {
          "additionalProperties": false,
          "properties": {
            "domain": {
              "type": [
                "integer",
                "string",
                "null"
              ]
            },
            "recipient": {
              "type": [
                "string",
                "null"
              ]
            }
          },
          "required": [
            "recipient",
            "domain"
          ],
          "type": "object"
        },
        "generation": {
          "const": "decoded_built_action_only"
        },
        "native_value_cap": {
          "additionalProperties": false,
          "properties": {
            "maximum_base": {
              "pattern": "^[0-9]+$",
              "type": "string"
            },
            "per_transaction_base": {
              "items": {
                "pattern": "^[0-9]+$",
                "type": "string"
              },
              "type": "array"
            },
            "unit": {
              "enum": [
                "wei",
                "lamports",
                "octas"
              ]
            }
          },
          "required": [
            "maximum_base",
            "unit",
            "per_transaction_base"
          ],
          "type": "object"
        },
        "network": {
          "additionalProperties": false,
          "properties": {
            "destination_chain": {
              "type": "string"
            },
            "source_chain": {
              "type": "string"
            },
            "source_chain_id": {
              "type": [
                "integer",
                "string"
              ]
            }
          },
          "required": [
            "source_chain",
            "source_chain_id",
            "destination_chain"
          ],
          "type": "object"
        },
        "parties": {
          "additionalProperties": false,
          "properties": {
            "caller": {
              "type": "string"
            },
            "fee_payer": {
              "type": "string"
            }
          },
          "required": [
            "caller",
            "fee_payer"
          ],
          "type": "object"
        },
        "payload_binding": {
          "additionalProperties": false,
          "properties": {
            "action_sha256": {
              "pattern": "^[0-9a-f]{64}$",
              "type": "string"
            },
            "canonicalization": {
              "const": "UTF-8 JSON sorted keys compact separators; omit safety_receipt"
            },
            "raw_payloads": {
              "items": {
                "additionalProperties": false,
                "properties": {
                  "chain_id": {
                    "minimum": 1,
                    "type": "integer"
                  },
                  "data_prefix_hex": {
                    "pattern": "^[0-9a-f]*$",
                    "type": "string"
                  },
                  "data_sha256": {
                    "pattern": "^[0-9a-f]{64}$",
                    "type": "string"
                  },
                  "index": {
                    "minimum": 0,
                    "type": "integer"
                  },
                  "instruction_type": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "kind": {
                    "enum": [
                      "evm_transaction",
                      "solana_instruction",
                      "aptos_raw_transaction"
                    ]
                  },
                  "native_value_base": {
                    "pattern": "^[0-9]+$",
                    "type": "string"
                  },
                  "program_id": {
                    "type": "string"
                  },
                  "raw_sha256": {
                    "pattern": "^[0-9a-f]{64}$",
                    "type": "string"
                  },
                  "selector": {
                    "type": "string"
                  },
                  "target": {
                    "type": "string"
                  }
                },
                "required": [
                  "index",
                  "kind",
                  "raw_sha256",
                  "data_sha256"
                ],
                "type": "object"
              },
              "minItems": 1,
              "type": "array"
            }
          },
          "required": [
            "canonicalization",
            "action_sha256",
            "raw_payloads"
          ],
          "type": "object"
        },
        "receive": {
          "additionalProperties": false,
          "properties": {
            "expected_amount_base": {
              "pattern": "^[0-9]+$",
              "type": [
                "string",
                "null"
              ]
            },
            "minimum_amount_base": {
              "pattern": "^[0-9]+$",
              "type": "string"
            },
            "token": {
              "additionalProperties": false,
              "properties": {
                "address_or_mint": {
                  "type": "string"
                },
                "symbol": {
                  "type": "string"
                }
              },
              "required": [
                "symbol",
                "address_or_mint"
              ],
              "type": "object"
            }
          },
          "required": [
            "token",
            "expected_amount_base",
            "minimum_amount_base"
          ],
          "type": "object"
        },
        "risks": {
          "additionalProperties": false,
          "properties": {
            "caller_verification_required": {
              "const": true
            },
            "provider": {
              "items": {
                "type": "string"
              },
              "minItems": 1,
              "type": "array"
            },
            "unpriced": {
              "items": {
                "type": "string"
              },
              "minItems": 1,
              "type": "array"
            }
          },
          "required": [
            "unpriced",
            "provider",
            "caller_verification_required"
          ],
          "type": "object"
        },
        "schema": {
          "const": "https://assetfare.dev/schemas/action-safety-receipt-v1"
        },
        "schema_version": {
          "const": 1
        },
        "selector_or_instruction_allowlist": {
          "items": {
            "type": "string"
          },
          "minItems": 1,
          "type": "array",
          "uniqueItems": true
        },
        "spend": {
          "additionalProperties": false,
          "properties": {
            "exact_amount_base": {
              "pattern": "^[0-9]+$",
              "type": "string"
            },
            "maximum_amount_base": {
              "pattern": "^[0-9]+$",
              "type": "string"
            },
            "token": {
              "additionalProperties": false,
              "properties": {
                "address_or_mint": {
                  "type": "string"
                },
                "symbol": {
                  "type": "string"
                }
              },
              "required": [
                "symbol",
                "address_or_mint"
              ],
              "type": "object"
            }
          },
          "required": [
            "token",
            "exact_amount_base",
            "maximum_amount_base"
          ],
          "type": "object"
        },
        "target_or_program_allowlist": {
          "items": {
            "type": "string"
          },
          "minItems": 1,
          "type": "array",
          "uniqueItems": true
        },
        "timing": {
          "additionalProperties": false,
          "properties": {
            "action_deadline_unix": {
              "type": [
                "integer",
                "null"
              ]
            },
            "bundle_expires_at": {
              "format": "date-time",
              "type": [
                "string",
                "null"
              ]
            },
            "quote_expiry_unix": {
              "type": [
                "integer",
                "null"
              ]
            },
            "recent_blockhash": {
              "type": [
                "string",
                "null"
              ]
            }
          },
          "required": [
            "action_deadline_unix",
            "quote_expiry_unix",
            "recent_blockhash",
            "bundle_expires_at"
          ],
          "type": "object"
        }
      },
      "required": [
        "schema",
        "schema_version",
        "generation",
        "network",
        "action",
        "parties",
        "spend",
        "approval",
        "target_or_program_allowlist",
        "selector_or_instruction_allowlist",
        "native_value_cap",
        "assetfare_service_fee",
        "receive",
        "destination",
        "timing",
        "payload_binding",
        "custody",
        "risks"
      ],
      "type": "object"
    },
    "UnsignedAction": {
      "additionalProperties": true,
      "properties": {
        "safety_receipt": {
          "$ref": "#/$defs/ActionSafetyReceiptV1"
        },
        "serverSigning": {
          "const": false
        },
        "serverSubmission": {
          "const": false
        },
        "signed": {
          "const": false
        },
        "submitted": {
          "const": false
        }
      },
      "required": [
        "safety_receipt",
        "signed",
        "submitted"
      ],
      "type": "object"
    }
  }
}