> ## Documentation Index
> Fetch the complete documentation index at: https://docs.threadify.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Hash Chain

> Cryptographically verified ordering and integrity for threads

The **Hash Chain** is a cryptographic verification system that ensures the integrity and ordering of steps in a thread. Each step contains a hash that links to the previous step, creating an immutable audit trail.

### Hash Properties

* **Tamper-proof** - Any modification breaks the chain
* **Ordered** - Ensures steps execute in correct sequence
* **Verifiable** - Chain integrity can be checked

Each step contains:

* **hash** - Current step's cryptographic hash
* **prevHash** - Previous step's hash (null for first step)

### Chain Verification

<Tabs>
  <Tab title="Node.js">
    ```javascript theme={null}
    // Verify hash chain integrity
    const archivedThread = await threadify.getThread('thread-uuid');
    const steps = await archivedThread.steps();

    for (const step of steps) {
      if (step.verified) {
        console.log(`${step.stepName}: Verified ✓`);
      } else {
        console.error(`${step.stepName}: Chain broken`);
      }
    }
    ```
  </Tab>

  <Tab title="Go">
    ```go theme={null}
    // Verify hash chain integrity
    archivedThread, err := conn.GetThread(ctx, "thread-uuid")
    if err != nil {
        log.Fatal(err)
    }

    steps, err := archivedThread.Steps(ctx)
    if err != nil {
        log.Fatal(err)
    }

    for _, step := range steps {
        if step.Verified {
            log.Printf("%s: Verified ✓", step.StepName)
        } else {
            log.Printf("%s: Chain broken", step.StepName)
        }
    }
    ```
  </Tab>

  <Tab title="Python">
    ```python theme={null}
    # Verify hash chain integrity
    archived_thread = await conn.get_thread("thread-uuid")
    steps = await archived_thread.steps()

    for step in steps:
        if step.verified:
            print(f"{step.step_name}: Verified ✓")
        else:
            print(f"{step.step_name}: Chain broken")
    ```
  </Tab>
</Tabs>

### Benefits

* **Integrity** - Detects any modification to step data
* **Ordering** - Ensures steps execute in correct sequence
* **Audit Trail** - Immutable record of execution
* **Trust** - Cryptographic proof of execution

### Use Cases

* **Compliance** - Regulated industries need audit trails
* **Dispute Resolution** - Prove what actually happened
* **Security** - Detect unauthorized modifications
* **Debugging** - Identify where execution went wrong
