JavaScript Reference Surface
@alx-protocol/sdk exposes the helpers used to create, connect, validate, sign, and verify ALX data. The reference groups the current root exports by protocol task and names the subpaths that carry the rest.
How the Package Is Organized
The root export covers canonicalization, Block identity, graph validation, attribution tracing, signed Blocks, replay checks, hash utilities, and error codes. The same helpers are also reachable through task-specific subpaths (/block, /lineage, /trace, /canonicalization, /signatures, /replay, /hash-utils), and Merkle helpers and the signing suites live only on their subpaths (/merkle, /ed25519, /p256, /eip712, /middleware).
When to Use This Reference
Use this page after choosing a protocol task and before importing a helper. The conceptual and guide pages explain the expected inputs and verification boundaries behind each export.
- Canonicalization and Identity Constants
- Block Exports
- Graph and Trace Exports
- Signed Blocks and Signing Suites
- Replay, Errors, and Byte Helpers
- Merkle Subpath
Serialize protocol JSON the one canonical way, and read the domains and version the hashes bind.
- Serialization:
canonicalizeProtocolJson,parseStrictJson,parseStrictJsonBytes - Constants:
CANONICALIZATION_ALGORITHM,ALX_PROTOCOL_VERSION,BLOCK_HASH_DOMAIN,CONTENT_HASH_DOMAIN,ATTESTATION_HASH_DOMAIN,MAX_PARENTS,HASH_PATTERN.
Create Blocks, derive both identities, normalize parent hashes, and validate a stored Block.
- Creation and identity:
createBlock,lock,deriveBlockHash,deriveContentHash - Validation:
validateBlock - Normalization:
normalizeHash,normalizeHashes,normalizeHashLenient,sanitizeImportedParentHashes,compareHashesConstantTime.
Build and validate lineage graphs, then trace attribution through declared parents.
- Graphs:
buildGraph,addBlockToGraph,validateGraph,validateGraphStructure,validateIncrementalBlock,validateLineage,verifyGraph - Traces:
traceAttribution,verifyTrace.
The /lineage and /trace subpaths export the same helpers for narrower imports.
Attach attestations to Blocks and verify them with Ed25519, P-256, or EIP-712.
- Signed Blocks:
createSignedBlock,validateSignedBlock,signBlock,verifyBlockSignature,addAttestation,deriveAttestationDigest,BLOCK_ATTESTATION_TYPES - Signers and verifiers:
Ed25519Signer,Ed25519Verifier,P256Signer,P256Verifier,Eip712Signer,Eip712Verifier(EIP-712 requires theetherspeer dependency) - Typed payloads:
buildProtocolSigningDomain,normalizeSignedProtocolPayload,verifySignedProtocolPayload,PROTOCOL_SIGNED_REQUEST_TYPES,PROTOCOL_SIGNING_DOMAIN_NAME,PROTOCOL_SIGNING_DOMAIN_VERSION.
An attestation stays outside Block identity: signing a Block does not change its blockHash.
Bound repeated requests, read typed error codes, and move between hex and bytes.
- Replay:
buildReplayScopeKey,validateReplayWindow - Errors:
ErrorCode,protocolError(every code is prefixedALX_) - Bytes:
bytesToHex,hexToBytes,concatBytes.
Build sorted-pair Merkle trees and verify inclusion proofs for commitment workflows.
@alx-protocol/sdk/merkle exports buildMerkleTree, getMerkleProof, and verifyMerkleProof. Merkle root hashes are an optional extension for commitments; they do not change Block identity.