Introduction

Hi, I'm cardene, a software engineer and technical writer focused on blockchain and AI.

I've also authored Japanese technical books on specification-driven development with LLMs and decentralized application (DApp) development.

I also build and publish a variety of tools, libraries, and open-source projects.

ERC-8326 defines a way to derive the same bytes32 value from a bundle of contract and certificate files and track that value on Ethereum. Instead of submitting the files themselves on-chain, it records only the result of hashing their contents and roles according to a specified format.

As of August 2, 2026, ERC-8326 was in Review status. Consult the latest specification before deciding whether to implement or adopt it.

https://raw.githubusercontent.com/ethereum/ERCs/master/ERCS/erc-8326.md

Overview

Suppose several parties hold a contract PDF, JSON certificates, and supporting documents. Even when the files look identical, differences in filename casing, JSON key order, or registration order can produce different hashes under a naive hashing scheme.

ERC-8326 therefore combines not only the contents of each file, but also its purpose, format, name, and normalization method into a single value. This value is called the bundleHash.

The bundleHash lets a verifier recompute the value to check whether a particular set of files and their descriptions match. It does not establish the authenticity or legal validity of those files, who created them, or whether they are retrievable.

Motivation

Why commit to a bundle rather than individual files?

A single contract may include an agreement, identity verification certificates, and amendments. If only individual file hashes are stored, separate conventions are needed to track which files belong to the same contract and which file is the primary agreement.

ERC-8326 hashes the entire collection as a single bundle. Because the same inputs always produce the same bundleHash, users can recompute it from the files they possess and compare it with the on-chain value.

Flow for hashing multiple contract and certificate files and combining them in a specified order into a bundleHash

The recipient first normalizes the contents according to the specified method. They then hash each file's information and arrange the entries in the prescribed order. Defining that order ensures that the same collection produces the same bundleHash even when the files are supplied in a different order.

Specification

Five values recorded for each file

ERC-8326 represents each file as a DocumentEntry. A file entry represents more than its contents. Even identical contents produce distinct entries when used as an agreement and as evidence.

js
struct DocumentEntry {
    bytes32 contentHash;
    bytes32 role;
    bytes32 mimeTypeHash;
    bytes32 filenameHash;
    bytes32 normProfileId;
}
Field Value What it distinguishes
contentHash keccak256 hash of the normalized contents File contents
role Hash of the role name Roles such as agreement, evidence, or certification
mimeTypeHash Hash of the lowercase MIME type with parameters removed application/json or application/pdf
filenameHash Hash of the normalized filename Filename
normProfileId Hash of the normalization method identifier The procedure used to normalize the contents

Predefined role values include AGREEMENT, EVIDENCE, CERTIFICATION, and AMENDMENT. Applications can also define their own roles, but they publish values that include a namespace and version to avoid accidental semantic collisions.

The filename is also a hash input

The filenameHash uses the filename without its path. ASCII uppercase letters are converted to lowercase, and the resulting UTF-8 bytes are normalized to Unicode NFC before hashing.

For example, records/Café.JSON becomes café.json after removing the path, lowercasing ASCII letters, and normalizing combining characters with NFC. Without this process, visually identical names could produce different hashes in different environments.

This process does not treat uppercase and lowercase letters as equivalent across all of Unicode. For non-ASCII characters, it does not introduce additional equivalences beyond the NFC normalization specified by the standard.

Normalizing contents before hashing

In some cases, hashing a file's bytes directly is sufficient. For JSON and XML, however, different key or attribute orders can produce different byte sequences despite conveying the same meaning. ERC-8326 identifies the normalization method explicitly through normProfileId.

Normalization method Applicable contents Processing
NORM:RAW:V1 PDFs, images, plain text, and inputs that need no normalization Leave the input bytes unchanged
NORM:JSON:RFC8785:V1 JSON Use UTF-8 bytes canonicalized according to RFC 8785
NORM:XML:C14N11:V1 XML Use Canonical XML 1.1 output without comments

JSON inputs must not contain duplicate keys, invalid Unicode, unpaired surrogates, or numbers outside the interoperable range. No additional Unicode normalization is applied to JSON strings.

XML processing must disable external entity resolution. Canonical XML 1.1 and Exclusive XML Canonicalization are distinct methods and must not be treated as interchangeable.

ERC-8326 does not define a normalization method specifically for PDFs or images. Resaving the same PDF in different software can change metadata or compression, resulting in different bytes despite an identical appearance. PDFs and images therefore generally use NORM:RAW:V1. An application that uses a custom method publishes the transformation procedure and test files.

