Note - The development was done on macOS. So, all the bin files for fabric network is for macOS. These bin files need to be replaced in case if the network is tested on other OS.
- Download the project folder.
- cd to /network path
$ cd network
- Tear down running network and containers for safer side
$ sh ./fabricNetwork.sh down
- Bootstrap the network
$ sh ./fabricNetwork.sh up
- Open 2 new tabs in terminal and bash into 2 chaincode container. For making development and testing seamless, 2 chaincode containers are configured one for registrar org and other for user org.
$ docker exec -it registrar.chaincode /bin/bash $ docker exec -it user.chaincode /bin/bash
- Start the nodejs service in the respective chaincode container.
a) In registrar chaincode tab -
b) In user chaincode tab -
$ npm install $ npm run start-dev-registrar
$ npm install $ npm run start-dev-user
- Install and intantiate the chaincode from the /network directory
$ sh ./fabricNetwork.sh install
- Network set up completed.
Note - Two cli will be used, one for registrar and other for user to support initiator validation. Registrar cli will connect to peer0 of registrar and user cli will connect to peer0 of the user. That way the request will have the respective initiator MSP id. So, user can not invoke the registrar functionality and vice versa.
- Bash into registrar and user cli.
a) Registrar tab -
b) User tab -
$ docker exec -it cli /bin/bash
$ docker exec -it user.cli /bin/bash
- Two users Ashlesh and Harshit requests for registration.
From user cli tab -
$ peer chaincode invoke -o orderer.property-registration-network.com:7050 -C registrationchannel -n regnet -c '{"Args":["org.property-registration-network.regnet.user:requestNewUser","Ashlesh", "sorteeashlesh@gmail.com", "9994293900", "12345"]}' $ peer chaincode invoke -o orderer.property-registration-network.com:7050 -C registrationchannel -n regnet -c '{"Args":["org.property-registration-network.regnet.user:requestNewUser","Harshit", "harshit@gmail.com", "8894293900", "54321"]}'
- Registrar accepts both the user’s registration request.
From registrar cli tab -
$ peer chaincode invoke -o orderer.property-registration-network.com:7050 -C registrationchannel -n regnet -c '{"Args":["org.property-registration-network.regnet.registrar:approveNewUser","Ashlesh", "12345"]}' $ peer chaincode invoke -o orderer.property-registration-network.com:7050 -C registrationchannel -n regnet -c '{"Args":["org.property-registration-network.regnet.registrar:approveNewUser","Harshit", "54321"]}'
- User Ashlesh raise the request for property registration.
From user cli tab -
$ peer chaincode invoke -o orderer.property-registration-network.com:7050 -C registrationchannel -n regnet -c '{"Args":["org.property-registration-network.regnet.user:propertyRegistrationRequest","Ashlesh", "12345", "001", "100"]}'
- Registrar view and verify the property registration request by Ashlesh.
From registrar cli tab -
$ peer chaincode invoke -o orderer.property-registration-network.com:7050 -C registrationchannel -n regnet -c '{"Args":["org.property-registration-network.regnet.registrar:viewPropertyRequest","Ashlesh", "12345", "001"]}'
- Registrar accepts property registration request by Ashlesh.
From registrar cli tab -
$ peer chaincode invoke -o orderer.property-registration-network.com:7050 -C registrationchannel -n regnet -c '{"Args":["org.property-registration-network.regnet.registrar:approvePropertyRegistration","001"]}'
- Ashlesh lists his property for sale.
From user cli tab -
$ peer chaincode invoke -o orderer.property-registration-network.com:7050 -C registrationchannel -n regnet -c '{"Args":["org.property-registration-network.regnet.user:updatePropertyStatus","Ashlesh","12345","001","onSale"]}'
- Harshit recharges his account with 500 propCoins.
From user cli tab -
$ peer chaincode invoke -o orderer.property-registration-network.com:7050 -C registrationchannel -n regnet -c '{"Args":["org.property-registration-network.regnet.user:rechargeAccount","Harshit", "54321", "txn500"]}'
- Harshit wish to buy the property of Ashlesh and initiate the purchase.
From user cli tab -
$ peer chaincode invoke -o orderer.property-registration-network.com:7050 -C registrationchannel -n regnet -c '{"Args":["org.property-registration-network.regnet.user:purchaseProperty","001","Harshit","54321"]}'
- Harshit view his purchase property.
From user cli tab-
$ peer chaincode invoke -o orderer.property-registration-network.com:7050 -C registrationchannel -n regnet -c '{"Args":["org.property-registration-network.regnet.user:viewProperty","Harshit","54321","001"]}'
- Now there is no property under Ashlesh’s name. So, when Ashlesh tries to view the property, he gets the error.
From the user cli tab -
$ peer chaincode invoke -o orderer.property-registration-network.com:7050 -C registrationchannel -n regnet -c '{"Args":["org.property-registration-network.regnet.user:viewProperty","Ashlesh","12345","001"]}'
- Ashlesh and Harshit both verify their propCoins after transaction. Ashlesh has 100 propCoins now and Harshit has 400 propCoins now.
From user cli tab -
$ peer chaincode invoke -o orderer.property-registration-network.com:7050 -C registrationchannel -n regnet -c '{"Args":["org.property-registration-network.regnet.user:viewUser","Ashlesh", "12345"]}' $ peer chaincode invoke -o orderer.property-registration-network.com:7050 -C registrationchannel -n regnet -c '{"Args":["org.property-registration-network.regnet.user:viewUser","Harshit", "54321"]}'