Aryama I
Aryama I

Reputation: 97

How to retrieve the identity of the user initiating a transaction in Hyperledger fabric using fabric contract-api?

I have a scenario where there are two organisations org1, org2. Now I wrote a chaincode in node.js using fabric-shim API, where some functions need to be invoked by only peers of org1 and others by peers of org2.

How can I check the identity of the initiator of the transaction? Does ctx.clientIdentity.getID()/ctx.clientIdentity.getMSPID() help me in giving the ID defined in configtx.yaml so I can check the initiator?

Please let me know about it.

Upvotes: 1

Views: 878

Answers (1)

Aryama I
Aryama I

Reputation: 97

I was able to verify if the transaction is called by a ctx.clientIdentity.getMSPID() function and check the resulting organization name to verify which organisation peer is calling the function.

Upvotes: 1

Related Questions