Currently I'm working with Hyperledger Fabric chaincode and trying to get at least any info regarding current user who invokes/queries chaincode. How do I solve this problem?
Asked
Active
Viewed 152 times
1 Answers
0
I think the lib cid is what you are searching for. The functions GetID and GetMSPID are super helpful to distinguish between the callers.
Here is an example on how to use it in go
msp, err := cid.GetMSPID(stub)
if err != nil {
return false
}
This returns the name of the MSP and you can act depending on the result you get. You can even use this to give access to certain functions by MSPID.

kajuken
- 307
- 2
- 10
-
Thank a lot, Kajuken. That looks like it is what I need. – TienThanh Apr 25 '19 at 08:17
-
@TiếnThànhNguyễn Glad i could help. An upvote is appreciated! :) – kajuken Apr 25 '19 at 08:24
-
Is there a way to get the user who submitted the transaction? Or only if you provide it explicitly during the transaction submission? – Fedor Petrov Nov 10 '21 at 16:43