Computing the bundleHash

Creating each DocumentEntry alone does not determine the bundle's value. ERC-8326 sorts entries in ascending order using all five fields.

  1. Sort by role

    First, compare the bytes32 role values as byte sequences and place the smaller values first.

  2. Sort by filenameHash

    When roles are equal, compare the filename hashes.

  3. Sort by the remaining three fields

    When filenames also match, compare contentHash, mimeTypeHash, and normProfileId, in that order.

  4. Compute a leaf for each entry

    Concatenate the five fixed-length bytes32 values using abi.encodePacked and compute keccak256.

  5. Hash the schema ID and all leaf values

    Concatenate SCHEMA_V1 and the leaf values from the sorted entries, then compute keccak256 to obtain the bundleHash.

If two DocumentEntry values are identical, they are not deduplicated. Duplicates remain part of the bundle.

js
bytes32 leaf = keccak256(
    abi.encodePacked(
        entry.contentHash,
        entry.role,
        entry.mimeTypeHash,
        entry.filenameHash,
        entry.normProfileId
    )
);

bundleHash = keccak256(
    abi.encodePacked(SCHEMA_V1, leaf0, leaf1, /* ... */, leafN)
);

Including SCHEMA_V1 prevents future formats from sharing the same hash domain. Any incompatible format introduced later uses a new schema ID.

Functions for sorting on-chain and accepting presorted entries

The ERC-8326 reference implementation provides two hash computation paths.

computeCanonicalBundleHash

js
function computeCanonicalBundleHash(DocumentEntry[] memory entries)
    internal pure returns (bytes32);

This function sorts the supplied entries within the contract before computing the bundleHash. It is a straightforward option for testing small bundles whose input order is unknown.

  1. Copy the input into a working array

    Treat the caller's entries as a working array that can be sorted.

  2. Sort by the five fields

    Compare entries in the order role, filenameHash, contentHash, mimeTypeHash, and normProfileId.

  3. Compute the bundleHash from the sorted entries

    Concatenate the per-entry leaf values with SCHEMA_V1 and hash the result.

The sorting algorithm in the reference implementation takes quadratic time in memory, however. Applications that handle large bundles perform normalization, sorting, and hashing off-chain.

computeBundleHash

js
function computeBundleHash(DocumentEntry[] memory entries)
    internal pure returns (bytes32);

This function accepts only inputs that are already in the prescribed order. It will revert for out-of-order inputs or empty bundles.

  1. Check that the input is not empty

    Inputs containing no entries are rejected.

  2. Check the ordering of adjacent entries

    The function will revert if the input violates the five-field comparison order.

  3. Compute the bundleHash from the ordered entries

    Concatenate the per-entry leaf values with SCHEMA_V1 and hash the result.

Both paths produce the same final value. When verifying a bundle, users also reproduce the normalization, sorting, and hashing locally rather than relying on an on-chain function to process their files.

IDocumentBundleAnchor

ERC-8326 does more than store the bundle hash. It uses subjectId and role to distinguish the subject and purpose associated with the value.

For example, a bundle concerning the same company may be used for business identity verification or for contract renewal. Recording the same bundleHash under a different subjectId or role produces an independent record.

IDocumentBundleAnchor is an interface that binds a document bundle hash to a subject and purpose and exposes the currently active value and update history. Even an identical bundleHash is treated as a separate record when the subjectId or role differs.

AnchorRecord

js
struct AnchorRecord {
    bytes32 bundleHash;
    bytes32 subjectId;
    bytes32 role;
    address anchoredBy;
    uint64 anchoredAt;
    uint256 documentCount;
    string metadataURI;
    bool superseded;
    bytes32 supersededBy;
}

AnchorRecord is a struct containing the values stored for one (bundleHash, subjectId, role) tuple. anchorBundle and supersedeBundle create records, and getAnchor retrieves them.

  • Fields
Field Details
bundleHash Hash derived from the bundle of files.
subjectId Nonzero identifier representing the subject to which the bundle belongs.
role Purpose of the bundle for that subject.
anchoredBy Caller account that created the record.
anchoredAt Block timestamp at which the contract created the record.
documentCount Number of files declared by the creator.
metadataURI Optional string indicating where to retrieve the files.
superseded Indicates whether a subsequent record has replaced this record.
supersededBy The replacement bundleHash.

The application determines the subjectId. If no existing identifier is available, the application derives one from a domain-separated value that incorporates its context.

