Skip to content

Latest commit

 

History

History
132 lines (88 loc) · 3.96 KB

two-org-single-machine.md

File metadata and controls

132 lines (88 loc) · 3.96 KB

Deploying two organizations on a single machine

For this tutorial, we will be using these files :

Check the files to see the configuration of each organization.

For the chaincode we will be deploying abstore chaincode of fabric-samples.

Install

sudo curl -L https://raw.githubusercontent.com/bxforce/bnc-hlf/master/bin/bnc -o /usr/local/bin/bnc && sudo chmod +x /usr/local/bin/bnc

Getting Started 🚀

Step1: Create config files

mkdir config
curl https://raw.githubusercontent.com/bxforce/bnc-hlf/master/tests/single_machine/two-orgs/config-deploy-org1.yaml > $PWD/config/config-deploy-org1.yaml
curl https://raw.githubusercontent.com/bxforce/bnc-hlf/master/tests/single_machine/two-orgs/config-deploy-org2.yaml > $PWD/config/config-deploy-org2.yaml
curl https://raw.githubusercontent.com/bxforce/bnc-hlf/master/tests/single_machine/two-orgs/config-genesis-org1-org2.yaml > $PWD/config/config-genesis-org1-org2.yaml
curl https://raw.githubusercontent.com/bxforce/bnc-hlf/master/tests/single_machine/two-orgs/config-chaincode.yaml > $PWD/config/config-chaincode.yaml

Step2: Enroll peers and orderers of org2

Now we will start by generating crypto material for org2:

bnc generate --config-folder $PWD/config -f config-deploy-org2.yaml 

Step3: Enroll peers and orderers of org1

Now we will start by generating crypto material for org1:

bnc generate --config-folder $PWD/config -f config-deploy-org1.yaml -g config-genesis-org1-org2.yaml

Step4: Start peers/orderers of org2

bnc start --config-folder $PWD/config -f config-deploy-org2.yaml

Step5: Start peers/orderers of org1

bnc start --config-folder $PWD/config -f config-deploy-org1.yaml

Step6: Create channel, join the channel and update anchor peer on org1:

bnc channel deploy --config-folder $PWD/config -f config-deploy-org1.yaml 

Step7: Join the channel and update anchor peer on org1:

bnc channel deploy --config-folder $PWD/config -f config-deploy-org2.yaml --no-create

Step8: Deploy chaincode on org2:

The following command will install + approve + commit chaincode

bnc chaincode deploy --config-folder $PWD/config -f config-deploy-org2.yaml -c config-chaincode.yaml

Step9: Deploy chaincode on org1:

bnc chaincode deploy --config-folder $PWD/config -f config-deploy-org1.yaml -c config-chaincode.yaml

Step10: TEST IT 🔥

Org1 will do the first invoke

bnc chaincode invoke --config-folder $PWD/config -f config-deploy-org1.yaml -c config-chaincode.yaml -i "Init,a,100,b,100"

query chaincode

bnc chaincode query --config-folder $PWD/config -f config-deploy-org1.yaml -c config-chaincode.yaml -i "query,a"

call the invoke fct to move 10 from a to b

bnc chaincode invoke --config-folder $PWD/config -f config-deploy-org1.yaml -c config-chaincode.yaml -i "invoke,a,b,10"

Invoke as org2

bnc chaincode invoke --config-folder $PWD/config -f config-deploy-org2.yaml -c config-chaincode.yaml -i "invoke,a,b,10"

Step11: Shutdown network

bnc rm --config-folder $PWD/config -f config-deploy-org1.yaml
bnc rm --config-folder $PWD/config -f config-deploy-org2.yaml