How to configure Endorsement policy in Hyperledger

+1 vote
I am trying to implement Hyperledger Fabric on my system. I am not understanding how to configure the Endorsement policy for the Hyperledger Fabric. Can someone explain how to configure the endorsement policy?
Jul 25, 2018 in Blockchain by digger
• 26,740 points
3,327 views

2 answers to this question.

+1 vote
Best answer

The Hyperledger Fabric Endorsement policy is configured when the chaincode is instantiated. The Endorsement policies are configured as logical gate predicates. The rule for this logic gate is as follows:

EXPR(E[, E...]) where EXPR is AND or OR and E is either a principal (Org1.Admin, Org1.Member) or a nested expression EXPR(..)

Example: 

"AND('Org1.member', 'Org2.member')"

When you execute

peer instantiate chaincodeName

you have to pass

-P policyString

where policyString is the expression shown as in the above example

Ex:

peer chaincode instantiate -C testchainid -n mycc -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02 -c '{"Args":["init","a","100","b","200"]}' -P "AND('Org1.member', 'Org2.member')"
answered Jul 25, 2018 by slayer
• 29,370 points

selected May 5, 2019 by Omkar

What the logic 

-P "AND('Org1.member', 'Org2.member')"

in your code mean?

Hi @Shri, it means that both Org1 and Org2 members are requested to sign the transaction.
Hi. I want to write a logic for the following case. I have two Organizations Org1 and Org2. I want either one of them to sign the transaction i.e., it is not necessary that both should sign the transaction. What is the logic for this?

You can use the OR gate for this. Refer the below logic.

-P "AND('Org1.member', 'Org2.member')"

You can also use nested logic. Suppose you want to request one signature from a member of the Org1 MSP or 1 signature from a member of the Org2 MSP and 1 signature from a member of the Org3 MSP. Then you can use the following logic:

OR('Org1.member', AND('Org2.member', 'Org3.member'))

0 votes

Endorsement policy can be set by using the -P switch. When instantiating the chaincode, use the -switch following by a Boolean logic representing which peer or organization has to sign the transaction. 

$ peer chaincode instantiate <other parameters> -P <boolean logic>
answered May 5, 2019 by Nandan

Related Questions In Blockchain

+15 votes
5 answers
0 votes
1 answer
0 votes
1 answer

Hyperledger Sawtooth vs Quorum in concurrency and speed Ask

Summary: Both should provide similar reliability of ...READ MORE

answered Sep 26, 2018 in IoT (Internet of Things) by Upasana
• 8,620 points
1,451 views
+1 vote
1 answer
0 votes
1 answer

Invalid Batch or signature in Savtooth

This will solve your problem import org.apache.commons.codec.binary.Hex; Transaction txn ...READ MORE

answered Aug 1, 2018 in Blockchain by digger
• 26,740 points
1,004 views
0 votes
1 answer

How to store photos in Hyperledger smart contract?

To do this, you need to represent ...READ MORE

answered Jul 9, 2018 in Blockchain by slayer
• 29,370 points
846 views
0 votes
1 answer

How to solve "error trying install composer runtime" in Hyperledger composer?

I think the docker-compose tool is not ...READ MORE

answered Jul 17, 2018 in Blockchain by slayer
• 29,370 points
896 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP