# File

File allows users to record contracts on the network or search contracts that are recorded on the chain network.

## Contents

<table><thead><tr><th width="344">Name</th><th width="404">Description</th></tr></thead><tbody><tr><td><a href="#1.-createcontractfile">1.​ createContractFile</a></td><td>This feature allows completed contracts to be written on the chain network as Hash value.</td></tr><tr><td><a href="#2.-getcontractfile">2. getContractFile​</a></td><td>This feature inquires contract information recorded on the chain network using Hash values.</td></tr><tr><td><a href="#3.-getcontractfileall">3. getContractFileAll</a></td><td>This feature inquires all contract related information recorded on the chain network.</td></tr><tr><td><a href="#4.-getgasestimationcreatecontractfile">4. getGasEstimationCreateContractFile</a></td><td><p>This feature estimates the required gas fee</p><p>when running the "createContractFile"  transaction.</p></td></tr><tr><td><a href="#5.-parameter-description">5. Parameter Description</a></td><td>Parameters required to call API.</td></tr></tbody></table>

### 1. createContractFile

This function(generate transactions) records contracts on the chain network.\
\&#xNAN;*\* Once a contract is recorded on the chain network, it cannot be further modified so we recommend users to only upload contracts that are complete.*

#### Parameters

<table><thead><tr><th width="203.33333333333331">Name</th><th width="244">Type</th><th>Example</th></tr></thead><tbody><tr><td>wallet</td><td><mark style="color:blue;">Object</mark> (<mark style="color:green;">FirmaWalletService</mark>)</td><td>You can check how to use your wallet in the "<a href="https://github.com/FirmaChain/firma-js#create-wallet-account">firma-js of the Github repository</a>".</td></tr><tr><td>fileHash</td><td><mark style="color:blue;">String</mark></td><td>"da39330a6dfd90a91563603950f742240fa222580beecf36e141fe6410184e8b1669119707"</td></tr><tr><td>timeStamp</td><td><mark style="color:blue;">Number</mark></td><td>1669182016039</td></tr><tr><td>ownerList</td><td><mark style="color:green;">Array</mark> (<mark style="color:blue;">String</mark>)</td><td>["firma1epg9kx7nqz32dykj23p6jreqfh5x0wdy5a43qc"]</td></tr><tr><td>metaDataJsonString</td><td><mark style="color:blue;">String</mark> (<mark style="color:green;">JSON</mark>)</td><td>'{"storage":"ipfs","encryptIpfsHash":["U2FsdGVkX19UsL3m7Cq2bOtTCQArqZTuLgz7mfdRtXM2MnIgm67GM26GtPELsVL8s4+IN2Vj9FbFzpFj3rwfaw=="]}'</td></tr><tr><td>txMisc<br>(Not required)</td><td><mark style="color:blue;">Object</mark> (<mark style="color:green;">TxMisc</mark>)</td><td>{fee:200000,gas:163821,memo:"custom message"}</td></tr></tbody></table>

#### Return value

```json
{
  code: 0,
  height: 413187,
  rawLog: ‘[{
            "events": [{
              "type": "message",
              "attributes": [{
                "key":"action",
                "value":"CreateContractFile“
              }]
            }]
          }]’,
  transactionHash: "2856B8B0C6B49CD...78EEB558D86421F",
  gasUsed: 70898,
  gasWanted: 200000
}

```

### 2. getContractFile​

This feature allows users to inquire contracts that are recorded on the Users chain using the fileHash value.\
\&#xNAN;*\* All contracts recorded on the chain network are recorded as hash values.*

#### Parameter

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

#### Return value

```
{
  creator: 'firma1nssuz67am2uwc2hjgvphg0fmj3k9l6cx65ux9u',
  fileHash: 'da39330a6dfd90a91563603950f742240fa222580beecf36e141fe6410184e8b',
  timeStamp: '1669106395',
  ownerList: [ 'firma1nssuz67am2uwc2hjgvphg0fmj3k9l6cx65ux9u' ],
  metaDataJsonString: '{"storage":"ipfs",
    "encryptIpfsHash": ["U2FsdGVkX18curk11EhPxYPJtwmE0BffES2vp1h/+p62/VTafy5dsmvaUCkHlXUkBiHXwzBKB8dF3NwI9dfUyw=="]}'
}
```

### 3. getContractFileAll

This feature inquires all contracts recorded on the chain network.

#### Parameter

