1

In HLF 1.4 I can get transaction id after successful invoke operation. But In HLF 2.x I am not getting txid. I can see the data which I submitted to hlf in state database (couch db). Then why I am not getting txid. Here is last line in chaincode,

return shim.Success(nil)

submit transaction using node sdk.

result = await contract.submitTransaction(fcn, args);
console.log("Result:", result.toString())

The above line gives empty. Help me to get tx id.

Gurunath
  • 341
  • 3
  • 17

2 Answers2

7

Function submitTransaction has only 1 line of code:

return this.createTransaction(name).submit(...args);

So you can use this code instead of your code:

const transaction = contract.createTransaction(fcn);
const result = await transaction.submit(...args);
console.log("Result:", result.toString())
console.log("TxID:", transaction.getTransactionId());
harisato
  • 326
  • 1
  • 7
  • Where fcn is the name of the function => `const transaction = contract.createTransaction('NameOfTheFunction'); \n const result = await transaction.submit(...args);` – sibS Sep 27 '21 at 20:02
0

To add to @harisato_vn excellent answer, I've found that the official docs here use a capital letter at the end like getTransactionID(), but it actually is getTransactionId(). It drove me crazy for a little while.

Dharman
  • 30,962
  • 25
  • 85
  • 135
Matias Salimbene
  • 510
  • 6
  • 19