Error when instantiating a node chaincode on a channel

I’m trying to instantiate an already installed node chaincode on a channel, but it fails with error: failed to invoke chaincode name:"lscc" , error: container exited with 0

What I did up to this point:

  1. Successfully started a network with 2 organizations with 2 peers for each organization and a raft consensus using ./byfn up -c some-channel -s couchdb -o etcdraft -l node script from Building your first network (v1.4) tutorial. The network already has one instantiated chaincode named mycc.
  2. Connected to the network from my script using Node.js SDK. I am able to successfully invoke read and write chaincode methods of the mycc chaincode from my script.
  3. Installed new chaincode on all 4 peers using each organization’s admin identities. I am able to confirm that the chaincode is indeed installed by querying installed chaincodes on a peer. Also peer container logs also confirm that the chaincode is installed successfully.
  4. Tried to instantiate the installed chaincode and encountered the above-mentioned error.

Here is how I’m trying to instantiate my chaincode:

// Load the network configuration
        const ccpPath = path.resolve(__dirname, ccpName);
        let ccp = JSON.parse(fs.readFileSync(ccpPath, 'utf8'));

        // Create a new file system based wallet for managing identities.
        const walletPath = path.join(process.cwd(), walletName);
        const wallet = new FileSystemWallet(walletPath);
        console.log(`Wallet path: ${walletPath}`);

        // Check to see if we've already enrolled the user.
        const identity = await wallet.exists(identityName);

        if (!identity) {
            console.log(`An identity for the user ${identityName} does not exist in the wallet`);
            console.log('Run the registerUser.js application before retrying');

        // Create a new gateway for connecting to our peer node.
        const gateway = new Gateway();
        await gateway.connect(ccp, { wallet, identity: identityName, discovery: { enabled: true, asLocalhost: true } });

        // Get the network (channel) our contract is deployed to.
        const network = await gateway.getNetwork(channelName);
        const client = gateway.getClient();
        const channel = network.getChannel(channelName);

        let channelPeers = channel.getPeers().map(peer => peer._peer);
        // console.log(channelPeers);

        const endorsementPolicy = {
            identities: [
                { role: { name: 'member', mspId: 'Org1MSP' }},
                { role: { name: 'member', mspId: 'Org2MSP' }}
            policy: {
                '1-of': [{ 'signed-by': 0 }, { 'signed-by': 1 }]
        const instantiateChaincodeRequest = {
            targets: channelPeers,
            chaincodeType: 'node',
            chaincodeId: 'deal',
            chaincodeVersion: '1.0.0',
            txId: client.newTransactionID(true),
            'endorsement-policy': endorsementPolicy

        const instantiateResponse = await channel.sendInstantiateProposal(instantiateChaincodeRequest, 300000);


This script resolves to this error:

{ Error: chaincode registration failed: container exited with 0
  at self._endorserClient.processProposal (/home/projects/testing/vs-code-hlf-sc/node_modules/fabric-client/lib/Peer.js:144:36)
  at Object.onReceiveStatus (/home/projects/testing/vs-code-hlf-sc/node_modules/grpc/src/client_interceptors.js:1212:9)
  at InterceptingListener._callNext (/home/projects/testing/vs-code-hlf-sc/node_modules/grpc/src/client_interceptors.js:568:42)
  at InterceptingListener.onReceiveStatus (/home/projects/testing/vs-code-hlf-sc/node_modules/grpc/src/client_interceptors.js:618:8)
  at callback (/home/projects/testing/vs-code-hlf-sc/node_modules/grpc/src/client_interceptors.js:847:24)
status: 500,
payload: <Buffer >,
 { url: 'grpcs://localhost:9051',
   name: '',
   options: [Object] },
isProposalResponse: true }

Here are relevant peer container logs:

2020-09-08 08:27:09.274 UTC [endorser] callChaincode -> INFO 0c7 [][7fdf845f] Entry chaincode: name:"lscc" 
2020-09-08 08:27:09.277 UTC [lscc] executeInstall -> INFO 0c8 Installed Chaincode [deal] Version [1.0.0] to peer
2020-09-08 08:27:09.277 UTC [endorser] callChaincode -> INFO 0c9 [][7fdf845f] Exit chaincode: name:"lscc"  (3ms)
2020-09-08 08:27:09.277 UTC [comm.grpc.server] 1 -> INFO 0ca unary call completed grpc.service=protos.Endorser grpc.method=ProcessProposal grpc.peer_address= grpc.code=OK grpc.call_duration=3.376691ms
2020-09-08 08:45:34.201 UTC [endorser] callChaincode -> INFO 0dd [some-channel][d3a00bc9] Entry chaincode: name:"lscc" 
2020-09-08 08:46:16.593 UTC [] func2 -> INFO 0de 
2020-09-08 08:46:16.593 UTC [] func2 -> INFO 0df > [email protected] start /usr/local/src
2020-09-08 08:46:16.593 UTC [] func2 -> INFO 0e0 > node deal-contract.js "--peer.address" ""
2020-09-08 08:46:16.593 UTC [] func2 -> INFO 0e1 
2020-09-08 08:46:17.141 UTC [dockercontroller] func2 -> INFO 0e2 Container has closed its IO channel
2020-09-08 08:46:17.314 UTC [endorser] callChaincode -> INFO 0e3 [some-channel][d3a00bc9] Exit chaincode: name:"lscc"  (43113ms)
2020-09-08 08:46:17.314 UTC [endorser] SimulateProposal -> ERRO 0e4 [some-channel][d3a00bc9] failed to invoke chaincode name:"lscc" , error: container exited with 0*RuntimeLauncher).Launch.func1
chaincode registration failed

The logs say that the chaincode was installed successfully and then the logs show an error with lscc chaincode. So I assume the error has something to do with building stage of the chaincode. But the very same chaincode works perfectly when I deploy it with VS Code IBM Blockchain Extension.

What I’ve tried so far:

  • Providing / not providing endorsement policy and tweaking instantiare request object in numerous ways
  • Using different identities
  • Inspecting logs of the ccenv container that is spawn for ~30 seconds when instantiation request is received. There were no errors
  • Restarting the network from scratch, deleting all fabric docker images and starting anew.

So basically the question is:
How can instantiate an already installed chaincode on a channel using Node.js SDK correctly?

My environment:

  • Ubuntu 18.04

  • Hyperledger Fabric v1.4

  • fabric-network 1.4.8

  • fabric-client 1.4.10

  • node 10.22.0

  • npm 6.14.6

  • docker 19.03.12, build 48a66213fe

  • docker-compose 1.26.2, build eefe0d31

  • chaincode is developed using fabric-contract-api

Source: Docker Questions