Explore Courses Blog Tutorials Interview Questions
0 votes
in Blockchain by (4.1k points)
The Chaincode for Developers tutorial uses only one chaincode.

I know multiple chaincode is supported as well, and the aforementioned tutorial uses a chaincode called SimpleAsset.

Does it imply that there is an expectation to have 1 chaincode for 1 asset? If my application involves several asset types (eg. Widgets and Gadgets), is the best practice to have a separate chaincode managing the lifecycle of each asset type? Or a single chaincode?

1 Answer

0 votes
by (14.4k points)

It is indeed possible to have one single chaincode for managing multiple assets. There is no fixed rule on how to map assets to chaincode, but here are some guidelines that I found to be useful:

  • When assets are tightly coupled, I prefer to have a single chaincode to manage them, especially when the life cycle of one asset depends on the life cycle of another.

  • If you expect a particular asset changes in its logic and life cycle then it is best to isolate it in its own chaincode. 

  • Try to keep your chaincode small. 

  • When the number of assets is less and there is not much logic in them, you should use a single chaincode.

Browse Categories