Skip to main content

Create and Validate a Block

Create one ALX Block from JSON content and validate both deterministic identities. A successful validation confirms that the content and declared parent set produce the recorded contentHash and blockHash.

Before You Start

Use Node.js 20 or later and the published @alx-protocol/sdk package. No account, API key, network connection, smart contract, blockchain, or production data is required.

Workflow

  1. Create a Block from JSON content and an empty parent set.
  2. Inspect the generated contentHash and blockHash.
  3. Run validateBlock() to recompute and compare both deterministic identities.
  4. Modify the content, contentHash, blockHash, or parent set.
  5. Run validateBlock() again and confirm that validation fails.

What Validation Confirms

validateBlock() performs local Block validation.

A successful result confirms that:

  • contentHash matches the canonicalized content.
  • blockHash matches the canonicalized content and normalized parent set.
  • The Block satisfies protocol validation requirements.

Validation uses only protocol data. Any conforming implementation produces equivalent validation results from equivalent protocol inputs.

Use Node.js 20 or later and install the package from npm.

Install the package:

npm i @alx-protocol/sdk

Dependency installation may require package-registry access. After installation, Block creation and validation run locally without credentials or a network connection.

Continue with the protocol rules for Block structure, Block identity, canonicalization, and validation.