Skip to main content

Block

A Block assigns deterministic identity to JSON-serializable content and records declared relationships to parent Blocks. Applications can identify, compare, verify, store, and compose Blocks without ALX interpreting the application-defined content.

Block Model

Every Block contains four required protocol fields.

type Block = {
blockHash: string;
contentHash: string;
parentHashes: string[];
content: unknown;
};
FieldDescription
contentJSON-serializable application data. ALX treats the value as opaque.
parentHashesNormalized, deduplicated, lexicographically sorted identities of declared parent Blocks.
contentHashDeterministic identity derived from canonicalized content.
blockHashDeterministic identity derived from canonicalized content and the normalized declared parent set.

Block Identity

ALX canonicalizes content, normalizes parentHashes, and derives two deterministic identities using Keccak-256.

contentHash identifies the canonicalized content independently of lineage. blockHash binds that content to its normalized declared parent set.

The same content therefore produces the same contentHash while allowing different declared parent sets to produce different blockHash values.

validateBlock() repeats canonicalization, parent normalization, and hash derivation before comparing the derived identities with the recorded values.

Block Invariants

A conforming implementation guarantees:

  • Equivalent supported content produces equivalent contentHash values.
  • Equivalent content and normalized parent sets produce equivalent blockHash values.
  • Parent order does not affect Block identity.
  • Duplicate parent hashes do not affect the normalized parent set.
  • null and undefined canonicalize as null where defined by the canonicalization rules.
  • Parent hashes must satisfy the protocol-defined format.
  • Declared parent relationships are never silently omitted during Block creation.

Parent Normalization

Before deriving blockHash, ALX normalizes parentHashes in a deterministic sequence:

  1. Treats an omitted value as an empty array.
  2. Requires an array of strings.
  3. Trims whitespace.
  4. Converts values to lowercase.
  5. Validates 0x-prefixed 32-byte hashes.
  6. Removes duplicates.
  7. Sorts the final parent set lexicographically.

Because normalization occurs before identity derivation, equivalent parent sets produce the same blockHash regardless of input order, casing, surrounding whitespace, or duplicate entries.

When to Create a Block

Create a Block when JSON-serializable content requires one or more of the following:

  • Deterministic identity
  • Declared lineage
  • Independent verification
  • Composition with other Blocks

A Block with an empty parent set is a root Block. A Block with one or more declared parents becomes connected to prior Blocks, allowing applications and intelligent systems to construct derivation graphs from those relationships.