Skip to main content

Overview

BlockHash is a branded Uint8Array type representing a 32-byte block identifier in Ethereum. Every block has a unique hash computed from its header.

Type Definition

Creating BlockHashes

from

Universal constructor accepting hex string or bytes.

fromHex

Parse from hex string (with or without 0x prefix).
Validation: Must be 64 hex characters (32 bytes).

fromBytes

Create from Uint8Array.
Validation: Must be exactly 32 bytes.

Converting BlockHashes

toHex

Convert to lowercase hex string with 0x prefix.

Comparing BlockHashes

equals

Check equality using constant-time byte comparison.

Errors

InvalidBlockHashLengthError: Bytes length is not 32. InvalidBlockHashFormatError: Invalid hex format or unsupported type.

See Also