<table><thead><tr><th width="165.33333333333331">Name</th><th width="185">Type</th><th>Example</th></tr></thead><tbody><tr><td><p>paginationKey</p><p>(Not required)</p></td><td><mark style="color:blue;">String</mark> | <mark style="color:blue;">Undefined</mark></td><td>"ZGEzOTMzMGE2ZGZkOTBhOTE1NjM2MDM5NTBmNzQyMjQwZmEyMjI1ODBiZWVjZjM2ZTE0MWZlNjQxMDE4NGU4YjE2NjkxMDY3MTE="</td></tr></tbody></table>

#### Return value

```
{
  [{
    creator: 'firma1nssuz67am2uwc2hjgvphg0fmj3k9l6cx65ux9u',
    fileHash: 'da39330a6dfd90a91563603950f742240fa222580beecf36e141fe6410184e8b1669106610',
    timeStamp: '1669106610',
    ownerList: [Array],
    metaDataJsonString: '{"storage":"ipfs","encryptIpfsHash":["U2FsdGVkX19UsL3m7Cq2bOtTCQArqZTuLgz7mfdRtXM2MnIgm67GM26GtPELsVL8s4+IN2Vj9FbFzpFj3rwfaw=="]}'
  }],
  ...
  pagination: {
    next_key: 'ZGEzOTMzMGE2ZGZkOTBhOTE1NjM2MDM5NTBmNzQyMjQwZmEyMjI1ODBiZWVjZjM2ZTE0MWZlNjQxMDE4NGU4YjE2NjkxMDY3MTE=',
    total: 117
  }
}
```

### 4. getGasEstimationCreateContractFile

This feature estimates the gas fee required when executing the createContractFile transaction.

#### Parameters

<table><thead><tr><th width="203.33333333333331">Name</th><th width="244">Type</th><th>Example</th></tr></thead><tbody><tr><td>wallet</td><td><mark style="color:blue;">Object</mark> (<mark style="color:green;">FirmaWalletService</mark>)</td><td>You can check how to use your wallet in the "<a href="https://github.com/FirmaChain/firma-js#create-wallet-account">firma-js of the Github repository</a>".</td></tr><tr><td>fileHash</td><td><mark style="color:blue;">String</mark></td><td>"da39330a6dfd90a91563603950f742240fa222580beecf36e141fe6410184e8b1669119707"</td></tr><tr><td>timeStamp</td><td><mark style="color:blue;">Number</mark></td><td>1669182016039</td></tr><tr><td>ownerList</td><td><mark style="color:green;">Array</mark> (<mark style="color:blue;">String</mark>)</td><td>["firma1epg9kx7nqz32dykj23p6jreqfh5x0wdy5a43qc"]</td></tr><tr><td>metaDataJsonString</td><td><mark style="color:blue;">String</mark> (<mark style="color:green;">JSON</mark>)</td><td>'{"storage":"ipfs","encryptIpfsHash":["U2FsdGVkX19UsL3m7Cq2bOtTCQArqZTuLgz7mfdRtXM2MnIgm67GM26GtPELsVL8s4+IN2Vj9FbFzpFj3rwfaw=="]}'</td></tr></tbody></table>

#### Return value

```json5
162019
```

### 5. Parameter Description

<table><thead><tr><th width="220">Name</th><th>Description</th></tr></thead><tbody><tr><td>wallet</td><td>Unique wallet parameter created from the user’s Mnemonic.<br>This parameter can be called by using the Wallet.fromMnemonic function from the FirmaSDK module.</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>timeStamp</td><td>This parameter timestamps a certain event, action or a result. This parameter is displayed as the "Unix time stamp" format and must be written in numbers.</td></tr><tr><td>ownerList</td><td>This parameter contains the wallet address list of the users related to a contract. This parameter can be added for the same purpose as the ownerAddress parameter.</td></tr><tr><td>metaDataJsonString</td><td>This parameter contains additional information related to a contract. Additional information for instance, includes, public key (encrypted), location of the saved contract, contract download link or the e-mail address of the owner of the contract. Please write this parameter as JSON text format.<br><em>* There are no set standard so please customize this parameter to suit the purpose of your project.</em></td></tr><tr><td>txMisc</td><td><p>This object contains the gas fee that is deducted when a transaction is called upon.</p><p><em>* The default gas fee is set at 0.02fct.</em></p></td></tr><tr><td>paginationKey</td><td>This parameter fetches all logs when the getContractLogAll is inquired. Once the number of log exceeds 100, this parameter is used to inquire data starting with the 101st data set.</td></tr></tbody></table>
