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

This function converts local files into hash values.

This function converts the buffer of files or texts into hash values.

This function checks whether a user is the owner of the ContractHash.

Parameter information required to call API.

1. getFileHash

This function gets the hash value of a file.

Parameters

NameTypeExample

filePath

String

"./contract_sameple.pdf"

Return value

da39330a6dfd90a91563603950f742240fa222580beecf36e141fe6410184e8b

2. getFileHashFromBuffer

This function gets the hash value from the buffer.

Parameters

NameTypeExample

buffer

Uint8Array (Buffer)

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

Return value

b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9

3. isContractOwner

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

Parameters

NameTypeExample

fileHash

String

"da39330a6dfd90a91563603950f742240fa222580beecf36e141fe6410184e8b1669119707"

ownerAddress

String

"firma1epg9kx7nqz32dykj23p6jreqfh5x0wdy5a43qc"

Return value

true

4. Parameter Description

NameDescription

filePath

This 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.

buffer

This parameter refers to the buffer data of a file or a text.

fileHash

This 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.

ownerAddress

For 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”).

Last updated