Bulk Insert

계약 진행 시 addContractLog와 createContractFile을 하나의 트랜잭션에 2개 이상을 담아 보내거나, 여러 계약서를 한번에 대용량으로 보낼 때 사용합니다.

Contents

NameDescription

addContractLog 트랜잭션 생성 메세지를 얻을 수 있습니다.

addContractFile 트랜잭션 생성 메세지를 얻을 수 있습니다.

트랜잭션 메시지 배열의 예상 가스 비용을 얻을 수 있습니다.

여러 개의 트랜잭션을 한번에 실행할 수 있습니다.

API 호출을 위한 파라미터들의 정보입니다.

1. getUnsignedTxAddContractLog

계약 진행에서 발생한 이벤트를 기록할 수 있는 addContractLog 트랜잭션을 메시지 형태로 생성합니다. 메세지는 가스 계산 후 메세지를 실행할 수 있는 함수를 통해 트랜잭션을 생성하게 됩니다. * 가스 계산과 메시지 실행 방법은 3, 4번 함수를 확인해주세요.

Parameters

NameTypeExample

wallet

Object (FirmaWalletService)

You can check the usage through the "Github example source".

contractHash

String

"da39330a6dfd90a91563603950f742240fa222580beecf36e141fe6410184e8b1669119707"

timeStamp

Number

1669182016039

eventName

String

"createContract"

ownerAddress

String

"firma1nssuz67am2uwc2hjgvphg0fmj3k9l6cx65ux9u"

jsonString

String (JSON)

"{Encryption:{type:"JWT",alg:"HS256"},contracts:[{target:"contractor1",email:"contractor1@gmail.com"}]}"

Return value

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

2. getUnsignedTxCreateContractFile

계약서를 체인에 기록하는createContractLog 트랜잭션을 메시지 형태로 생성합니다. 메세지는 가스 계산 후 메세지를 실행할 수 있는 함수를 통해 트랜잭션을 생성하게 됩니다. * 가스 계산과 메시지 실행 방법은 3, 4번 함수를 확인해주세요.

Parameters

NameTypeExample

wallet

Object (FirmaWalletService)

You can check the usage through the "Github example source".

fileHash

String

"da39330a6dfd90a91563603950f742240fa222580beecf36e141fe6410184e8b1669119707"

timeStamp

Number

1669182016039

ownerList

Array (String)

["firma1epg9kx7nqz32dykj23p6jreqfh5x0wdy5a43qc"]

metaDataJsonString

String (JSON)

'{"storage":"ipfs","encryptIpfsHash":["U2FsdGVkX19UsL3m7Cq2bOtTCQArqZTuLgz7mfdRtXM2MnIgm67GM26GtPELsVL8s4+IN2Vj9FbFzpFj3rwfaw=="]}'

txMisc (Not required)

Object (TxMisc)

{fee:200000,gas:163821,memo:"custom message"}

Return value

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

3. getGasEstimationSignAndBroadcast

1, 2번 함수를 통해 생성한 메세지를 배열을 트랜잭션 생성할 때 사용될 가스 예상 비용을 얻을 수 있습니다. 이 함수가 필요한 이유는 Bulk Insert 사용 시 default 가스 비용(0.02fct)을 초과할 가능성이 높습니다. 그렇기에 예상 가스 비용을 구해야 합니다.

Parameters

NameTypeExample

wallet

Object (FirmaWalletService)

You can check the usage through the "Github example source".

msgList

msgList (EncodeObject[])

1 or 2 "Return value" Array value.

Return value

239964

Example Run Image

4. signAndBroadcast

1, 2번 함수를 통해 생성한 메세지를 배열 형태로 만든 후 트랜잭션 생성할 수 있습니다.

Parameters

NameTypeExample

wallet

Object (FirmaWalletService)

You can check the usage through the "Github example source".

msgList

msgList (EncodeObject[])

1 or 2 "Return value" Array value.

txMisc (Not required)

Object (TxMisc)

{fee:200000,gas:163821,memo:"custom message"}

Return value

{
  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

5. Params

NameDescription

wallet

사용자의 Mnemonic으로 생성한 고유 지갑 변수입니다. FirmaSDK 모듈 중 Wallet.fromMnemonic 함수를 통해 선언할 수 있습니다.

contractHash &

fileHash

파일 또는 텍스트 정보를 고정된 길이로 매핑한 정보입니다. 체인에서 Contract 추적을 위한 정보로 활용이 가능하며, 하나의 Contract Hash에 여러 개의 Log를 추가할 수 있습니다. 고유 값 사용을 권장하며, FirmaUtil을 통해 파일 및 텍스트의 해시 값을 가져올 수 있습니다.

timeStamp

해당 이벤트 또는 행동, 결과에 대한 로그가 발생한 시점을 의미합니다. "Unix time stamp" 형식이며, 숫자 타입으로 작성해주세요.

eventName

이벤트 또는 행동, 결과에 대한 정보를 의미합니다. 계약 진행을 예로 들어 "계약 생성", "서명자 초대", "계약자1 서명", "모든 서명 완료", "계약 완료" 로 사용될 수 있습니다.

ownerAddress

피르마체인 지갑 주소를 입력해주세요. 지갑 주소의 대상은 누구나 될 수 있으며, "서비스 대표 지갑 주소", "서명자 지갑 주소" 등을 예시로 들 수 있습니다.

ownerList

계약과 연관있는 사용자의 지갑 주소 배열입니다. ownerAddress와 동일한 목적으로 추가할 수 있습니다.

jsonString & metaDataJsonString

계약과 관련된 추가 정보를 기록할 수 있습니다. 예를 들어 공개키(암호화), 계약서 저장 공간 또는 다운로드 링크, 계약 진행자의 이메일 주소 등이 될 수 있습니다. JSON 형식의 문자열 타입으로 작성해주세요.

* 정해진 규격은 없으며 커스텀 하여 사용하시면 됩니다.

txMisc

트랜잭션 호출 시 사용될 수수료 비용을 담고 있는 오브젝트입니다. * 가스 계산 없이 사용할 경우 기본 가스 비용은 0.02fct입니다.

msgList

트랜잭션을 실행할 수 있는 메세지를 담고 있는 배열입니다. * 배열은 서로 다른 트랜잭션 메시지를 담을 수 있습니다.

Last updated