diff --git a/balance-transfer/README.md b/balance-transfer/README.md index 553c67d376..7d551d25ba 100644 --- a/balance-transfer/README.md +++ b/balance-transfer/README.md @@ -173,13 +173,40 @@ curl -s -X POST \ ### Instantiate chaincode +This is the endorsement policy defined during instantiation. +This policy can be fulfilled when members from both orgs sign the transaction proposal. + +``` +{ + identities: [{ + role: { + name: 'member', + mspId: 'Org1MSP' + } + }, + { + role: { + name: 'member', + mspId: 'Org2MSP' + } + } + ], + policy: { + '2-of': [{ + 'signed-by': 0 + }, { + 'signed-by': 1 + }] + } +} +``` + ``` curl -s -X POST \ http://localhost:4000/channels/mychannel/chaincodes \ -H "authorization: Bearer " \ -H "content-type: application/json" \ -d '{ - "peers": ["peer0.org1.example.com","peer1.org1.example.com"], "chaincodeName":"mycc", "chaincodeVersion":"v0", "chaincodeType": "golang", @@ -190,13 +217,14 @@ curl -s -X POST \ ### Invoke request +This invoke request is signed by peers from both orgs, *org1* & *org2*. ``` curl -s -X POST \ http://localhost:4000/channels/mychannel/chaincodes/mycc \ -H "authorization: Bearer " \ -H "content-type: application/json" \ -d '{ - "peers": ["peer0.org1.example.com","peer1.org1.example.com"], + "peers": ["peer0.org1.example.com","peer0.org2.example.com"], "fcn":"move", "args":["a","b","10"] }' diff --git a/balance-transfer/app/instantiate-chaincode.js b/balance-transfer/app/instantiate-chaincode.js index 923be6b8c8..1c6455a570 100644 --- a/balance-transfer/app/instantiate-chaincode.js +++ b/balance-transfer/app/instantiate-chaincode.js @@ -50,7 +50,19 @@ var instantiateChaincode = async function(peers, channelName, chaincodeName, cha chaincodeType: chaincodeType, chaincodeVersion: chaincodeVersion, args: args, - txId: tx_id + txId: tx_id, + + // Use this to demonstrate the following policy: + // The policy can be fulfilled when members from both orgs signed. + 'endorsement-policy': { + identities: [ + { role: { name: 'member', mspId: 'Org1MSP' }}, + { role: { name: 'member', mspId: 'Org2MSP' }} + ], + policy: { + '2-of':[{ 'signed-by': 0 }, { 'signed-by': 1 }] + } + } }; if (functionName) diff --git a/balance-transfer/testAPIs.sh b/balance-transfer/testAPIs.sh index e83a672e6d..8528924c32 100755 --- a/balance-transfer/testAPIs.sh +++ b/balance-transfer/testAPIs.sh @@ -144,7 +144,7 @@ curl -s -X POST \ echo echo -echo "POST instantiate chaincode on peer1 of Org1" +echo "POST instantiate chaincode on Org1" echo curl -s -X POST \ http://localhost:4000/channels/mychannel/chaincodes \ @@ -159,14 +159,14 @@ curl -s -X POST \ echo echo -echo "POST invoke chaincode on peers of Org1" +echo "POST invoke chaincode on peers of Org1 and Org2" echo TRX_ID=$(curl -s -X POST \ http://localhost:4000/channels/mychannel/chaincodes/mycc \ -H "authorization: Bearer $ORG1_TOKEN" \ -H "content-type: application/json" \ -d '{ - "peers": ["peer0.org1.example.com","peer1.org1.example.com"], + "peers": ["peer0.org1.example.com","peer0.org2.example.com"], "fcn":"move", "args":["a","b","10"] }')