I am trying using PDC on hyperledger fabric for testing.
So then, I heard that PDC needs specific chaincode for itself, not exactly.
For using PDC, do it need something special chaincode only for PDC??
First of all, you need to make colletions_config.yaml file.
When you instantiate the chaincode, specify the flag --collections-config [path]
Chaincode Functions:
stub.GetPrivateData()
stub.PutPrivateData()
See this page
https://hyperledger-fabric.readthedocs.io/en/release-1.4/private_data_tutorial.html
Related
I have gone through documentation and I want to secure private data using GetTransient but I am not having idea that where to put collection-config.json.
If it is needed to be put under package root, then when should I pass it by flag --collections-config. As per documentation, it is suggested to pass for all three later methods - approveformyorg, checkcommitreadiness & commit. I could not get example for this (node chaincode example will be preferred).
Any help or direction, will be appreciated.
--collections-config is a flag on the peer lifecycle chaincode commands. It is independent of the chaincode package and chaincode language, the actual JSON file can reside anywhere as long as the flag specifies the location.
You can see an example in the private data tutorial.
I'm new to hyperledger fabric and I'm trying to query a chaincode for a specific key. I can retrieve the json data for the key but I would also like to get the block number and transaction id related to the last PutState call which created/updated the data I'm retrieving from couchDB. Is there a way to do that?
Thanks in advance
Responding to help anyone who could have the same problem and to check if the solution I adopted makes any sense. So as I understand Hyperledger allows you to get the transaction id before your transaction is submitted to the blockchain wich I found peculiar after having worked with ethereum. Using golang me and my colleagues found this line:
txID := ctx.GetStub().GetTxID();
So our solution was to save the transaction id inside the data we are storing in the blockchain, to easily retrieve it by a simple query (to couchDB for example).
In the end we retrieved the informations bound to the txid by calling the "GetBlockByTxID" sc of the "qscc" chaincode (present by default in every channel of hyperledger as far as I understand) using the "fabric-network" node module, and decoded it using "fabric-common" node module's BlockDecoder:
result = BlockDecoder.decode(result)
We have set up a hyperledger fabric network and uploaded a history of transactions. Realized that part of these transactions are incorrect and hence we want to exclude them from chaincode queries.
From whatever I understand, the shim API DelState can be used to delete an asset from World state and hence this will not appear in chaincode queries.
But, we do not want to delete the entire asset. We just want to mark few transactions as invalid.
I am working with the Hyperledger Fabric, I want to write a chaincode in go lang which takes list of arguments which contains a list in it.
For example: client will be calling chaincode function with parameters passed are [uname,job,[21,23,45]].
Can anyone help me in reading data in chaincode?
You can send them as ["uname","job","21","23","45"], and in chaincode you can store the arguments by assigning them to your asset.
I want to test pii-network sample of hyperledger composer. I can add two participants but when I want to sumbit the AuthorizeAccess transaction I get this error: "Instance admin has a property named authorized which is not declared in org.hyperledger.composer.system.NetworkAdmin".
this may have been an error you saw in Playground. Please update (ie re-install) your Composer dev environment to the current release v0.15.0 (as of Nov 10th) and this problem will be resolved (in 0.14.3 specifically, there was a temporary issue with transactions ie in the Playground only). You will need to install the modules as per the docs -> https://hyperledger.github.io/composer/installing/development-tools.html - this will get the latest release. Make sure you do a full teardown using the scripts you downloaded in fabric-tools (as your CC containers will be 0.14.3 or earlier and thus out of date) and that you then subsequently, do an npm -g uninstall of the same module names eg composer-cli, composer-playground etc and such that they are all at the same level (0.15.0) upon subsequent npm -g install of same composer modules.
You get this error because you have connected to the business network as the "admin" identity. It is bound to the org.hyperledger.composer.system.NetworkAdmin participant which is a system participant and not a participant the the PII sample is expecting.
You should issue an identity for one or more of the participants you have created in the PII network, then switch to using one of those participants before you attempt the authorizeAccess transaction.
The PII example could benefit from improved ACL rules to stop this error by only allowing the right type of participant to submit that transaction