BCertificate is a Hyperledger blockchain full application that automates the issuance, dispatch, and management of university's digital credentials (diplomas, skills, transcripts, degree certifications, etc).
A blockchain network that let schools, colleges and universities add their credentials in the blockchain which could help against fraud papers.
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 one's familiar with hyperlegder fabric and have everything needed for it to run set up, move to certificate-network/certificate-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:
BCertificate 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 do we start our HL network and get our web app running?
First and foremost, download or clone this repo.
Repo structure:
- certificate-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, certificate-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 samples from grab them from my fabric-sample 2021's fork
-
certificate-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 (add_path_org1.sh) to fabric-samples/test-network. -
certificate-network/chaincode/certificate/: contains our smart contract code (javascript/, java/) which will be packaged (chaincode), installed and committed to corresponding peers.
Copy the folder certificate-network/chaincode/certificate/ to fabric-samples/chaincode/.
Open terminal and runnpm install
to install packages. -
certificate-network/certificate-starter/ : contains our client application and is the starting point of our application.
-
startBCertificate.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 one 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 certificate-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 certificate-network/certificate-starter run the following commands on your terminal:
./startBCertificate.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.
All certificates
http://localhost:8080/api/allcertificates
Adding a certificate
Note that one can add a list of certificate by importing an excel sheet (.xls).
http://localhost:8080/api/addcertificate
Git GitHub's certificate
http://localhost:8080/api/query/CERT11
If you find interest in this project.
You might also look at a similar project that manage land certificates with QR Code where a client request a certificate to a land conserver and this latter add it in their blockchain network land certificate management.
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, can't launch the app ... 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.
AL-FAHAMI TOIHIR
FACULTY OF SCIENCE - KENITRA
MATHEMATICS & COMPUTER SCIENCE DEPARTMENT
This project is avalaible as open source under the terms of licence MIT.