Closed ajiths10 closed 3 months ago
The problem might be the way your client application is invoking the smart contract. You need to explicitly request the correct contract within the chaincode package, for example:
const assetTransfer = network.getContract("basic", "AssetTransferContract");
const carGarage = network.getContract("basic", "CarGarageContract");
It seems that one of the contracts — for me, the first in the list — is selected as the default contract. The default contract is the one that will be called if you do not explicitly provide the contract name, for example:
const defaultContract = network.getContract("basic");
Note that the two contracts share the containing chaincode's namespace within the ledger so will have visibility of each other's ledger entries. If you want the ledger state of the two smart contracts to be separate, you should deploy them in separate chaincode packages.
The problem might be the way your client application is invoking the smart contract. You need to explicitly request the correct contract within the chaincode package, for example:
const assetTransfer = network.getContract("basic", "AssetTransferContract"); const carGarage = network.getContract("basic", "CarGarageContract");
It seems that one of the contracts — for me, the first in the list — is selected as the default contract. The default contract is the one that will be called if you do not explicitly provide the contract name, for example:
const defaultContract = network.getContract("basic");
Note that the two contracts share the containing chaincode's namespace within the ledger so will have visibility of each other's ledger entries. If you want the ledger state of the two smart contracts to be separate, you should deploy them in separate chaincode packages.
@bestbeforetoday This was the issue. This solved my issue. Thank you.
I have a suggestion as well. It was very hard to find this information in the community. I think we need to include this information in the documentation.
@ajiths10 Which bits of information were missing for you? The client application side is documented in the API documentation:
It seems that you discovered how to define multiple contracts OK. Again, this is described in the API documentation:
@ajiths10 Which bits of information were missing for you? The client application side is documented in the API documentation:
It seems that you discovered how to define multiple contracts OK. Again, this is described in the API documentation:
I never thought it was on the client side. Anyway, thanks for the support :+1: . The issue is resolved, so I'm closing this issue.
Chaincode only accept the first contract in the export array.
I exported the contracts like this:
I have 2 channels - mychannel & garagecars
I deployed the chaincode to both channels using these commands: