Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.xandrlabs.ai/llms.txt

Use this file to discover all available pages before exploring further.

@alx/protocol is the TypeScript reference implementation of ALX Protocol. It exports the canonicalization functions, hash utilities, and registry ABI you need to compute Knowledge Block identities, verify artifacts, and interact with the on-chain registry. This page walks you through installing the package, confirming your environment, and running a smoke test.
@alx/protocol requires Node.js 20 (>=20 <21). Using a different major version may produce environment-specific behavior that breaks conformance with protocol test vectors.

Install the package

Choose your package manager and run the corresponding command.
npm install @alx/protocol

Import the core exports

After installing, import the functions you need from @alx/protocol. The three most commonly used exports are:
  • canonicalize — serializes any value to deterministic RFC 8785 / JCS JSON
  • kbHashFromEnvelope — derives the domain-separated kbHash from a Knowledge Block envelope
  • REGISTRY_ABI — the ABI for the on-chain registry contract, used with ethers or viem
import { canonicalize, kbHashFromEnvelope, REGISTRY_ABI } from "@alx/protocol";
The package uses ES module syntax ("type": "module"). If your project uses CommonJS, configure your bundler or transpiler to handle ESM dependencies before importing.

Verify your setup

Run the following smoke test to confirm the package is installed correctly and that canonicalization works as expected in your environment.
import { canonicalize } from "@alx/protocol";

const artifact = {
  type: "Practice",
  domain: "engineering.auth.jwt",
  summary: "Rotate signing keys every 90 days."
};

const canonical = canonicalize(artifact);
console.log(canonical);
// {"domain":"engineering.auth.jwt","summary":"Rotate signing keys every 90 days.","type":"Practice"}
The output is a deterministic JSON string with keys sorted alphabetically. If you see this output, your installation is working correctly.

Next steps

1

Compute a Knowledge Block identity

Use kbHashFromEnvelope to derive a kbHash from a full KB envelope. See the compute identity guide for the complete envelope structure and requirements.
2

Publish on-chain

Register your Knowledge Block in the Base mainnet registry using REGISTRY_ABI and ethers. See the publish on-chain guide.
3

Verify an artifact

Confirm that a retrieved artifact matches its published cryptographic commitment. See the verify artifact guide.
The registry contract is deployed on Base mainnet (chain ID 8453) at 0xD1F216E872a9ed4b90E364825869c2F377155B29. Publishing a Knowledge Block requires a minimum stake of 0.001 ETH.