Skip to content

Final Project for Dapp 1 at George Brown College. Built using React and Nodejs sdk

Notifications You must be signed in to change notification settings

mathaip/LandRegistry-Hyperledger-GBC

Repository files navigation

DAPP 1 Final Project: Mathai Puthiakunnel, Student number 101278673

Step 1

git clone https://github.com/mathaip/LandRegistry-Hyperledger-GBC.git

Make sure you have docker installed on your machine.

STEP 2

To run the Network

Please run the hyperledger scripts by going to fabric-samples/fabcar/

sh startFabric.sh javascript

This will bootstrap the 2 org 2 node setup and install the javascript chaincode on the nodes.

To run the API

Copy connection profile

git clone https://github.com/mathaip/GBHyperledger-FabCar.git
cd GBHyperledger-FabCar

Copy the connection profile generated by the step 1 above. The connection profile is located in /fabric-samples/first-network/connection-org1.json

Copy this profile inside config folder

Enroll Admin and User for the first time to connect to blockchain

node enrollAdmin.js
node registerUser.js

These commands will generate admin certificates and a user certificate for a user called user1 and save them into the wallet folder.

Start the server

npm install
node start

This will start the express server at http://localhost:3000. If you are in GCP, it will start the server at http://<your GCP external IP>:3000. Please note that you have to enable the firewall rules to allow port 3000 to be exposed in your GCP Compute Engine.

To test the installation, initiate a GET request to http://localhost:3000/query

To install new chaincode

Put your chaincode in /fabric-samples/chaincode/<your chaincode folder>/javascript/. The chaincode folder is mounted in the docker container.

docker exec -it cli bash
peer chaincode install -l node -n realstate -v 1.2 -p /opt/gopath/src/github.com/chaincode/realstate/javascript/

To instantiate Chaincode

peer chaincode instantiate -o orderer.example.com:7050 --tls $CORE_PEER_TLS_ENABLED --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 mychannel -n realstate -v 1 -c '{"Args":["initLedger"]}' -P "OR ('Org1MSP.member','Org2MSP.member')" ​

To Invoke Functions From Chaincode

Query All Houses

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 mychannel -n realstate -c '{"function":"queryAllHouses","Args":[]}'

Query Specific House

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 mychannel -n realstate -c '{"function":"queryHouse","Args":["HOUSE0"]}'

Change Ownership

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 mychannel -n realstate -c '{"function":"changeHouseOwner","Args":["HOUSE9","Wilmar"]}'

Create House

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 mychannel -n realstate -c '{"function":"createHouse","Args":["HOUSE10","55 Mill St, Toronto, ON M5A 3C4","(416) 364-1177","appartment","Wilmar"]}'

Step 4

A) Navigate to ./FrontEndHyperledger

B) Run npm install

C) Run npm start. The NodeJs app and React app must be running in parallel

D) Go to http://localhost:3000/dashboard


About

Final Project for Dapp 1 at George Brown College. Built using React and Nodejs sdk

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published