Sam LAM @ OriginBit
2 min readFeb 18, 2019

--

Hello Tommaso,

Thanks for your comment.

I just re-run the tutorial and found that the default endorsement policy in Build Your First Network (BYFN) for the transactions is an AND policy, which requires both organizations, Org1 and Org2, to sign those transactions. But my tutorial treats it as an OR policy.

In other words, one possible case that makes the endorsement failure is: any signature or endorsement of Org1 and Org2 is missed. In my tutorial, the Invoke command is sent to one Peer in one organization — Org1 only (treating the policy as an OR policy, that’s not correct).

So, a possible solution is to collect enough signature or endorsement from both organizations, Org1 and Org2, when we Invoke Chaincode.

Can you try the following updated Invoke command below?

peer chaincode invoke -o orderer.example.com:7050 --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C $CHANNEL_NAME -n mycc --peerAddresses peer0.org1.example.com:7051 --tlsRootCertFiles /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt --peerAddresses peer0.org2.example.com:7051 --tlsRootCertFiles /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt -c '{"Args":["createWallet","tom","100"]}'
  • I have updated the tutorial as well
  • After using the updated command above, try to query again to see whether it works

Please accept my apologies, I am going to explain the long command above

peer chaincode invoke
  • This is to use the Fabric-given Peer program to invoke Chaincode
-o orderer.example.com:7050 --tls true --cafile xxx.pem
  • This is to specify which Orderer to send transaction after the endorsement is finished successfully, also we turn on TLS and set which cert to use

Why do we specify which Orderer to send transaction “after the endorsement”? May refer to here and look at the “Hyperledger Fabric — The Transaction Flow” section for the Fabric transaction flow

-C $CHANNEL_NAME -n mycc
  • This is to specify which Channel and Chaincode to use
--peerAddresses peer0.org1.example.com:7051 --tlsRootCertFiles /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
  • This is to specify which Peer (Peer0 in this case) to send transaction proposal for the endorsement and set which cert to use

If the policy is an OR policy, now, one Peer should be enough. But the policy is an AND policy, we will need to specift one more Peer from another orgnization.

-peerAddresses peer0.org2.example.com:7051 --tlsRootCertFiles /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt
  • This is to specify one more Peer (Peer0@Org1 in this case) to send transaction proposal for the endorsement and set which cert to use

In our case, because our policy is an AND policy, we need to specify one more Peer (Peer0@Org2) from another organization (Org2 in our case) to send transaction proposal for the endorsement

-c '{"Args":["createWallet","tom","100"]}'
  • This is to specify the method name and parameters for Chaincode method

Thank you very much!

--

--

Sam LAM @ OriginBit

OriginBit Founder | HSUHK Lecturer | Gov Advisory Committee Member(SCSDITE) | GDG Organizer | MBuddhStud(HKU) | BEng(HKUST) | MCSE | MCP | CCNP | CEH