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 machine 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.
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
-
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:
-
test-network/add_path_org1.sh : a 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. -
chaincode/certificate/: contains our smart contract code (javascript/, java/) which will be packaged (chaincode), installed and committed to corresponding peers.
Copy the folder chaincode/certificate/ to fabric-samples/chaincode.
Open terminal and runnpm install
to install packages. -
certificate/ : 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 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 certificate/ and paste 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 fabric-samples/certificate 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
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.
AL-FAHAMI TOIHIR
FACULTY OF SCIENCE - KENITRA
MATHEMATICS & COMPUTER SCIENCE DEPARTMENT
This project is avalaible as open source under the terms of licence MIT.