Skip to main content

IDocumentation

Hashgraph Asset Tokenization

IDocumentation

Interface for on-chain document management, enabling attachment, removal, and retrieval of off-chain documents referenced by a unique bytes32 name.

Implementing contracts are expected to gate write operations behind role-based access control and pause checks. Storage is managed via a dedicated diamond storage slot (STORAGE_LOCATION_DOCUMENTATION) to avoid layout collisions. All function selectors are identical to those of the former IERC1643 interface, preserving full ABI compatibility.

Methods​

getAllDocuments​

function getAllDocuments() external view returns (bytes32[])

Returns the names of all documents currently attached to the contract.

The returned array reflects the current contents of the docNames storage array; ordering may change when documents are removed via swap-and-pop.

Returns​

NameTypeDescription
_0bytes32[]Array of bytes32 document names.

getDocument​

function getDocument(bytes32 _name) external view returns (string, bytes32, uint256)

Returns the URI, content hash, and last-modified timestamp of a document.

Parameters​

NameTypeDescription
_namebytes32Unique bytes32 identifier of the document to query.

Returns​

NameTypeDescription
_0stringOff-chain URI of the document.
_1bytes32Keccak-256 content hash of the document.
_2uint256Unix timestamp of the last write operation on this document.

initializeDocumentation​

function initializeDocumentation() external nonpayable

Initialises the documentation capability on the token.

Callable once; subsequent calls revert with FacetAlreadyRegistered. Requires DEFAULT_ADMIN_ROLE. Called by the factory during deployment.

removeDocument​

function removeDocument(bytes32 _name) external nonpayable

Removes an existing document from the contract.

Requires the caller to hold ROLE_DOCUMENTER and the token to be unpaused. Uses a swap-and-pop strategy to remove the entry from docNames in O(1), updating docIndexes accordingly. Emits {DocumentRemoved}. Reverts with {DocumentDoesNotExist} if _name is not registered.

Parameters​

NameTypeDescription
_namebytes32Unique bytes32 identifier of the document to remove.

setDocument​

function setDocument(bytes32 _name, string _uri, bytes32 _documentHash) external nonpayable

Attaches a new document to the contract or updates the URI and hash of an existing one.

Requires the caller to hold ROLE_DOCUMENTER and the token to be unpaused. If _name is not yet registered, it is appended to the docNames array and its index is recorded in docIndexes. Emits {DocumentUpdated}.

Parameters​

NameTypeDescription
_namebytes32Unique bytes32 identifier for the document. Must not be zero.
_uristringOff-chain URI of the document. Must not be empty.
_documentHashbytes32Keccak-256 content hash of the document. Must not be zero.

Events​

DocumentRemoved​

event DocumentRemoved(bytes32 indexed name, string uri, bytes32 documentHash)

Emitted when a document is permanently removed from the contract.

Parameters​

NameTypeDescription
name indexedbytes32Unique identifier of the document that was removed.
uristringOff-chain URI that was associated with the document.
documentHashbytes32Content hash that was associated with the document.

DocumentUpdated​

event DocumentUpdated(bytes32 indexed name, string uri, bytes32 documentHash)

Emitted when a document is created or its URI or hash is updated.

Parameters​

NameTypeDescription
name indexedbytes32Unique identifier of the document that was set or updated.
uristringOff-chain URI now associated with the document.
documentHashbytes32Content hash now associated with the document.

DocumentationInitialized​

event DocumentationInitialized()

Emitted once when the documentation capability is initialised on a token.

Fires exclusively from initializeDocumentation.

Errors​

DocumentDoesNotExist​

error DocumentDoesNotExist(bytes32 name)

Raised when an operation targets a document name that has not been registered.

Parameters​

NameTypeDescription
namebytes32The document name that could not be found in storage.

EmptyHASH​

error EmptyHASH()

Raised when setDocument is called with a zero-value document hash.

A zero hash provides no integrity guarantee and is therefore disallowed.

EmptyName​

error EmptyName()

Raised when setDocument is called with a zero-value document name.

A bytes32(0) name is rejected to prevent silent collisions in storage.

EmptyURI​

error EmptyURI()

Raised when setDocument is called with an empty URI string.

An empty URI would produce an unresolvable document reference.