Welcome to the Linux Foundation Forum!

submitTransaction.js Issue: Commit of tx failed.

After following the docs' steps of deploying a production network, I think I finally achieve the goal (without mutual TLS) in a local environment (5 orderers, 5 peers, 5 CAs and 5 TLSCA). The problem appears when I use the application with this network configuration. Both enrollUser.js and registerUser.js works but submitTransaction does not. Here I got the error logs. It looks like the tx proposal is sent 3 times to the same peer because I attached to the 5 dev-peers docker containers and only one executes the function. If I execute the peer invoke command using the bash, the tx updates the world state. I do not know if I must point to the endorsers inside the node.js application.

I have searched on Google but I can not solve this problem.

Any help would be appreciated.

And the submitTransaction.js

'use strict';

const fs = require('fs');
const path = require('path');
const { Wallets, Gateway } = require('fabric-network');

const testNetworkRoot = path.resolve(require('os').homedir(), 'go/src/github.com/hyperledger/fabric-samples/tfm/tfm-network/fabric-ca/');

async function main() {
const gateway = new Gateway();
const wallet = await Wallets.newFileSystemWallet('./wallet');

  1. try {
  2. let args = process.argv.slice(2);
  3.  
  4. const identityLabel = args[0];
  5. const functionName = args[1];
  6. const chaincodeArgs = args.slice(2);
  7.  
  8. // const orgName = identityLabel.split('@')[1];
  9. const orgNameWithoutDomain = 'originator';
  10.  
  11. let connectionProfile = JSON.parse(fs.readFileSync(
  12. path.join(testNetworkRoot,
  13. orgNameWithoutDomain,
  14. `/connection-${orgNameWithoutDomain}.json`), 'utf8')
  15. );
  16.  
  17. let connectionOptions = {
  18. identity: identityLabel,
  19. wallet: wallet,
  20. // clientTlsIdentity: 'tlsadmin@originator',
  21. discovery: {enabled: true, asLocalhost: true}
  22. };
  23.  
  24. console.log("Here");
  25. console.log('Connect to a Hyperledger Fabric gateway.');
  26. await gateway.connect(connectionProfile, connectionOptions);
  27.  
  28. console.log('Use channel "securitization".');
  29. const network = await gateway.getNetwork('securitization');
  30.  
  31. console.log('Use Origination.');
  32. const contract = network.getContract('securitizationcode');
  33.  
  34. console.log('Submit ' + functionName + ' transaction.');
  35. contract.createTransaction(functionName)
  36. // const response = await contract.createTransaction(functionName, ...chaincodeArgs);
  37. const response = await contract.submitTransaction(functionName, ...chaincodeArgs);
  38. if (`${response}` !== '') {
  39. console.log(`Response from ${functionName}: ${response}`);
  40. }
  41.  
  42. } catch (error) {
  43. console.log(`Error processing transaction. ${error}`);
  44. console.log(error.stack);
  45. } finally {
  46. console.log('Disconnect from the gateway.');
  47. gateway.disconnect();
  48. }

}

main();

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Comments

  • Posts: 193

    Hello, Let's see if we can determine what is happening. You stated you were following the docs' steps of deploying a production network It would be helpful if you could specify what lab exercise you were attempting before your error message for the submitTransaction request. Thanks Bobbi

  • Hi Bobbi, I followed these instructions to create my own network and I used the Main Application Components content (registerUser.js, addToWallet.js, enrollUser.js and submitTransaction.js of Balance Transfer app) to customize my client applications. I can register and enroll with each orgCA as well as addToWallet, but submitTransaction does not work (I also tried the createTransaction method instead of submitTransaction). However if I invoke that chaincode function using invoke command it works. Thanks, Oliver

  • Posts: 193

    :)

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Categories

Upcoming Training