metadataURI is an optional string describing where the files can be retrieved. It can be empty. An empty value does not mean that the files do not exist; it means that this record does not provide a retrieval location.

BundleAnchored

js
event BundleAnchored(
    bytes32 indexed bundleHash,
    bytes32 indexed subjectId,
    bytes32 indexed role,
    uint256 documentCount
);

The BundleAnchored event is emitted when a new bundle record is created. Indexers can search the event logs for new records by subject and purpose.

  • Fields
Field Details
bundleHash Indexed bundle hash.
subjectId Indexed subject identifier.
role Indexed purpose of the bundle.
documentCount Number of files declared by the creator.

The event logs alone do not expose the complete metadataURI, anchoredBy, or supersession status. These are available in the stored record returned by getAnchor.

anchorBundle

js
function anchorBundle(
    bytes32 bundleHash,
    bytes32 subjectId,
    bytes32 role,
    uint256 documentCount,
    string calldata metadataURI
) external;

anchorBundle accepts nonzero bundleHash, subjectId, role, and documentCount values and records a bundle. On success, it stores the calling account as anchoredBy and the block timestamp as anchoredAt, and emits BundleAnchored.

  1. Validate the inputs and role slot

    Check that bundleHash, subjectId, role, and documentCount are nonzero and that there is no active record for the same (subjectId, role).

  2. Create the record

    Store the inputs, msg.sender, and the block timestamp in an AnchorRecord. Set the new record's superseded to false and supersededBy to bytes32(0).

  3. Register the bundle as active

    Set the active value for (subjectId, role) to the new bundleHash and emit BundleAnchored.

  • Parameters
Parameter Details
bundleHash Bundle value produced by normalization, sorting, and hashing.
subjectId Nonzero identifier of the subject to which the bundle belongs.
role Purpose of the bundle for that subject.
documentCount Number of entries included in the bundle.
metadataURI Optional string indicating where to retrieve the files.
  • Execution conditions

  • The caller satisfies the anchoring authorization defined by the implementation.

  • bundleHash, subjectId, role, and documentCount must be nonzero.

  • The same (bundleHash, subjectId, role) cannot be registered twice.

  • If an active record already exists for the same (subjectId, role), the call will revert. Use supersedeBundle instead.

Replacing a bundle without deleting the old record

When a contract is renewed or corrected, the bundle for the same subject and purpose is replaced with a new one. ERC-8326 does not overwrite the old record's original values. It marks the old record as replaced by a new bundleHash and makes the new record active.

Flow for retaining the old bundleHash record and linking it to the new active bundleHash

The old record's superseded flag becomes true, and supersededBy points to the new bundleHash. If users need to verify the old bundle again, the old record itself remains accessible.

supersedeBundle

js
function supersedeBundle(
    bytes32 oldBundleHash,
    bytes32 newBundleHash,
    bytes32 subjectId,
    bytes32 role,
    uint256 documentCount,
    string calldata metadataURI
) external;

supersedeBundle replaces an active old bundleHash with a new bundleHash. Updating the old record, creating the new record, and changing the active value for the purpose all take place in a single transaction.

  1. Check the old record and new inputs

    Verify that the old record exists, has not been superseded, and is currently active for the specified (subjectId, role). Also check that the new value, subject, role, and count are nonzero, and that the old and new hashes differ.

  2. Mark the old record as superseded

    Set the old record's superseded flag to true and store the new bundleHash in supersededBy.

  3. Activate the new record

    Create a new AnchorRecord and update the active value for the role slot. Emit BundleSuperseded and BundleAnchored for the new record.

  • Parameters
Parameter Details
oldBundleHash Hash of the currently active bundle to replace.
newBundleHash Hash of the new bundle to activate.
subjectId Identifier of the subject to which the bundle belongs.
role Purpose of the bundle for that subject.
documentCount Number of entries included in the new bundle.
metadataURI Optional string indicating where to retrieve the files.
  • Execution conditions

  • The caller is authorized to supersede records in that role slot.

  • The old record exists, has not been superseded, and is currently active for the specified purpose.

  • newBundleHash, subjectId, role, and documentCount must be nonzero.

  • The old and new values differ, and the new (bundleHash, subjectId, role) has not been registered.

  • Authorization must not allow an unrelated anchor creator to take over another party's (subjectId, role).

BundleSuperseded

js
event BundleSuperseded(
    bytes32 indexed oldBundleHash,
    bytes32 indexed newBundleHash,
    bytes32 indexed subjectId,
    bytes32 role
);

