# 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

| Name                                                  | Description                                                           |
| ----------------------------------------------------- | --------------------------------------------------------------------- |
| [1. getFileHash](#1.-getfilehash)                     | This function converts local files into hash values.                  |
| [2. getFileHashFromBuffer](#2.-getfilehashfrombuffer) | This function converts the buffer of files or texts into hash values. |
| [3. isContractOwner](#3.-iscontractowner)             | This function checks whether a user is the owner of the ContractHash. |
| [4. Parameter Description](#4.-parameter-description) | Parameter information required to call API.                           |

### 1. getFileHash

This function gets the hash value of a file.

#### Parameters

<table><thead><tr><th width="165.33333333333331">Name</th><th width="255">Type</th><th>Example</th></tr></thead><tbody><tr><td>filePath</td><td><mark style="color:blue;">String</mark></td><td>"./contract_sameple.pdf"</td></tr></tbody></table>

#### Return value

```json5
da39330a6dfd90a91563603950f742240fa222580beecf36e141fe6410184e8b
```

### 2. getFileHashFromBuffer

This function gets the hash value from the buffer.

#### Parameters

<table><thead><tr><th width="166.33333333333331">Name</th><th width="254">Type</th><th>Example</th></tr></thead><tbody><tr><td>buffer</td><td><mark style="color:blue;">Uint8Array</mark> (<mark style="color:blue;">Buffer</mark>)</td><td>Uint8Array(11) [ 104, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100 ]</td></tr></tbody></table>

#### 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

<table><thead><tr><th width="171.33333333333331">Name</th><th width="255">Type</th><th>Example</th></tr></thead><tbody><tr><td>fileHash</td><td><mark style="color:blue;">String</mark></td><td>"da39330a6dfd90a91563603950f742240fa222580beecf36e141fe6410184e8b1669119707"</td></tr><tr><td>ownerAddress</td><td><mark style="color:blue;">String</mark></td><td>"firma1epg9kx7nqz32dykj23p6jreqfh5x0wdy5a43qc"</td></tr></tbody></table>

#### Return value

```json5
true
```

### 4. Parameter Description

<table><thead><tr><th width="191">Name</th><th>Description</th></tr></thead><tbody><tr><td>filePath</td><td>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.</td></tr><tr><td>buffer</td><td>This parameter refers to the buffer data of a file or a text.</td></tr><tr><td>fileHash</td><td>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.</td></tr><tr><td>ownerAddress</td><td>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”).</td></tr></tbody></table>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.firmachain.org/master/developer/modules/contract/utils.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
