HcsFileService API Reference
This document provides a detailed API reference for the HcsFileService
class — a service for submitting and resolving Hedera Consensus Service (HCS) files following the HCS-1 standard.
Methods
submitFile
async submitFile(props: SubmitFileProps): Promise<string>
Submits an HCS-1 formatted file to Hedera Consensus Service.
-
props
(required): Properties for submitting a file.
SubmitFileProps
fields:
-
payload
(Buffer, required): The file content as a binary buffer. -
submitKey
(PrivateKey, required): Private key used to sign transaction submissions. -
waitForChangesVisibility
(boolean, optional): If true, waits until the submitted file is fully visible on the network. -
waitForChangesVisibilityTimeoutMs
(number, optional): Timeout in milliseconds to wait for visibility confirmation.
-
A promise resolving to the topic ID string where the file was submitted.
-
Error if an issue occurs during file submission.
resolveFile
async resolveFile(props: ResolveFileProps): Promise<Buffer>
Resolves an HCS-1 file from a Hedera topic ID, using cache if available.
-
props
(required): Properties for resolving a file.
ResolveFileProps
fields:
-
topicId
(string, required): The topic ID where the file was submitted.
-
A promise resolving to a
Buffer
containing the reconstructed file content.
-
Error if the file cannot be resolved.
ResolveFileProps
fields:
-
topicId
(string, required): The topic ID where the file was submitted.
-
A promise resolving to a
Buffer
containing the reconstructed file content.
-
Error if the topic memo is invalid or does not comply with HCS-1 standard.
-
Error if the topic contains an admin key (which is not allowed).
-
Error if the resolved file’s checksum does not match the expected hash.