Learn more >
Get the code
View the demo
Run the app
Code walkthrough 1
Code walkthrough 2
by Horea Porutiu, Deepika Bablini, Gordon Zhang, Ryan Bouchard, Kai Wetlesen, Eric Hernandez-Lu, Shalini Gundaiah Ramamurthy | Published July 10, 2019
With its distributed ledger, smart contracts, and non-repudiation capabilities, blockchain is revolutionizing the way organizations do business, and the election industry is no exception. This developer code pattern shows you how to implement a web-based blockchain app using the IBM Blockchain Platform to facilitate voting and help ensure the prevention of double-voting.
Have you ever wondered how exactly the votes in a presidential election are counted? What if — instead of having volunteers spending many hours each day manually counting votes — you had an app backed by blockchain, recording each voter’s vote, ensuring that double-voting is not possible? That’s what this code pattern explains how to do. We aim to build a web app in which the voter can register with their driver’s license, get a unique voter ID, which is used to log in to the app, and cast the vote. The vote is tallied on the blockchain, and the web app shows the current poll standings.
At the start of the application, the user registers to vote by providing a driver’s license number, registrar district, and first and last name. In this step, you can check to see if the driver’s license is valid and has not been registered previously. If all goes well, you create a private and public key for the voter with the certificate authority running on the cloud and add those keys to the wallet.
After that, users use their driver’s license numbers to submit votes, during which the application checks to see if the driver with this license number has voted before. If this particular license number has not been used before, the vote goes through the consensus policy, and the world state is updated. The application then updates the current election standings to show which political party the user has voted for.
Since each transaction submitted to the ordering service must have a signature from a valid public-private key pair, you can trace back each transaction to a registered voter of the application, in case of an audit.
Given that every transaction that has been recorded on the blockchain has reached consensus on the network and is immutable, using blockchain for voting can help ensure trust between the public and the government. In addition, by using smart contracts to automate the tallying of votes, voting becomes a much more secure and cost-effective process. Although this is a simple application, you can see how to implement a Hyperledger Fabric web app to decrease the chance of election fraud and enhance a voting application by using blockchain technology.
Ready to get started? Check out the README for the step-by-step details on:
Get the Code »
Back to top