Skip to main content
FactRequest represents a request to add a fact (state change) to an existing subject in the TAPLE network. Facts are events that modify the state of a subject according to its schema and governance rules.

Fields

subject_id
DigestIdentifier
required
The identifier of the subject to which the fact will be added. This subject must already exist in the network.
payload
ValueWrapper
required
The payload of the fact to be added. This contains the data that will trigger a state change in the subject. The payload must conform to the schema defined for the subject.

Usage Example

use taple_core::{
    EventRequest, FactRequest,
    DigestIdentifier, ValueWrapper
};
use serde_json::json;

// Add a temperature reading to a sensor subject
let fact_request = EventRequest::Fact(FactRequest {
    subject_id: DigestIdentifier::from_str(
        "JXtZRpNgBWVg9v5YG9AaTNfCpPd-rCTTKrFW9cV8-JKs"
    ).unwrap(),
    payload: ValueWrapper(json!({
        "temperature": 23.5,
        "timestamp": "2024-03-15T10:30:00Z"
    })),
});

// Add a transfer record to a supply chain subject
let transfer_fact = EventRequest::Fact(FactRequest {
    subject_id: subject_id.clone(),
    payload: ValueWrapper(json!({
        "action": "transfer",
        "from": "warehouse_a",
        "to": "warehouse_b",
        "quantity": 100
    })),
});

Notes

  • FactRequest is wrapped in the EventRequest::Fact variant
  • Requires evaluation and approval: Unlike other request types, fact requests must be evaluated by the governance contract and may require approval from designated approvers
  • The payload structure must match the schema defined for the subject
  • The governance contract’s evaluation logic will process the payload and generate a state patch
  • The subject’s state will be updated by applying the generated patch
  • Each successful fact increments the subject’s sequence number (sn)

Evaluation Process

  1. The fact request is submitted to the network
  2. The governance contract’s evaluation logic is executed with the current state and the payload
  3. The evaluator generates a patch representing the state changes
  4. If required by governance rules, the request goes through an approval process
  5. Once approved, the patch is applied to the subject’s state
  6. A new event is created and added to the subject’s event chain

Build docs developers (and LLMs) love