Abhishek
Abhishek

Reputation: 63

How to share data between two chaincodes on Hyperledger Fabric on Single Channel?

I have started to learn Hyperledger Fabric and Composer. I am able to create a simple Business Network using Composer and deploy it on Fabric, but I have a question. Let's say I have 2 BNA (instantiated on single channel) files both having same namespace (org.example) and having same participant name as well, as Customer (identifier will be org.example.Customer). Is there any way that I can access the participants created by first Business Network App in another Business Network App? Logically what I can think of is since both have been instantiated in the same channel with different chaincode and same model file, data should be cross accessible. But it isn't.

Upvotes: 2

Views: 1068

Answers (2)

MrL
MrL

Reputation: 1720

Is available a tutorial about how to interact from a bna to another one.

Here the link to the official Hyperledger Composer documentation.

https://hyperledger.github.io/composer/latest/tutorials/invoke-composer-network

Upvotes: 0

david_k
david_k

Reputation: 5868

Although chaincodes share the same ledger when installed on the same channel (and as business networks are just chaincodes this applies to them also). Fabric still partitions the data that a chaincode can read/write by it's chaincode id. So when you install 2 business networks onto the same channel they will have different chaincode id's and so their data is separately partitioned.

As mentioned in the other answer (although the link is not quite correct), what you can do is make use of a feature of composer to be able to invoke another business network on the same or even different channel from the executing business network. As the 2 business networks are on the same channel you can not only read information but you are also able to invoke transactions that can change information. (You can only read information if the business networks are on different channels).

The correct link for the tutorial is here https://hyperledger.github.io/composer/latest/tutorials/invoke-composer-network Unfortunately this tutorial is rather basic and only offers a glimpse of how to interact with other business networks.

Upvotes: 2

Related Questions