ADARSH MORADIYA
ADARSH MORADIYA

Reputation: 161

Failed to deploy multiple chaincode on same peer in hyperledger fabric

I am trying to set up a hyperledger network with four different organizations and four peers (one from each organization).

I have to deploy two chain codes on all four peers. one is InsuranceChaincode and ERC20TokenChaincode.

When I try to deploy both chaincodes on the same peers, it does not deploy properly. I'm not able to invoke any function from one of the chaincode (ERC20TokenChaincode). But I can call functions from InsuranceChaincode.

I have already set the network script by taking references from fabric-samples. And I have tried single chaincode deployment for both of them, and it is working fine.

This is how I have exported my chain codes:

const InsuranceClaim = require("./lib/insuranceChaincode");
const ERC20Token = require("./lib/ERC20Chaincode");

module.exports.ERC20Token = ERC20Token;
module.exports.InsuranceClaim = InsuranceClaim;
module.exports.contracts = [ERC20Token, InsuranceClaim];

Upvotes: 0

Views: 133

Answers (1)

bestbeforetoday
bestbeforetoday

Reputation: 1649

If your chaincode includes multiple smart contracts, they need to be distinguished by having different smart contract names. For a named smart contract, the client needs to specify the contract name when invoking transaction functions on that contract. Only one smart contract can be the "default" smart contract, which is unnamed.

The Defining your contract classes section of this tutorial page explains how the smart contract name is defined by the argument to the super-class constructor:

https://hyperledger.github.io/fabric-chaincode-node/main/api/tutorial-deep-dive-contract-interface.html

The client API documentation mentions the contract name as an optional argument when calling the Network's getContract() method. At the implementation level, this prepends the smart contract name followed by a colon (:) to the transaction name when invoking a transaction function within a specific chaincode. If using the CLI to invoke the transaction function, you would specify this qualified transaction name explicitly, for example SmartContractName:TransactionFunctionName.

Upvotes: 1

Related Questions