This event lets observers track which bundleHash for a given purpose has been replaced by a subsequent record. When a bundle is superseded, BundleAnchored is also emitted for the new record.

  • Fields
Field Details
oldBundleHash Indexed hash of the old bundle.
newBundleHash Indexed hash of the replacement bundle.
subjectId Indexed subject identifier.
role Purpose of the bundle that was replaced.

The event establishes the relationship between the old and new values. Use getAnchor to retrieve the new record's retrieval location and anchoring timestamp.

Checks when reading active records

A record's existence and its current active status are different properties. ERC-8326 therefore provides separate functions for reading them.

getAnchor

js
function getAnchor(
    bytes32 bundleHash,
    bytes32 subjectId,
    bytes32 role
) external view returns (AnchorRecord memory);

Returns the complete record for the specified (bundleHash, subjectId, role) tuple. The function will revert if the tuple does not exist.

  1. Locate the record corresponding to the tuple

    Look up the stored record using bundleHash, subjectId, and role as keys.

  2. Return the complete AnchorRecord

    If the record exists, return every field, including its retrieval location, anchoring timestamp, and supersession status.

  • Parameters
Parameter Details
bundleHash Hash of the bundle to verify.
subjectId Identifier of the subject to verify.
role Purpose to verify.
  • Return value
Return value Details
AnchorRecord Complete record stored for the specified tuple.
  • Execution conditions

  • The function will revert if the specified (bundleHash, subjectId, role) does not exist.

isAnchored

js
function isAnchored(
    bytes32 bundleHash,
    bytes32 subjectId,
    bytes32 role
) external view returns (bool);

Returns true if the record has ever been created. Because old, superseded records also return true, this function alone does not determine whether a record is currently active.

  1. Check the record corresponding to the tuple

    Look up whether a record has been stored using bundleHash, subjectId, and role as keys.

  2. Return whether it exists

    Return true if it exists, regardless of supersession status, or false for an unknown tuple.

  • Parameters
Parameter Details
bundleHash Hash of the bundle whose existence is being checked.
subjectId Identifier of the subject to check.
role Purpose to check.
  • Return value
Return value Details
bool true if a record exists for the specified tuple.
  • Execution conditions

  • This is a read-only function.

  • Superseded records also count as existing records and return true.

activeBundle

js
function activeBundle(
    bytes32 subjectId,
    bytes32 role
) external view returns (bytes32);

Returns the current bundleHash for the subject and purpose. If no record has ever been created, it returns bytes32(0).

  1. Look up the role slot

    Use subjectId and role to look up the subject's currently active bundle.

  2. Return the active value or zero

    If the purpose has never been registered, return bytes32(0). Otherwise, return the currently active bundleHash.

  • Parameters
Parameter Details
subjectId Identifier of the subject whose active bundle is being checked.
role Purpose to check.
  • Return value
Return value Details
bytes32 Hash of the currently active bundle, or bytes32(0) if unregistered.
  • Execution conditions

  • This is a read-only function.

  • For an unregistered purpose, it returns bytes32(0) rather than triggering a revert.

Users verify a document bundle in six steps.

  1. Retrieve the active bundleHash

    Call activeBundle(subjectId, role) and stop verification if the result is bytes32(0).

  2. Retrieve the stored record

    Call getAnchor using the returned value and the same subjectId and role.

  3. Check that the subject and purpose match

    Verify that the returned bundleHash, subjectId, and role match the requested values.

  4. Check the timestamp and count

    Verify that anchoredAt and documentCount are nonzero.

  5. Check that the record has not been superseded

    Verify that superseded is false.

  6. Recompute the value from local files

    Reproduce normalization, creation of the five fields, sorting, and bundleHash computation, then compare the result with the on-chain value.

Compare the locally recomputed value with the current value returned by activeBundle. Only a match confirms that the local bundle was constructed from the same inputs as the currently active record for that subject and purpose.

Flow for normalizing local files, recomputing the bundleHash, and comparing it with the currently active on-chain record

documentCount is not a value that the contract verifies against the contents of the bundle. Count the entries in the recomputed bundle rather than trusting the stored count alone.

IDocumentBundleAnchorRecovery

ERC-8326 includes an optional recovery interface for cases in which the account that creates records is lost, or an authorized account occupies a role slot first. A registry implementing recovery lets an administrator change the principal account for a particular (subjectId, role).

SlotPrincipalAssigned

js
event SlotPrincipalAssigned(
    bytes32 indexed subjectId,
    bytes32 indexed role,
    address indexed principal
);

