Blockchain vote app built with hyperledger composer https://www.builtwithblockchain.io/livepreview/vote-app/
This web app is meant to prove a simple vote use case and technichly this can be turned into real electronique election app and fit the regulators laws.
The project is built essentially with hyperledger fabric , hyperledger composer , reactjs for the client side , expressjs for the server side. The web app interact with hyperledger through the composer REST JSON server..
- vote-network :
Contain the hyperledger composer business newtork "where all the magic happens" and the REST JSON server sources.
- vote-app :
- server :
The server side Expressjs, this part expose what we need for the client web app.
- client :
The web app client app built with Reactjs ... the fun part.
git clone https://github.com/html5-ninja/hyperledger-vote-app.git
Now you need to get hyperledger fabric and hyperledger composer , all you need is here
https://hyperledger.github.io/composer/latest/installing/installing-prereqs.html
https://hyperledger.github.io/composer/latest/installing/development-tools.html
Note : Skip the Start the web app ("Playground") section.
cd ~/fabric-tools
./stopFabric.sh
./teardownFabric.sh
./downloadFabric.sh
./startFabric.sh
composer card delete -c PeerAdmin@fabric-network
composer card delete -c admin@vote-network
rm -fr ~/.composer
composer card create -p connection.json -u PeerAdmin -c admincerts/[email protected] -k keystore/xxxxxxx_your_keyxxxxxxxxx_sk -r PeerAdmin -r ChannelAdmin
Replace xxxxxxx_your_keyxxxxxxxxx_sk with your key , visit https://hyperledger.github.io/composer/latest/tutorials/deploy-to-fabric-single-org "Step Four: Locating the certificate and private key for the Hyperledger Fabric administrator" for more details.
composer card import -f [email protected]
we will install our vote app bna file
composer network install -c PeerAdmin@fabric-network -a [path to repo]/vote-network/[email protected]
composer network start --networkName vote-network --networkVersion 0.0.6 -A admin -S adminpw -c PeerAdmin@fabric-network
composer card import -f [email protected]
composer network ping -c admin@vote-network
first we need to install node modules, should be done once.
cd [path to hyperledger-vote-app]/vote-app/server/
npm install
cd [path to hyperledger-vote-app]/vote-app/client/
npm install
cd [path to hyperledger-vote-app]/vote-network/
npm install
cd [path to hyperledger-vote-app]/vote-network/
composer-rest-server -c admin@vote-network -n never -w true
This will start the composer REST SERVER on port 3000, the magic happen here http://localhost:3000
Now we will add candidates this is the assets on our business network
- go to http://localhost:3000/explorer/
- click "Candidate" and "POST"
- on "data" paste , it's the same data as the live demo
[
{
"name": "clinton",
"votes": 0
},
{
"name": "developer",
"votes": 0
},
{
"name": "trump",
"votes": 0
}
]
cd [path to hyperledger-vote-app]/vote-app/server/
node app.js
cd [path to hyperledger-vote-app]/vote-app/client/
npm start
If everything goes right open http://localhost:3002
My to do list
- TODO[ ] : Deploying a Hyperledger Composer blockchain business network to Hyperledger Fabric (multiple organizations)
- TODO[ ] : Better UI
- TODO[ ] : fix minors bugs