How can i copy block aspects in hyperledger fabric?

0 votes
Hi.. i am working on a project where i have one chaincode and now i want to create a chain code with same chaincode aspects such as world state, keys and others attributes.. I can do this by changing some go code and deploying but if i do this then it will create a new chaincode with its own attributes/state. But i want it to have attributes of the present chaincode that i have.. How can i do this?
Jul 6, 2018 in Blockchain by slayer
• 29,050 points
37 views

1 answer to this question.

0 votes
There are three ways you can do this:

1. Chaincode Upgrade:
In this type, you can inherit the properties of the chaincode that you already have by keeping the name of the new chaincode same as the current chaincode but by changing the version. So when the new chaincode is instantiated, it inherits the full state of the previous chaincode. You can learn more about this on: http://hyperledger-fabric.readthedocs.io/en/latest/chaincode4noah.html#upgrade

2. Chaincode to chaincode invocations:
This is achieved by using the InvokeChaincode() API. While instantiating the new chain code, use the InvokeChaincode() API in the Init() function. The second chaincode will invoke the previous chaincode and inherit paticular states. It can reference or copy the states.. If you are using this method then you need particular query functions.

3. Hybrid: In this method, you can use both the above mentioned ways. First upgrade the chaincode and then add
query functions required by the chaincode.
answered Jul 6, 2018 by digger
• 26,550 points

Related Questions In Blockchain

+4 votes
2 answers

How do I create a new block in Hyperledger Fabric?

This link might help you: https://github.com/hyperledger/fabric-sample ...READ MORE

answered Oct 11, 2018 in Blockchain by Sahu
475 views
+1 vote
2 answers

How can I traverse the blocks of transactions in hyperledger fabric?

For hyperledger fabric you can use query ...READ MORE

answered May 8, 2018 in Blockchain by Rachel
1,786 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Invalid Batch or signature in Savtooth

This will solve your problem import org.apache.commons.codec.binary.Hex; Transaction txn ...READ MORE

answered Aug 1, 2018 in Blockchain by digger
• 26,550 points
68 views
+1 vote
1 answer
0 votes
1 answer
0 votes
1 answer

How i can use nodejs to watch transactions in bitcoin network?

you can use  const Socket = require('blockchain.info/Socket'); const mySocket ...READ MORE

answered Jul 9, 2018 in Blockchain by digger
• 26,550 points
46 views