# Log

One of the features provided by the Contract module, Log allows users to record any and all events that happen in the process of closing a contract, on the chain network as transactions. Additionally, users can search logs that are recorded on ContractHash.

## Contents

<table><thead><tr><th width="330">Name</th><th width="411">Description</th></tr></thead><tbody><tr><td><a href="#1.-addcontractlog">1. addContractLog</a></td><td>This feature allows users to record events, actions or results that happen<br>in the process of writing a contract on the chain network.</td></tr><tr><td><a href="#2.-getcontractlog">2. getContractLog</a></td><td>This feature inquires logs that are recorded on the chain using the log ID.</td></tr><tr><td><a href="#3.-getcontractlogall">3. getContractLogAll</a></td><td>This feature checks all logs that are recorded on the chain network.</td></tr><tr><td><a href="#4.-getgasestimationaddcontractlog">4. getGasEstimationAddContractLog</a></td><td><p>This feature estimates gas fee required</p><p>to execute the addContractLog transaction.</p></td></tr><tr><td><a href="#5.-getcontractlistfromhash">5. getContractListFromHash</a></td><td>This feature checks all logs that are registered on the hash.</td></tr><tr><td><a href="#6.-parameter-description">6. Parameter Description</a></td><td>Parameters required to call API.</td></tr></tbody></table>

### 1. addContractLog&#x20;

This function allows users to record events, actions and results that happen in the process of closing a contract on the chain network as transactions. When running this function, transactions are created on the chain based on the predesignated parameters of this function. Users can get a visual confirmation of the result of this function on the FirmaChain block explorer by using the “transactionHash” value of the “Return value”.

#### **Parameters**

<table><thead><tr><th width="160.33333333333331">Name</th><th width="246">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>contractHash</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>eventName</td><td><mark style="color:blue;">String</mark></td><td>"createContract"</td></tr><tr><td>ownerAddress</td><td><mark style="color:blue;">String</mark></td><td>"firma1nssuz67am2uwc2hjgvphg0fmj3k9l6cx65ux9u"</td></tr><tr><td>jsonString</td><td><mark style="color:blue;">String</mark> (<mark style="color:green;">JSON</mark>)</td><td>"{Encryption:{type:"JWT",alg:"HS256"},contracts:[{target:"contractor1",email:"contractor1@gmail.com"}]}"</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

```json5
{
  code: 0,
  height: 413126,
  rawLog: ‘[{
    "events": [{
      "type": "message",
        "attributes": [{
        "key": "action",
        "value":"CreateContractLog“
      }]
    }]
  }]',
  transactionHash: "F61584DE6B2F...63B1788247FE",
  gasUsed: 73443,
  gasWanted: 200000
}
```

### 2. getContractLog

This feature allows users to inquire logs that happen in the process of closing a contract. Inquiries are made using the logId, and users can check the transaction information in the addContractLog. *\* transactionHash information are not included.*

#### Paramters

<table><thead><tr><th width="160.33333333333331">Name</th><th width="260">Type</th><th>Example</th></tr></thead><tbody><tr><td>logId</td><td><mark style="color:blue;">String</mark> (<mark style="color:blue;">Number</mark>)</td><td>"6792"</td></tr></tbody></table>

#### Return value

```json5
{
  creator: "firma1nssuz67a...j3k9l6cx65ux9u",
  id: "68219",
  contractHash: "da39330a6dfd90a...4e8b1669108636",
  timeStamp: "1669108636",
  eventName: "createContract",
  ownerAddress: "firma1nssuz67a...j3k9l6cx65ux9u",
  jsonString: "{}"
}
```

### 3. getContractLogAll

This function checks all contract related logs recorded on the chain network. Since this functions goes through all recorded logs on the chain network, using this function might cause serious network delays. Therefore, we do not recommend the universal application of this feature when developing real services. Rather, we recommend developers to apply this feature only to obtain an overall tally of the recorded log data.

#### Parameters

<table><thead><tr><th width="161.33333333333331">Name</th><th width="256">Type</th><th>Example</th></tr></thead><tbody><tr><td>paginationKey<br>(Not required)</td><td><mark style="color:blue;">String</mark> | <mark style="color:blue;">Undefined</mark></td><td>"AAAAAAAAAGQ="</td></tr></tbody></table>

#### Return value

```json5
{
  [{
    creator: 'firma1p3qk0ednef258lv6vjt6g657d7jh0gh6wez9c4',
    id: '99',
    contractHash: 'test0.9212182198543295',
    timeStamp: '1666933357',
    eventName: 'test0.678718823219671',
    ownerAddress: 'test',
    jsonString: '{}'
  }],
  ...
  pagination: { next_key: 'AAAAAAAAAGQ=', total: 68221 }
}
```

### 4. getGasEstimationAddContractLog

This feature calculates the gas fee that is generated when running the function that creates addContractLog transactions. Used as the last parameter of the addContractLog function, we recommend developers to pay the transaction fees using this function.

#### Parameters

<table><thead><tr><th width="158.33333333333331">Name</th><th width="248">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>contractHash</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>eventName</td><td><mark style="color:blue;">String</mark></td><td>"createContract"</td></tr><tr><td>ownerAddress</td><td><mark style="color:blue;">String</mark></td><td>"firma1nssuz67am2uwc2hjgvphg0fmj3k9l6cx65ux9u"</td></tr><tr><td>jsonString</td><td><mark style="color:blue;">String</mark> (<mark style="color:green;">JSON</mark>)</td><td>"{Encryption:{type:"JWT",alg:"HS256"},contracts:[{target:"contractor1",email:"contractor1@gmail.com"}]}"</td></tr></tbody></table>

#### Return value

```json5
112706
```

### 5. getContractListFromHash

#### Parameters

<table><thead><tr><th width="162.33333333333331">Name</th><th width="111"></th><th>Example</th></tr></thead><tbody><tr><td>contractHash</td><td><mark style="color:blue;">String</mark></td><td>"da39330a6dfd90a91563603950f742240fa222580beecf36e141fe6410184e8b1669119707"</td></tr></tbody></table>

#### Return value

```json5
[
  '68183', '68185', '68187', '68189', '68193', '68195',
  '68199', '68201', '68207', '68209', '68213', '68215'
]
```

### 6. Parameter Description

<table><thead><tr><th width="195">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>contractHash</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>eventName</td><td>This parameter contains information related to a certain event, action or a result. For instance, looking at the life cycle of a contract, this parameter can be devided into “Contract Creation”, “Invite Signatories”, “Sign”, “All Signatues Received” and “Contract Complete”.</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><tr><td>jsonString</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>logId</td><td>This parameter contains the Unique ID value of the addContractLog recorded on the chain network. Developers can search the Log registered under a certain ID.</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>


---

# 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/log.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.
