0

I am trying to create private data on Fabric version 1.2.0.

I have created the collections configuration file for storing private data.

[
{
     "name": "collectionData",
     "policy": "OR('Org1MSP.member','Org2MSP.member')",
     "requiredPeerCount": 0,
     "maxPeerCount": 3,
     "blockToLive":1000000,
     "memberOnlyRead": true
}
]

I have instantiated the chaincode using --collections-config flag.I have provided the configuration file correctly and successfully created the network.

I have developed the chaincode using nodejs.

  console.log("************************************");
  console.log("Private Data Testing");
  let sample = "test";
  await stub.putPrivateData("collectionData",transactionId,sample.toString());
  let response = await stub.getPrivateData("collectionData",transactionId);
  console.log("Response",response.toString());

I am doing the operations on behalf of Org1MSP.But I didn't get any response.It returns null while fetching the private details.

Could someone help me to resolve the issue?

  • try (where Key1 is your key) - `await stub.putPrivateData("collectionData","Key1",Buffer.from(sample.toString()));` then `let response = await stub.getPrivateData('collectionData',"Key1");` (not sure if you're using `transactionId` as a key in your scenario..) toString should default to `utf8` – Paul O'Mahony Mar 08 '19 at 10:11
  • @PaulO'Mahony I have tried as you mentioned. But still same issue persists.Any other suggestion?? – HF_developer Mar 08 '19 at 11:47
  • @PaulO'Mahony I am using version 1.2.1. Is this issue related to Fabric version? – HF_developer Mar 08 '19 at 12:24
  • PD came in with 1.2 https://hyperledger-fabric.readthedocs.io/en/release-1.2/private-data-arch.html?highlight=private%20data - these are the official Fabric releases FYI https://github.com/hyperledger/fabric#releases – Paul O'Mahony Mar 08 '19 at 16:50
  • ps. You may be also be aware that `GetPrivateData` doesn't read data from the private writeset, which has not been committed to the `collection`. In other words, `GetPrivateData` doesn't consider data modified by `PutPrivateData - that has not been committed. – Paul O'Mahony Mar 10 '19 at 17:14
  • If you use IBM Blockchain Platform "classic" solution (not beta 2.0), private data are not available in starter plan. (if this helps) – Itération 122442 Apr 04 '19 at 15:56
  • @cmr: did you manage to make this work? I'm having the same issue – Rouliboy Oct 09 '19 at 11:55

0 Answers0