The SlotPrincipalAssigned event is emitted when the recovery administrator changes the principal account of a role slot. Observers can use these event logs to track the current principal for each subject and purpose.

  • Fields
Field Details
subjectId Indexed subject identifier.
role Indexed purpose of the bundle.
principal Indexed new principal account.

The event alone does not indicate whether the principal satisfies the implementation's general anchoring authorization. The registry implementation enforces the actual authorization conditions.

slotPrincipal

js
function slotPrincipal(
    bytes32 subjectId,
    bytes32 role
) external view returns (address);

slotPrincipal returns the principal account assigned to a role slot. If no principal is assigned, it returns address(0).

  1. Look up the role slot

    Use subjectId and role to look up the principal account stored for recovery.

  2. Return the principal account or the zero address

    If a principal has been assigned, return its address; otherwise, return address(0).

  • Parameters
Parameter Details
subjectId Identifier of the subject whose principal is being checked.
role Purpose whose principal is being checked.
  • Return value
Return value Details
address Principal account, or address(0) if no principal is assigned.
  • Execution conditions

  • This is a read-only function.

  • For an unassigned purpose, it returns address(0) rather than triggering a revert.

assignSlotPrincipal

js
function assignSlotPrincipal(
    bytes32 subjectId,
    bytes32 role,
    address principal
) external;

assignSlotPrincipal changes the principal account assigned to a role slot. This call alone does not grant general anchoring authorization to the new principal.

  1. Check the caller and inputs

    Verify that the caller is the recovery administrator and that subjectId, role, and principal are nonzero.

  2. Store the principal account

    Update the principal for the specified (subjectId, role) to principal.

  3. Emit the principal change

    Emit SlotPrincipalAssigned so observers can track the change.

  • Parameters
Parameter Details
subjectId Identifier of the subject whose principal is being changed.
role Purpose whose principal is being changed.
principal Nonzero account to assign as the new principal.
  • Execution conditions

  • The caller must be the recovery administrator defined by the implementation.

  • subjectId, role, and principal must be nonzero.

Only the recovery administrator can call assignSlotPrincipal. Changing the principal account alone does not grant general anchoring authorization. The principal can anchor or supersede records only after satisfying the implementation's authorization conditions.

If an administrator directly calls supersedeBundle after a role slot has been taken over, the previous principal may submit a supersession transaction first. The recovery extension lets the administrator first change the principal atomically, after which the legitimate principal can supersede the bundle.

Flow in which the recovery administrator first switches the principal using assignSlotPrincipal and the new principal replaces the bundle with supersedeBundle

The sequence in this diagram does not imply that assignSlotPrincipal alone grants general anchoring authorization. The new principal can call supersedeBundle only when the registry implementation's authorization conditions are also satisfied.

A registry conforming to ERC-8326 implements ERC165 and reports support for IDocumentBundleAnchor.

For more on ERC-165, see the following article.

[ERC-165] Checking whether a contract supports a specific interface

An ERC165 response, however, is a declaration that the interface is implemented. It does not verify that the bundle was hashed correctly, that the files are authentic, or that the anchor creator is trustworthy.

Compatibility

ERC-8326 adds a new interface without changing the behavior of existing token or registry standards. Existing systems can integrate it by storing the resulting bundleHash in an existing record field or by providing a separate IDocumentBundleAnchor registry.

A hash derived using an earlier method, however, may not incorporate ERC-8326's sorting rules, five fields, and schema ID. Even if both values can be stored as bytes32, they cannot be verified against one another by recomputation if the construction methods differ.

Reference implementation

The official discussion links to a Solidity reference implementation, hashing library, unit tests, property tests, client-side verification code, and an audit. The reference implementation sorts DocumentEntry values and computes the hash, but JSON and XML normalization is performed off-chain.

Security

ERC-8326 lets users check whether a bundle created using the same normalization method and five fields matches the recorded bundleHash. It also lets them track which record is currently active for each subject and purpose, and which values have replaced earlier records.

A hash alone cannot be used to retrieve the files. A record remains valid even if metadataURI is empty, and a URI does not guarantee that the files will remain available.

Even when the hashes match, the creator's signature, issuer's authority, and legal validity must be verified separately. Avoid placing personal or confidential information directly in a URI.

Conclusion

ERC-8326 combines a bundle of contracts and certificates into a single bundleHash that incorporates the contents, roles, MIME types, filenames, and normalization methods. Users can recompute the same value from their local files and compare it against the currently active on-chain record. Supersession retains the old record and links it to the new value, making earlier records verifiable as well.