ERC-8326 · Last Call · ERC · 2026-07-05
ERC-8326: Canonical Document Bundle Anchor
Defines one deterministic way to hash a bundle of off-chain documents into a single bytes32 and an on-chain registry that anchors that hash per subject and role, keeping an append-only history when a bundle is superseded.
What problem does it solve?
Many applications commit on-chain to a set of off-chain documents: an agreement plus amendments, a certification plus evidence, and so on. Today every project hashes these differently, with different entry formats, ordering and versioning, so two systems holding identical documents can still produce different commitments, and there is no shared way to record that one bundle replaced another.
ERC-8326 standardises the manifest (how each document is described and ordered before hashing) and a small anchoring interface. It is explicit about its limits: it does not prove a document is authentic, legally effective or still available.
How it works
1. Describe each document as a fixed-width DocumentEntry of five bytes32 fields:
contentHash:keccak256of the document bytes after a normalization profile. Defined profiles are raw bytes (NORM:RAW:V1), RFC 8785 canonical JSON and Canonical XML 1.1. PDFs and images use raw bytes.role: for examplekeccak256("AGREEMENT"),EVIDENCE,CERTIFICATION,AMENDMENT,LEGAL_BASIS,SUPPORTING.mimeTypeHash: hash of the lowercase media type without parameters.filenameHash: hash of the basename, ASCII-lowercased and Unicode NFC-normalized.normProfileId: which profile produced the bytes.
2. Sort and hash. Entries are sorted by role, then filenameHash, contentHash, mimeTypeHash, normProfileId. Each entry becomes a leaf (keccak256 of its packed fields), and bundleHash = keccak256(SCHEMA_V1 ‖ leaf0 ‖ … ‖ leafN) with SCHEMA_V1 = keccak256("ERC-8326:BUNDLE:V1"). Duplicates are kept.
3. Anchor. An IDocumentBundleAnchor registry (with ERC-165 detection) stores records keyed by (bundleHash, subjectId, role). Each (subjectId, role) slot has at most one active bundle. anchorBundle fills an empty slot; supersedeBundle replaces the active one, marking the old record superseded but never deleting it. An optional recovery extension lets an administrator reassign a contested slot's principal.
Sample code
Hashing pre-sorted entries, as the spec's computeBundleHash path requires:
// SPDX-License-Identifier: CC0-1.0
pragma solidity ^0.8.20;
library BundleHash {
struct DocumentEntry {
bytes32 contentHash; bytes32 role; bytes32 mimeTypeHash;
bytes32 filenameHash; bytes32 normProfileId;
}
bytes32 constant SCHEMA_V1 = keccak256("ERC-8326:BUNDLE:V1");
function _key(DocumentEntry memory e) private pure returns (bytes32[5] memory k) {
k = [e.role, e.filenameHash, e.contentHash, e.mimeTypeHash, e.normProfileId];
}
function _le(DocumentEntry memory a, DocumentEntry memory b) private pure returns (bool) {
bytes32[5] memory x = _key(a); bytes32[5] memory y = _key(b);
for (uint i; i < 5; i++) if (x[i] != y[i]) return x[i] < y[i];
return true; // equal entries allowed (duplicates)
}
function computeBundleHash(DocumentEntry[] memory es) internal pure returns (bytes32) {
require(es.length > 0, "empty");
bytes memory buf = abi.encodePacked(SCHEMA_V1);
for (uint i; i < es.length; i++) {
if (i > 0) require(_le(es[i - 1], es[i]), "unsorted");
DocumentEntry memory e = es[i];
buf = abi.encodePacked(buf, keccak256(abi.encodePacked(
e.contentHash, e.role, e.mimeTypeHash, e.filenameHash, e.normProfileId)));
}
return keccak256(buf);
}
}
Things to know
- Status: Last Call (deadline 2026-10-19). Changes are still possible until it is finalized.
- Normalization and sorting are meant to happen off-chain; consumers must reproduce the manifest and bundle hash themselves. The contract cannot check that a claimed profile was really applied, and
documentCountis purely declarative. - How callers are authorized to anchor is implementation-defined; a caller with anchoring rights can squat an unassigned slot unless principals are pre-assigned.
- Never put personal or confidential data in
metadataURI; an empty URI is allowed. - It commits to the whole manifest, not a Merkle tree, so proving a single document's membership requires the full entry list.
- Related prior art cited by the authors: ERC-5732 commit-reveal, ERC-7208 data containers, and ERC-3668 off-chain retrieval.