Skip to content

Bulk Insert ​

This feature is used when two or more addContractLog or createContractLog must be contained in a single transaction during the contract life cycle or when more than one contracts are sent as a bulk transaction.

Contents ​

NameDescription
1. getUnsignedTxAddContractLogThis feature receives the addContractLog transaction creation message.
2. getUnsignedTxCreateContractFileThis feature receives the addContractFile transaction creation message.
3. getGasEstimationSignAndBroadcastThis feature estimates the gas fee required for lining up transaction messages.
4. signAndBroadcastThis feature executes multiple transactions at once.
5. Parameter DescriptionParameters required to call API.

1. getUnsignedTxAddContractLog ​

This function generates addContractLog transactions as messages. Events that happen in a contract life cycle are contained in the addContractLog. Once the gas fee for generating a message is calculated, the transaction is created by the function that executes messages.
&#xNAN;* For a more detailed guide on calculating the gas fee and executing messages, please refer to functions 3 and 4.

Parameters ​

NameTypeExample
walletObject (FirmaWalletService)You can check how to use your wallet in the "firma-js of the Github repository".
contractHashString"da39330a6dfd90a91563603950f742240fa222580beecf36e141fe6410184e8b1669119707"
timeStampNumber1669182016039
eventNameString"createContract"
ownerAddressString"firma1nssuz67am2uwc2hjgvphg0fmj3k9l6cx65ux9u"
jsonStringString (JSON)"{Encryption:{type:"JWT",alg:"HS256"},contracts:[{target:"contractor1",email:"contractor1@gmail.com"}]}"

Return value ​

json5
{
  typeUrl: '/firmachain.firmachain.contract.MsgAddContractLog',
  value: {
    creator: 'firma1nssuz67am2uwc2hjgvphg0fmj3k9l6cx65ux9u',
    contractHash: 'da39330a6dfd90a91563603950f742240fa222580beecf36e141fe6410184e8b',
    timeStamp: 1669199517,
    eventName: 'createContract',
    ownerAddress: 'firma1nssuz67am2uwc2hjgvphg0fmj3k9l6cx65ux9u',
    jsonString: '"{}"'
  }
}

2. getUnsignedTxCreateContractFile ​

This function generates "createContractLog" transactions as messages. Events that happen in a contract life cycle are contained in the addContractLog. Once the gas fee for generating a message is calculated, the transaction is created by the function that executes messages.
&#xNAN;* For a more detailed guide on calculating the gas fee and executing messages, please refer to functions 3 and 4.

Parameters

NameTypeExample
walletObject (FirmaWalletService)You can check how to use your wallet in the "firma-js of the Github repository".
fileHashString"da39330a6dfd90a91563603950f742240fa222580beecf36e141fe6410184e8b1669119707"
timeStampNumber1669182016039
ownerListArray (String)["firma1epg9kx7nqz32dykj23p6jreqfh5x0wdy5a43qc"]
metaDataJsonStringString (JSON)'{"storage":"ipfs","encryptIpfsHash":["U2FsdGVkX19UsL3m7Cq2bOtTCQArqZTuLgz7mfdRtXM2MnIgm67GM26GtPELsVL8s4+IN2Vj9FbFzpFj3rwfaw=="]}'
txMisc (Not required)Object (TxMisc){fee:200000,gas:163821,memo:"custom message"}

Return value ​

json5
{
  typeUrl: '/firmachain.firmachain.contract.MsgCreateContractFile',
  value: {
    creator: 'firma1nssuz67am2uwc2hjgvphg0fmj3k9l6cx65ux9u',
    fileHash: 'da39330a6dfd90a91563603950f742240fa222580beecf36e141fe6410184e8b1669199724',
    timeStamp: 1669199724,
    ownerList: [
      'firma1nssuz67am2uwc2hjgvphg0fmj3k9l6cx65ux9u',
      'firma1nssuz67am2uwc2hjgvphg0fmj3k9l6cx65ux9u'
    ],
    metaDataJsonString: '"{}"'
  }
}

3. getGasEstimationSignAndBroadcast ​

This function estimates the gas fee required when generating transactions of the message list created by functions 1 and 2. When using Bulk Insert, there is a high chance where the gas fee could exceed the default gas fee(0.02fct). Therefore, prior to the execution of the transaction, the gas fee must be estimated properly.

Parameters ​

NameTypeExample
walletObject (FirmaWalletService)You can check the usage through the "Github example source".
msgListmsgList (EncodeObject[])1 or 2 "Return value" Array value.

Return value ​

json5
239964

Example Run Image ​

FirmaChain guide screenshot

4. signAndBroadcast ​

This function lists the messages generated from functions 1 and 2 and then generates the message list as transactions.

Parameters ​

NameTypeExample
walletObject (FirmaWalletService)You can check how to use your wallet in the "firma-js of the Github repository".
msgListmsgList (EncodeObject[])1 or 2 "Return value" Array value.
txMisc (Not required)Object (TxMisc){fee:200000,gas:163821,memo:"custom message"}

Return value ​

json5
{
  code: 0,
  height: 428306,
  rawLog: '[
  {
    "events": [{
      "type":"message",
      "attributes":[{"key":"action","value":"CreateContractFile"}]
    }]
  }, {
    "msg_index":1,
    "events":[{
      "type":"message",
      "attributes": [{"key":"action","value":"CreateContractFile"}]
    }]
  }, {
    "msg_index":2,
    "events":[{
      "type":"message",
      "attributes": [{"key":"action","value":"CreateContractFile"}]
    }]
  }]',
  transactionHash: 'DC03E4872A97325D3AAA58B9B6296476E32AD42D8A448F6C7460F9D260CCBB56',
  gasUsed: 98872,
  gasWanted: 113703
}

Image of the transaction verified in Blockchain Explorer ​

FirmaChain guide screenshot

5. Parameter Description ​

NameDescription
walletUnique wallet parameter created from the user’s Mnemonic.
This parameter can be called by using the Wallet.fromMnemonic function from the FirmaSDK module.
contractHash &
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.
timeStampThis 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.
eventNameThis 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”.
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”).
ownerListThis 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.
jsonString &
metaDataJsonString
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.
* There are no set standard so please customize this parameter to suit the purpose of your project.
msgListThis parameter contains the list of messages that is used to execute transactions.
* List can contain different transaction messages.
txMiscThis object contains the gas fee that is deducted when a transaction is called upon.
* The default gas fee is set at 0.02fct.