Skip to content

Utils ​

This functions provides features that are required in order to record and inquire contracts. Features such as file conversion to hash values, file or text buffer data conversion to hash values, owner of the contract hash value inquiry etc. are provided by this function.

Contents ​

NameDescription
1. getFileHashThis function converts local files into hash values.
2. getFileHashFromBufferThis function converts the buffer of files or texts into hash values.
3. isContractOwnerThis function checks whether a user is the owner of the ContractHash.
4. Parameter DescriptionParameter information required to call API.

1. getFileHash ​

This function gets the hash value of a file.

Parameters ​

NameTypeExample
filePathString"./contract_sameple.pdf"

Return value ​

json5
da39330a6dfd90a91563603950f742240fa222580beecf36e141fe6410184e8b

2. getFileHashFromBuffer ​

This function gets the hash value from the buffer.

Parameters ​

NameTypeExample
bufferUint8Array (Buffer)Uint8Array(11) [ 104, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100 ]

Return value ​

json5
b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9

3. isContractOwner ​

This function verifies whether the user is the owner of the file hash recorded on the chain network.

Parameters ​

NameTypeExample
fileHashString"da39330a6dfd90a91563603950f742240fa222580beecf36e141fe6410184e8b1669119707"
ownerAddressString"firma1epg9kx7nqz32dykj23p6jreqfh5x0wdy5a43qc"

Return value ​

json5
true

4. Parameter Description ​

NameDescription
filePathThis parameter refers to the path of the contract file. Only local directory paths can be used and paths that do not point to a file or a web file path cannot be used.
bufferThis parameter refers to the buffer data of a file or a text.
fileHashThis parameter contains the mapped information of a file or a text to a predesignated length. This information can be used to track Contract on the network and allows developers to add multiple Logs to a single Contract Hash. Using the FirmaUtil, developers can call the hash value of a file or a text and we recommend developers to use the unique value.
ownerAddressFor this parameter, please enter your FirmaChain wallet address. The owner of the wallet can be anyone. (e.g. “Service Wallet Address” or “Signatory’s Wallet Address”).