mirror of
https://github.com/hyperledger/fabric-samples.git
synced 2026-06-17 07:25:10 +00:00
[FAB-8479] Added Endorsement policy
for balance transfer app in node-sdk samples. Added Endorsement policy in instantiate-chaincode. Change-Id: Ie7344353a8febf0f1e76f6a4edcb3035ab2d00e2 Signed-off-by: susmita <susmita.somanchi@gmail.com>
This commit is contained in:
parent
1745c996b3
commit
c4bdc68e1b
3 changed files with 46 additions and 6 deletions
|
|
@ -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 <put JSON Web Token here>" \
|
||||
-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 <put JSON Web Token here>" \
|
||||
-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"]
|
||||
}'
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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"]
|
||||
}')
|
||||
|
|
|
|||
Loading…
Reference in a new issue