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,370 points
786 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.

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,740 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
2,653 views
+2 votes
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
5,373 views
0 votes
1 answer
0 votes
1 answer

Hyperledger Sawtooth vs Quorum in concurrency and speed Ask

Summary: Both should provide similar reliability of ...READ MORE

answered Sep 26, 2018 in IoT (Internet of Things) by Upasana
• 8,620 points
1,451 views
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,740 points
1,003 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,740 points
1,282 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP