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.
Related
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)
I want to examine the gRPC Message Flow from invoking a smart contract until a block is created:
I exactly want to examine these steps (the used message stream) I later found composed in a whole block (If I understand it right these parts are only put together at the end in a block some adds):
Invoke call of a Chaincode e.g. Change Value "a" to "10" in using CLI:
1. CLI sends Proposal to Endorser -> [SignedProposal with Signature, Proposal:(Header+Payload)]
2. Endorser sends Proposal Response back to CLI -> [ProposalResponse with its Endorsement,
PropRespPayload]
3. CLI packs endorsements into Transaction + sends them to orderer for block creation
4. Block is created by orderer + validation of sign.
What is the fastest way to fetch them?
What I did:
(Not good, rather laborious) Try to modificate code in binaries like "peer" where gRPC is handled, rebuild images:
My problem is that I am able to build and modificate the binaries like the peer executable (which is used in images and started inside a docker container like the peer), but I finally want to use them and make us of the sample projects like first-network, where I can invoke a transaction and log with own implementations what is gRPCed there. What I could do here and what is very time consuming is to rebuild all images and later make all sample files fitting to the new environement and implement this parts, but I think there have to be a faster way of evaluating the message flow (with the output of the full gRPC message stream /decoded and encoded).
(I think the best way for now):
I have not discovered faster ways yet (am new to Go and gRPC), instead of logging what gRPC is sending with wireshark and try to decode it (but it won't work for all parts, cause of incomplete messages or afraid). For some parts (proving sign) it is necessary that I have the marshalled version of some objects. This is what I need the most actually, but therefore I need to understand the gRPC content of the wiresharked parts :)
Do you have any suggestions for me? Would you rather go on with Way1 or Way2? Or am I on a too complicated way to fix it?
Is there a faster way existing? I mean I need the unmarshaled parts, but also the marshaled content of some objects and I have the proto files (when these are the correct ones for the logging parts I did in wireshark while an invoke was take place).
You can make your own gRPC api by following those simple steps:
1st you need to make a signed proposal. To make a signed proposal, you can get idea from endorser_test.go file.
To send a signed proposal to peer for endorsement, you need a ProcessProposal gRPC call where you can get the response from endorsing peer and your need to create a EndorserClient too.
After that you need to collect all endorsements from peers and have to make signed envelope
To make a signed envelope, you can take help from txutils.go file
To send a signed envelope to orderers you need to broadcast your envelope to orderers with Send gRPC call where we need to create a AtomicBroadcastClient.
This seems closely related to the question you posted a month or so ago.
As you point out, if you wish to do things like validate signatures, you will need the marshaled form of the messages, but if you wish to inspect the messages, you will need to unmarshal them.
I would think that option 1 (modifying the code to dump the information you need) is still the most useful. As you can perform whatever serialization, persistence, or analysis inside the code itself. If you simply store these data structures to disk via something like wire-shark, then you will need to track them, parse them, etc., which seems like more work to me.
If you have marshaled messages on disk, you can try using a tool like configtxlator to unmarshal the messages to a more friendly JSON format, if you have tracked the appropriate type, though this still seems more difficult than simply injecting code to me.
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
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
I am building blockchain explorer. I have my own blockchain. In that, i want to search details of a given address from blockchain. There is no direct API to get detail of an address, could anybody help how to this ?
Thanks in Advance.
Two options:
option 1:
blockchain.info has an open API (REST + JSON)
https://blockchain.info/it/api/blockchain_api
here how:
https://blockchain.info/it/rawaddr/$bitcoin_address
bear in mind that you can only acquire info from an address that actually moved at least once some bitcoin on the network. If you just create a new wallet and do not transact then the public address is non existent on the blockchain (i.e. there's no difference between a newly generated address and a non existent address). That's the "shameful" approach as you are building a blockchain explorer using another blockchain explorer, see option 2 for the correct approach:
option 2:
Run a bitcoin node on your own and query your stuff on it. You may not be able to run a node on a normal hosting, probably you need something more like an Amazon AWS instance or host on your own server
I see from comments you are using peercoin (https://github.com/peercoin/peercoin). If it's a fork of Bitcoin, then the following holds:
In basic Bitcoin full-node setup, it's impossible to query random address. You can add some addresses to track, but think of it as of "yours".
There are modifications to the bitcoin-core, that have a addressindex option. The one I am aware of is bitcore: https://github.com/bitpay/bitcore-node.
Here's how to run your own blockchain explorer for Bitcoin using bitcore's insight: https://github.com/bitpay/insight-api
npm install -g bitcore#latest
bitcore create mynode
cd mynode
bitcore install insight-api
bitcore install insight-ui
bitcore start
This will launch full node in the needed mode (addressindex=1 enabled, etc) and a webservice with API and UI, similar to: https://insight.bitpay.com/.
Config file will be located at mynode/bitcore-node.json
Bitcore's docs and not well maintained, some are outdated. Try the code, but don't give up if it fails. For more information, refer to the source code.
P.S. I am not sure how to convert this to run with your blockchain, but if it's similar to bitcoin, it should be possible. I think it's closest you can get without writing your own explorer.