javahyperledger-fabrichyperledger-chaincode

How can i implement multiple smart-contract in a single chain-code using java?


is it possible to implement multiple smart contracts in a single chain-code package in hyper ledger fabric 2.0? For example, I have two contracts Car Transfer and Money Transfer. Is it possible to have them in a single chain-code?

I was trying to implement two smart contracts namely Car Transfer and Money Transfer. Now when I call the methods in Car transfer they work fine. but when I call the methods of Money Transfer it shows the error "Undefined contract method"


Solution

  • Although discussing Node.js chaincode, this answer also applies to your question:

    Failed to deploy multiple chaincode on same peer in hyperledger fabric

    The principles are the same regardless of the smart contract implementation language (Go, Node, Java). For a Java implementation, only one of the smart contracts within the chaincode package can be the default smart contract (marked with the @Default annotation), and accessed using only the chaincode name. All others must be referred to using their chaincode and contract name (defined in the @Contract annotation).

    See the Fabric samples for examples of annotation usage.