landCertificate is a Hyperledger blockchain admin/client land certficate requester application built on top of Hyperledger where clients request a land certificate to a land conserver(admin) who will deliver the certificate. Online mongoDB-atlas is used to store clients' resquests, which are displayed in the admin panel.
A blockchain network that let's land conservers add its certificates in the blockchain, which can help against land ownership issues and problems.
The network was built using Hyperledger Fabric V2.X.X and the test were made on Linux/Debian 10 Buster, WSL/Debian 10 Buster and WSL/Ubuntu machines but should work on any given OS.
The web app is built with NodeJS, ExpressJS, REST API and pug template engine as a render for the front-end.
NB: Having docker installed in one's OS is a MUST.
TL;DR : if you are familiar with hyperlegder fabric and have everything needed for it to run set up, move to landcertificate-network/landcertificate-starter/ and run & execute the network.
If you have never dealth with Hyperledger Fabric before, then you might want to grab the version that suits well this project.
Download the sources of fabric-samples version-2.0.0 repository or grab them from my fabric-sample 2021's fork and do the following:
landCertificate is built on top of Hyperledger Linux foundation, thus it's a must to install and configure Hyperledger first.
Prerequisites:
- Install and configure Docker (tons of tutorial on the web, )
- Install curl (
sudo apt update && sudo apt upgrade
thensudo apt install curl
on linux machine)
Hyperledger:
-
Run this single command to download and install the samples, binaries, and docker image of the latest production release of HL:
-
curl -sSL https://bit.ly/2ysbOFE | bash -s
-
- if the above link is not working, download the sources of fabric-samples version-2.0.0 repository
-
Find more details Official HL documentation
-
Run the test-network as described in using the test-network tutoriel to make sure that everything is set up.
Now how so we start our HL network and get our web app running?
First and foremost, download or clone this repo.
Repo structure:
- landcertificate-network/_ : contains our full blockchain application. It contains our config files, crypto materials, starter-app, chaincode ... etc.
As Hyperledger has changed fabric_samples folder content and structure, landcertificat-network/ has the necerssary binaries and tools- to build and run up our netwrork. Its content could also be found in the original fabric-samples version-2.0.0 repository or grab them from my fabric-sample 2021's fork
-
landcertificate-network/test-network/add_path_org1.sh : a custom script that adds peer cli, peer and fabric config related path with org1's environment variables.
Copy this file (test-network/add_path_org1.sh) to fabric-samples/test-network. -
landcertificate-network/chaincode/landcertificate/: contains our smart contract code (javascript/, java/) which will be packaged (chaincode), installed and committed to corresponding peers.
Copy the folder chaincode/landcertificate/ to fabric-samples/chaincode_.
Open terminal and runnpm install
to install packages. -
landcertificate-network/certificate-starter/ : contains our client application and is the starting point of our application.
-
startBcLand.sh is the script that is going to start our network, bringing up HL docker images, creating channel, packaging, installing and deploying our chaincode.
Note : We're deploying our chaincode by nitializing the ledger which consists of requesting and invoking a chaincode initialization function (initLedger).
Check the flag cci in./network.sh deployCC -ccn certificate -ccv 1 -cci initLedger
If you don't want to initialize the ledger, remove-cci initLedger
from startBCertificate.sh -
networkDown.sh will bring down our network, thus stopping running docker containers.
Note: If you're restarting the netowrk, you'll probably want to manually remove the chaincode docker volumes as they'll create conflict. (docker volumes prune
would remove all your docker volumes) -
javascript/ is where we're going to enroll ou admin, registrer our user (so he/she can run transactions against the network by invoking the chaincode) and querying the ledger to get added certificates as we've deployed our chaincode while initializing it.
Runnpm install
before using any scripts. -
java/ same as javascript/, contains our administration scripts. Not fully implemented and neither fully tested.
-
apiserver/ is our nodeJS application. It contains same administration scripts in javascript/ and more.
Runnpm install
before using any enrolling admin, registering the user and invoking transactions. -
Copy landcertificate-network/certificate-starter/ to fabric-samples/
-
Now that we went through all the folder and script let's see how we to start the app step by step :
-
Make sure you are in landcertificate-network/landcertificate-starter run the following commands on your terminal:
./startBcLand.sh
cd apiserver/
node enrollAdmin.js && node registerUser.js && node query.js
node apiserver.js
- Now you can visit http://localhost:8080/api/ or http://localhost:8080/api/allcertificates to see already added certificates.
http://localhost:8080/api/admin/index
http://localhost:8080/api/admin/addland
http://localhost:8080/client/index
After validation, our land is certified in the blockchain
If you find interest in this project.
You might also look at a similar project that automates the issuance, dispatch, and management of university's digital credentials (diplomas, skills, transcripts, degree certifications, etc) here.
Once again the main idea was to get familiar with how Hyperledger Fabric build and handles blockchain rahter than the user application and user experience.
Please contact me by email in case you've got questions, remarks, ... regarding the project.
Feel free to contribute by creating an issue and/or a pull request.
The main focus was on getting familiar with Hyperledger and its different ways of building blockchain solutions.
This work is licensed under a Creative Commons Attribution 4.0 International License.