Distribute, Commit, and Verify a Block
Create and validate a Block first. Add IPFS distribution or blockchain commitment evidence when the application requires distribution or public commitment records.
Neither optional layer changes the Block identity or declared lineage. No supported public ALX EVM deployment is currently published.
1. Create and Validate Locally
Install the package as shown in Quick Start. Create prepare-block.mjs in the project:
import {writeFile} from 'node:fs/promises';
import {createBlock, validateBlock} from '@alx-protocol/sdk';
const block = createBlock(
{type: 'research-note', text: 'A reproducible ALX example'},
[],
);
const result = validateBlock(block);
if (!result.ok) throw new Error('Block validation failed');
await writeFile('research.block.json', `${JSON.stringify(block, null, 2)}\n`);
console.log(block.blockHash);
Run the script:
node prepare-block.mjs
Keep the printed blockHash. The Block retains the same ALX identity whether stored locally or distributed elsewhere.
2. Optionally Distribute Through IPFS
The current repository does not provide an IPFS publishing CLI, gateway resolver, Kubo adapter, or CID mapping store. An application that chooses IPFS must use an application-controlled IPFS client to publish research.block.json, retain the resulting CID with the expected blockHash, and arrange pinning when availability matters.
When the application retrieves bytes from a gateway or node, parse the Block and validate it locally:
import {readFile} from 'node:fs/promises';
import {validateBlock} from '@alx-protocol/sdk';
const serializedBlock = await readFile('retrieved.block.json', 'utf8');
const retrievedBlock = JSON.parse(serializedBlock);
const result = validateBlock(retrievedBlock);
if (!result.ok) throw new Error('Retrieved Block validation failed');
console.log(result.blockHash.recomputed);
The CID identifies raw file bytes for retrieval; the recomputed blockHash identifies the ALX Block. Availability still depends on a node or pinning service keeping the content available.
3. Optionally Commit Evidence
Commit either one blockHash or a Merkle root hash representing multiple Block hashes when the application requires a public record of that deterministic value.
The repository includes the ALXAnchor reference contract, deployment tooling, tests, and an ABI for local evaluation. Independent security review and a supported public deployment remain pending. Do not configure a network or contract address from this guide. Before integrating a deployment, verify the source, build evidence, transaction record, ABI, and deployment manifest for the selected address.
A commitment establishes that the specified value was recorded at a blockchain position. The record does not establish ownership, authorship, correctness, approval, persistence, or availability of the underlying Block content.
4. Verify the Right Claim
| Question | Verify with | What a successful result establishes |
|---|---|---|
| Is the supplied Block internally consistent? | validateBlock() | The recorded identities match the Block content and declared parents. |
| Did retrieved bytes match the expected Block? | Local validateBlock() | The retrieved Block recomputes to the recorded blockHash; the application compares the recomputed value with the expected Block identity. |
| Is a Block hash in a committed batch? | A Merkle inclusion proof | The hash is included in the supplied Merkle root hash. |
| Was the supplied Merkle root hash recorded onchain? | Reviewed deployment and transaction evidence | The specified value was recorded at the selected chain position. |
For an off-chain Merkle example, follow Verify Commitment Inclusion. For deployment readiness, see Deployment Requirements.
When to Use This Workflow
Use the distribution and commitment workflow when an application needs to share serialized Block data outside application-controlled storage, preserve commitment evidence for a Block hash, or evaluate Block, retrieval, inclusion, and onchain-record claims. Validate each Block locally before evaluating distribution or commitment evidence.