{"id":15069843,"url":"https://github.com/ibm/evote","last_synced_at":"2025-04-05T13:09:35.750Z","repository":{"id":37733307,"uuid":"187119292","full_name":"IBM/evote","owner":"IBM","description":"A voting application that leverages Hyperledger Fabric and the IBM Blockchain Platform to record and tally ballots.","archived":false,"fork":false,"pushed_at":"2023-01-01T08:10:34.000Z","size":76588,"stargazers_count":328,"open_issues_count":44,"forks_count":165,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-04-05T13:09:24.756Z","etag":null,"topics":["blockchain","hyperledger-fabric","kubernetes","node-js","vuejs"],"latest_commit_sha":null,"homepage":"https://developer.ibm.com/patterns/how-to-create-a-secure-e-voting-application-on-hyperledger-fabric/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/IBM.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-05-17T00:26:56.000Z","updated_at":"2025-04-05T11:40:16.000Z","dependencies_parsed_at":"2023-01-31T21:16:08.366Z","dependency_job_id":null,"html_url":"https://github.com/IBM/evote","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IBM%2Fevote","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IBM%2Fevote/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IBM%2Fevote/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IBM%2Fevote/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/IBM","download_url":"https://codeload.github.com/IBM/evote/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247339158,"owners_count":20923014,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["blockchain","hyperledger-fabric","kubernetes","node-js","vuejs"],"created_at":"2024-09-25T01:45:06.468Z","updated_at":"2025-04-05T13:09:35.710Z","avatar_url":"https://github.com/IBM.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# WARNING: This repository is no longer maintained :warning:\n\n\u003e This repository will not be updated. I will check periodically for pull requests, but do not expect a quick response. \n\n# Create a fair evoting application to ensure correct election results with Hyperledger Fabric and IBM Blockchain Platform\n\n\u003e **NOTE**: This developer pattern creates a blockchain network on *IBM Blockchain Platform version **2.5*** using the *Hyperledger Fabric version **1.4***.\n\n\u003cbr\u003e\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"docs/doc-gifs/demo.gif\"\u003e\n\u003c/p\u003e\n\u003cbr\u003e\n\nHave you ever wondered how exactly the votes in a presidential election \ncounted? What if instead of having volunteers that are spending hours a \nday counting votes manually, we have an app that was backed by blockchain, \nrecording each vote made by a voter, ensuring double-voting is not possible?\nThat's what this code pattern explains how to do. We aim to build a web-app\nin which the voter can register with their drivers license, get a unique \nvoterId which is used to login to the app, and cast the vote. The vote is \ntallied on the blockchain, and the web-app shows the current standings of the\npolls. \n\n### Voting using Public Key Infrastructure\nAt the start of the application, the user registers to vote by providing their drivers license number,\nregistrar district, and first and last name. In this step, we can check to see if the drivers license \nis valid, and has not been registered previously. If all goes well, we create a private and public key \nfor the voter with our certificate authority that is running on the cloud, and add those keys to the \nwallet. To read more about public key infrastructure, and how Hyperledger Fabric implements identity\nusing this technology, go [here](https://hyperledger-fabric.readthedocs.io/en/release-1.4/identity/identity.html).\n\nAfter that, we use our drivers license number to submit our vote, during which the application checks \nif this drivers license number has voted before and tells the user they have already submitted a vote \nif so. If all goes well, the political party which the voter has chosen is given a vote, and the world\nstate is updated. The application then updates our current standings of the election to show how many \nvotes each political party currently has. \n\nSince each transaction that is submitted to the ordering service must have a signature from a valid\npublic-private key pair, we can trace back each transaction to a registered voter of the application, \nin the case of an audit.\n\nIn conclusion, although this is a simple application, the developer can see how they can implement a \nHyperledger Fabric web-app to decrease the chance of election-meddling, and enhance a voting application\nby using blockchain technology. \n\nWhen the reader has completed this code pattern, they will understand how to:\n\n* Create, build, and use the IBM Blockchain Platform service.\n* Build a blockchain back-end using Hyperledger Fabric API's\n* Create and use a (free) Kubernetes Cluster to deploy and monitor our \nHyperledger Fabric nodes.\n* Deploy a Node.js app that will interact with our deployed smart contract.\n\n# Flow Diagram\n\u003cbr\u003e\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"docs/app-architecture.png\"\u003e\n\u003c/p\u003e\n\u003cbr\u003e\n\n# Flow Description\n1. The blockchain operator sets up the IBM Blockchain Platform 2.5 service.\n2. The IBM Blockchain Platform 2.5 creates a Hyperledger Fabric network on an IBM Kubernetes \nService, and the operator installs and instantiates the smart contract on the network.\n3. The Node.js application server uses the Fabric SDK to interact with the deployed network on IBM Blockchain Platform 2.5 and creates APIs for a web client.\n4. The Vue.js client uses the Node.js application API to interact with the network.\n5. The user interacts with the Vue.js web interface to cast their ballot and\nand query the world state to see current poll standings.\n\n# Included components\n*\t[IBM Blockchain Platform](https://console.bluemix.net/docs/services/blockchain/howto/ibp-v2-deploy-iks.html#ibp-v2-deploy-iks) gives you total control of your blockchain network with a user interface that can simplify and accelerate your journey to deploy and manage blockchain components on the IBM Cloud Kubernetes Service.\n*\t[IBM Cloud Kubernetes Service](https://www.ibm.com/cloud/container-service) creates a cluster of compute hosts and deploys highly available containers. A Kubernetes cluster lets you securely manage the resources that you need to quickly deploy, update, and scale applications.\n* [IBM Blockchain Platform Extension for VS Code](https://marketplace.visualstudio.com/items?itemName=IBMBlockchain.ibm-blockchain-platform) is designed to assist users in developing, testing, and deploying smart contracts -- including connecting to Hyperledger Fabric environments.\n\n## Featured technologies\n+ [Hyperledger Fabric v1.4](https://hyperledger-fabric.readthedocs.io) is a platform for distributed ledger solutions, underpinned by a modular architecture that delivers high degrees of confidentiality, resiliency, flexibility, and scalability.\n+ [Node.js](https://nodejs.org) is an open source, cross-platform JavaScript run-time environment that executes server-side JavaScript code.\n+ [Vue.js 2.6.10](https://vuejs.org/) Vue.js is an open-source JavaScript framework for building user interfaces and single-page applications.\n\n# Watch the Video - Intro (Cloud)\n\n[![](docs/ibpVideo.png)](https://www.youtube.com/watch?v=ny8iif6ZXRU)\n\n# Watch the Video - Build and Run the App (Cloud)\n\n[![](docs/ibpVideo2.png)](https://www.youtube.com/watch?v=mkVUW1KroTI)\n\n# Watch the Video - Code walkthrough (User Authentication)\n\n[![](docs/userAuth.png)](https://www.youtube.com/watch?v=8uJSHW3Rpzs)\n\n# Watch the Video - Code walkthrough (Routes)\n\n[![](docs/routes.png)](https://www.youtube.com/watch?v=iajsJiIC7oU)\n\n## Prerequisites (Cloud)\n\nThis Cloud pattern assumes you have an **IBM Cloud account**.\n  - [IBM Cloud account](https://tinyurl.com/y4mzxow5)\n  - [Node v8.x or greater and npm v5.x or greater](https://nodejs.org/en/download/)\n\nYou do not technically need VSCode or the IBM Blockchain Platform extension for VSCode if you are running the \nCloud pattern, but if you want to make any changes to the smart contract, you will need the\nextension to package your smart contract project. \n\n\n## Prerequisites (Local)\nIf you want to run this pattern locally, without any Cloud services, then all you need is VSCode and the\nIBM Blockchain Platform extension. \n- [Install VSCode version 1.39](https://code.visualstudio.com/updates/v1_39)\n- [Install IBM Blockchain Platform Extension for VSCode](https://github.com/IBM-Blockchain/blockchain-vscode-extension)\n- [Node v8.9.0](https://nodejs.org/en/download/)\n- [npm v6.11.3](https://nodejs.org/en/download/)\n\n**🚧🚧Note: you will need Node 8.x to run this pattern!🚧🚧**\n\nFor example, to install and run Node 8.9.0: \n\n```bash\n  brew install nvm\n  nvm install 8.9.0\n  nvm use 8.9.0\n```  \n\n\n# Steps (Local Deployment)\n\u003e To run a local network, you can find steps [here](./docs/run-local.md).\n\n# Steps (Cloud Deployment)\n1. [Clone the Repo](#step-1-clone-the-repo)\n2. [Create IBM Cloud services](#step-2-create-ibm-cloud-services)\n3. [Build a network](#step-3-build-a-network)\n4. [Deploy voterContract Smart Contract on the network](#step-4-deploy-voterContract-smart-contract-on-the-network)\n5. [Connect application to the network](#step-5-connect-application-to-the-network)\n6. [Run the application](#step-6-run-the-application)\n\n## Step 1. Clone the Repo\n\nGit clone this repo onto your computer in the destination of your choice, then go into the web-app folder:\n```\nHoreaPorutiu$ git clone https://github.com/IBM/evote\n```\n\n## Step 2. Create IBM Cloud services\n\n* Create the [IBM Cloud Kubernetes Service](https://cloud.ibm.com/catalog/infrastructure/containers-kubernetes).  You can find the service in the `Catalog`.  For this code pattern, we can use the `Free` cluster, and give it a name.  Note, that the IBM Cloud allows one instance of a free cluster and expires after 30 days. \u003cb\u003eThe cluster takes around 20\nminutes to provision, so please be patient!\u003c/b\u003e\n\n\u003cbr\u003e\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"docs/doc-gifs/createIKS.gif\"\u003e\n\u003c/p\u003e\n\u003cbr\u003e\n\n* Create the [IBM Blockchain Platform](https://console.bluemix.net/catalog/services/blockchain/) service on the IBM Cloud.  You can find the service in the `Catalog`, and give a name.\n\n* After your Kubernetes cluster is up and running, you can deploy your IBM Blockchain Platform service on the cluster. The service walks through few steps and finds your cluster on the IBM Cloud to deploy the service on.\n\n* In the gif below, you can see me choosing my free cluster to deploy my IBM Blockchain Platform.\n\n* Once the Blockchain Platform is deployed on the Kubernetes cluster (which can \ntake a couple of minutes, you can launch the console to start operating on your\nblockchain network by clicking on *Launch the IBM Blockchain Platform*.\n\n\u003cbr\u003e\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"docs/doc-gifs/createIBP.gif\"\u003e\n\u003c/p\u003e\n\u003cbr\u003e\n\n\n## Step 3. Build a network\n\nWe will build a network as provided by the IBM Blockchain Platform [documentation](https://cloud.ibm.com/docs/services/blockchain/howto?topic=blockchain-ibp-console-build-network#ibp-console-build-network). This will include creating a channel with a single peer organization with its own MSP and CA (Certificate Authority), and an orderer organization with its own MSP and CA. We will create the respective identities to deploy peers and operate nodes.\n\n\n### Create your organization and your entry point to your blockchain\n\n* #### Create your Voter Organization CA\n  - Navigate to the \u003cb\u003eNodes\u003c/b\u003e tab in the left navigation and click \u003cb\u003eAdd Certificate Authority +\u003c/b\u003e.\n  - Click \u003cb\u003eCreate a Certificate Authority +\u003c/b\u003e and click \u003cb\u003eNext\u003c/b\u003e.\n  - Give it a \u003cb\u003eCA display name\u003c/b\u003e of `Voter CA`, a \u003cb\u003eCA administrator enroll ID\u003c/b\u003e of `admin` and a \u003cb\u003eCA administrator enroll secret\u003c/b\u003e of `adminpw`, then click \u003cb\u003eNext\u003c/b\u003e.\n  - Review the summary and click \u003cb\u003eAdd Certificate Authority\u003c/b\u003e.\n\n\u003cbr\u003e\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"docs/doc-gifs/voterCA.gif\"\u003e\n\u003c/p\u003e\n\u003cbr\u003e\n\n\n* #### Associate the voter organization CA admin identity\n  - In the Nodes tab, select the \u003cb\u003eVoter CA\u003c/b\u003e once it is running (indicated by the green box in the tile).\n  - Click \u003cb\u003eAssociate identity\u003c/b\u003e on the CA overview panel.\n  - On the side panel, select the \u003cb\u003eEnroll ID\u003c/b\u003e tab. \n  - Provide an \u003cb\u003eEnroll ID\u003c/b\u003e of `admin` and an \u003cb\u003eEnroll secret\u003c/b\u003e of `adminpw`. Use the default value of `Voter CA Admin` for the \u003cb\u003eIdentity display name\u003c/b\u003e.\n  - Click \u003cb\u003eAssociate identity\u003c/b\u003e to add the identity into your wallet and associate the admin identity with the \u003cb\u003eVoter CA\u003c/b\u003e.\n\n\u003cbr\u003e\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"docs/doc-gifs/assoociate-ca-identity.gif\"\u003e\n\u003c/p\u003e\n\u003cbr\u003e\n\n\n* #### Use your CA to register identities\n  - Select the \u003cb\u003eVoter CA\u003c/b\u003e Certificate Authority and ensure the `admin` identity that was created for the CA is visible in the table.\n  - The next step is to register an admin for the organization \"Voter\". Click on the \u003cb\u003eRegister User +\u003c/b\u003e button. Give an \u003cb\u003eEnroll ID\u003c/b\u003e of `voterAdmin` and an \u003cb\u003eEnroll secret\u003c/b\u003e of `voterAdminpw`. Set the \u003cb\u003eType\u003c/b\u003e for this identity as `admin`. Specify to \u003cb\u003eUse root affiliation\u003c/b\u003e. Leave the \u003cb\u003eMaximum enrollments\u003c/b\u003e field blank. Click \u003cb\u003eNext\u003c/b\u003e.\n  - Skip the section to add attributes to this user and click \u003cb\u003eRegister user\u003c/b\u003e.\n  - Repeat the process to create an identity of the peer. Click on the \u003cb\u003eRegister User +\u003c/b\u003e button. Give an \u003cb\u003eEnroll ID\u003c/b\u003e of `peer1` and an \u003cb\u003eEnroll secret\u003c/b\u003e of `peer1pw`. Set the \u003cb\u003eType\u003c/b\u003e for this identity as `peer`. Specify to \u003cb\u003eUse root affiliation\u003c/b\u003e. Leave the \u003cb\u003eMaximum enrollments\u003c/b\u003e field blank. Click \u003cb\u003eNext\u003c/b\u003e.\n  - Skip the section to add attributes to this user and click \u003cb\u003eRegister user\u003c/b\u003e.\n\n\u003cbr\u003e\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"docs/doc-gifs/registerIdentities.gif\"\u003e\n\u003c/p\u003e\n\u003cbr\u003e\n\n\n* #### Create the peer organization MSP definition\n  - Navigate to the \u003cb\u003eOrganizations\u003c/b\u003e tab in the left navigation and click \u003cb\u003eCreate MSP definition +\u003c/b\u003e.\n  - Enter the \u003cb\u003eMSP display name\u003c/b\u003e as `Voter MSP` and the \u003cb\u003eMSP ID\u003c/b\u003e as `votermsp`. Click \u003cb\u003eNext\u003c/b\u003e.\n  - Specify `Voter CA` as the \u003cb\u003eRoot Certificate Authority\u003c/b\u003e. Click \u003cb\u003eNext\u003c/b\u003e.\n  - Select the \u003cb\u003eNew identity\u003c/b\u003e tab. Give the \u003cb\u003eEnroll ID\u003c/b\u003e and \u003cb\u003eEnroll secret\u003c/b\u003e for your organization admin, i.e. `voterAdmin` and `voterAdminpw` respectively. Then, give the \u003cb\u003eIdentity name\u003c/b\u003e as `Voter Admin`.\n  - Click the \u003cb\u003eGenerate\u003c/b\u003e button to enroll this identity as the admin of your organization and add the identity to the wallet. Click \u003cb\u003eExport\u003c/b\u003e to export the admin certificates to your file system. Click \u003cb\u003eNext\u003c/b\u003e.\n  - Review all the information and click \u003cb\u003eCreate MSP definition\u003c/b\u003e.\n\n\u003cbr\u003e\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"docs/doc-gifs/voterMSP.gif\"\u003e\n\u003c/p\u003e\n\u003cbr\u003e\n\n\n* #### Create a peer\n  - Navigate to the \u003cb\u003eNodes\u003c/b\u003e tab in the left navigation and click \u003cb\u003eAdd peer +\u003c/b\u003e.\n  - Click \u003cb\u003eCreate a peer +\u003c/b\u003e and then click \u003cb\u003eNext\u003c/b\u003e.\n  - Give the \u003cb\u003ePeer display name\u003c/b\u003e as `Voter Peer` and click \u003cb\u003eNext\u003c/b\u003e.\n  - On the next screen, select `Voter CA` as the \u003cb\u003eCertificate Authority\u003c/b\u003e. Then, give the \u003cb\u003ePeer enroll ID\u003c/b\u003e and \u003cb\u003ePeer enroll secret\u003c/b\u003e as `peer1` and `peer1pw` respectively. Select the \u003cb\u003eOrganization MSP\u003c/b\u003e as `Voter MSP`. Leave the \u003cb\u003eTLS CSR hostname\u003c/b\u003e blank and select `1.4.7-0` in the drop-down for \u003cb\u003eFabric version\u003c/b\u003e. Click \u003cb\u003eNext\u003c/b\u003e.\n  - Provide `Voter Admin` as the \u003cb\u003ePeer administrator identity\u003c/b\u003e and click \u003cb\u003eNext\u003c/b\u003e.\n  - Review the summary and click \u003cb\u003eAdd peer\u003c/b\u003e.\n\n\u003cbr\u003e\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"docs/doc-gifs/voterPeer.gif\"\u003e\n\u003c/p\u003e\n\u003cbr\u003e\n\n\n### Create the node that orders transactions\n\n* #### Create your orderer organization CA\n  - Navigate to the \u003cb\u003eNodes\u003c/b\u003e tab in the left navigation and click \u003cb\u003eAdd Certificate Authority +\u003c/b\u003e.\n  - Click \u003cb\u003eCreate a Certificate Authority +\u003c/b\u003e and click \u003cb\u003eNext\u003c/b\u003e.\n  - Give it a \u003cb\u003eCA display name\u003c/b\u003e of `Orderer CA`, a \u003cb\u003eCA administrator enroll ID\u003c/b\u003e of `admin` and a \u003cb\u003eCA administrator enroll secret\u003c/b\u003e of `adminpw`, then click \u003cb\u003eNext\u003c/b\u003e.\n  - Review the summary and click \u003cb\u003eAdd Certificate Authority\u003c/b\u003e.\n\n\u003cbr\u003e\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"docs/doc-gifs/ordererCA.gif\"\u003e\n\u003c/p\u003e\n\u003cbr\u003e\n\n* #### Associate the orderer organization CA admin identity\n  - In the Nodes tab, select the \u003cb\u003eOrderer CA\u003c/b\u003e once it is running (indicated by the green box in the tile).\n  - Click \u003cb\u003eAssociate identity\u003c/b\u003e on the CA overview panel.\n  - On the side panel, select the \u003cb\u003eEnroll ID\u003c/b\u003e tab. \n  - Provide an \u003cb\u003eEnroll ID\u003c/b\u003e of `admin` and an \u003cb\u003eEnroll secret\u003c/b\u003e of `adminpw`. Use the default value of `Orderer CA Admin` for the \u003cb\u003eIdentity display name\u003c/b\u003e.\n  - Click \u003cb\u003eAssociate identity\u003c/b\u003e to add the identity into your wallet and associate the admin identity with the \u003cb\u003eOrderer CA\u003c/b\u003e.\n\n\u003cbr\u003e\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"docs/doc-gifs/assoociate-orderer-ca-identity.gif\"\u003e\n\u003c/p\u003e\n\u003cbr\u003e\n\n\n* #### Use your CA to register orderer and orderer admin identities\n  - Select the \u003cb\u003eOrderer CA\u003c/b\u003e Certificate Authority and ensure the `admin` identity that was created for the CA is visible in the table.\n  - The next step is to register an admin for the organization \"Orderer\". Click on the \u003cb\u003eRegister User +\u003c/b\u003e button. Give an \u003cb\u003eEnroll ID\u003c/b\u003e of `ordererAdmin` and an \u003cb\u003eEnroll secret\u003c/b\u003e of `ordererAdminpw`. Set the \u003cb\u003eType\u003c/b\u003e for this identity as `admin`. Specify to \u003cb\u003eUse root affiliation\u003c/b\u003e. Leave the \u003cb\u003eMaximum enrollments\u003c/b\u003e field blank. Click \u003cb\u003eNext\u003c/b\u003e.\n  - Skip the section to add attributes to this user and click \u003cb\u003eRegister user\u003c/b\u003e.\n  - Repeat the process to create an identity of the orderer. Click on the \u003cb\u003eRegister User +\u003c/b\u003e button. Give an \u003cb\u003eEnroll ID\u003c/b\u003e of `orderer1` and an \u003cb\u003eEnroll secret\u003c/b\u003e of `orderer1pw`. Set the \u003cb\u003eType\u003c/b\u003e for this identity as `orderer`. Specify to \u003cb\u003eUse root affiliation\u003c/b\u003e. Leave the \u003cb\u003eMaximum enrollments\u003c/b\u003e field blank. Click \u003cb\u003eNext\u003c/b\u003e.\n  - Skip the section to add attributes to this user and click \u003cb\u003eRegister user\u003c/b\u003e.\n\n\u003cbr\u003e\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"docs/doc-gifs/ordererIdentities.gif\"\u003e\n\u003c/p\u003e\n\u003cbr\u003e\n\n\n* #### Create the orderer organization MSP definition\n  - Navigate to the \u003cb\u003eOrganizations\u003c/b\u003e tab in the left navigation and click \u003cb\u003eCreate MSP definition +\u003c/b\u003e.\n  - Enter the \u003cb\u003eMSP display name\u003c/b\u003e as `Orderer MSP` and the \u003cb\u003eMSP ID\u003c/b\u003e as `orderermsp`. Click \u003cb\u003eNext\u003c/b\u003e.\n  - Specify `Orderer CA` as the \u003cb\u003eRoot Certificate Authority\u003c/b\u003e. Click \u003cb\u003eNext\u003c/b\u003e.\n  - Select the \u003cb\u003eNew identity\u003c/b\u003e tab. Give the \u003cb\u003eEnroll ID\u003c/b\u003e and \u003cb\u003eEnroll secret\u003c/b\u003e for your organization admin, i.e. `ordererAdmin` and `ordererAdminpw` respectively. Then, give the \u003cb\u003eIdentity name\u003c/b\u003e as `Orderer Admin`.\n  - Click the \u003cb\u003eGenerate\u003c/b\u003e button to enroll this identity as the admin of your organization and add the identity to the wallet. Click \u003cb\u003eExport\u003c/b\u003e to export the admin certificates to your file system. Click \u003cb\u003eNext\u003c/b\u003e.\n  - Review all the information and click \u003cb\u003eCreate MSP definition\u003c/b\u003e.\n\n\u003cbr\u003e\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"docs/doc-gifs/ordererMSP.gif\"\u003e\n\u003c/p\u003e\n\u003cbr\u003e\n\n\n* #### Create an orderer\n  - Navigate to the \u003cb\u003eNodes\u003c/b\u003e tab in the left navigation and click \u003cb\u003eAdd ordering service +\u003c/b\u003e.\n  - Click \u003cb\u003eCreate an ordering service +\u003c/b\u003e and then click \u003cb\u003eNext\u003c/b\u003e.\n  - Give the \u003cb\u003eOrdering service display name\u003c/b\u003e as `Orderer` and click \u003cb\u003eNext\u003c/b\u003e.\n  - On the next screen, select `Orderer CA` as the \u003cb\u003eCertificate Authority\u003c/b\u003e. Then, give the \u003cb\u003eOrdering service enroll ID\u003c/b\u003e and \u003cb\u003eOrdering service enroll secret\u003c/b\u003e as `orderer1` and `orderer1pw` respectively. Select the \u003cb\u003eOrganization MSP\u003c/b\u003e as `Orderer MSP`. Leave the \u003cb\u003eTLS CSR hostname\u003c/b\u003e blank and select `1.4.7-0` in the drop-down for \u003cb\u003eFabric version\u003c/b\u003e. Click \u003cb\u003eNext\u003c/b\u003e.\n  - Provide `Orderer Admin` as the \u003cb\u003eOrderer administrator identity\u003c/b\u003e and click \u003cb\u003eNext\u003c/b\u003e.\n  - Review the summary and click \u003cb\u003eAdd ordering service\u003c/b\u003e.\n\n\u003cbr\u003e\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"docs/doc-gifs/createOrderer.gif\"\u003e\n\u003c/p\u003e\n\u003cbr\u003e\n\n* #### Add organization as Consortium Member on the orderer to transact\n  - Navigate to the \u003cb\u003eNodes\u003c/b\u003e tab, and click on the \u003cb\u003eOrderer\u003c/b\u003e that was created.\n  - Under \u003cb\u003eConsortium Members\u003c/b\u003e, click \u003cb\u003eAdd organization +\u003c/b\u003e.\n  - Select the \u003cb\u003eExisting MSP ID\u003c/b\u003e tab. From the drop-down list, select `Voter MSP (votermsp)`, as this is the MSP that represents the peer's organization \"Voter\".\n  - Click \u003cb\u003eAdd organization\u003c/b\u003e.\n\n\u003cbr\u003e\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"docs/doc-gifs/consortium.gif\"\u003e\n\u003c/p\u003e\n\u003cbr\u003e\n\n\n### Create and join channel\n\n* #### Create the channel\n  - Navigate to the \u003cb\u003eChannels\u003c/b\u003e tab in the left navigation and click \u003cb\u003eCreate channel +\u003c/b\u003e.\n  - Click \u003cb\u003eNext\u003c/b\u003e.\n  - Give the \u003cb\u003eChannel name\u003c/b\u003e as `mychannel`. Select `Orderer` from the \u003cb\u003eOrdering service\u003c/b\u003e drop-down list. Click \u003cb\u003eNext\u003c/b\u003e.\n  - Under \u003cb\u003eOrganizations\u003c/b\u003e, select `Voter MSP (votermsp)` from the drop-down list to add the organization \"Voter\" as a member of this channel. Click the \u003cb\u003eAdd\u003c/b\u003e button. Set the permissions for this member as \u003cb\u003eOperator\u003c/b\u003e. Click \u003cb\u003eNext\u003c/b\u003e.\n  - Leave the \u003cb\u003ePolicy\u003c/b\u003e as the default value i.e. `1 out of 1`. Click \u003cb\u003eNext\u003c/b\u003e.\n  - Select the \u003cb\u003eChannel creator MSP\u003c/b\u003e as `Voter MSP (votermsp)` and the \u003cb\u003eIdentity\u003c/b\u003e as `Voter Admin`. Click \u003cb\u003eNext\u003c/b\u003e.\n  - Review the summary and click \u003cb\u003eCreate channel\u003c/b\u003e.\n\n\u003cbr\u003e\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"docs/doc-gifs/createChannel.gif\"\u003e\n\u003c/p\u003e\n\u003cbr\u003e\n\n\n* #### Join your peer to the channel\n  - Click on the newly created channel \u003cb\u003emychannel\u003c/b\u003e.\n  - In the side panel that opens, under \u003cb\u003eChoose from available peers\u003c/b\u003e, select `Voter Peer`. Once the peer is selected, a check mark will be displayed next to it. Ensure that \u003cb\u003eMake anchor peer(s)\u003c/b\u003e is marked as `Yes`. Click \u003cb\u003eJoin channel\u003c/b\u003e.\n\n\u003cbr\u003e\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"docs/doc-gifs/joinChannel.gif\"\u003e\n\u003c/p\u003e\n\u003cbr\u003e\n\n\n## Step 4. Deploy voterContract Smart Contract on the network\n\n* #### Install a smart contract\n  - Navigate to the \u003cb\u003eSmart contracts\u003c/b\u003e tab in the left navigation and click \u003cb\u003eInstall smart contract +\u003c/b\u003e.\n  - Click on \u003cb\u003eAdd file\u003c/b\u003e.\n  - Browse to the location of the voterContract smart contract package file, which is in the root of the repo we cloned - the file is called `voterContract.cds`.\n  - Once the contract is uploaded, click \u003cb\u003eInstall smart contract\u003c/b\u003e.\n\n\u003cbr\u003e\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"docs/doc-gifs/installContract.gif\"\u003e\n\u003c/p\u003e\n\u003cbr\u003e\n\n\n* #### Instantiate smart contract\n  - Under \u003cb\u003eInstalled smart contracts\u003c/b\u003e, find the smart contract from the list (**Note: ours is called voterContract**) installed on our peer and click \u003cb\u003eInstantiate\u003c/b\u003e from the overflow menu on the right side of the row.\n  - On the side panel that opens, select the channel, `mychannel` on which to instantiate the smart contract. Click \u003cb\u003eNext\u003c/b\u003e.\n  - Select `Voter MSP` as the organization member to be included in the endorsement policy. Click \u003cb\u003eNext\u003c/b\u003e.\n  - Skip the \u003cb\u003eSetup private data collection\u003c/b\u003e step and simply click \u003cb\u003eNext\u003c/b\u003e.\n  - Give the \u003cb\u003eFunction name\u003c/b\u003e as `init` and leave the \u003cb\u003eArguments\u003c/b\u003e blank. \u003cb\u003eNote: init is the method in the voterContract.js file that initiates the smart contracts on the peer.\u003c/b\u003e\n  - Click \u003cb\u003eInstantiate smart contract\u003c/b\u003e.\n\n\u003cbr\u003e\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"docs/doc-gifs/instantiateContract.gif\"\u003e\n\u003c/p\u003e\n\u003cbr\u003e\n\n\n## Step 5. Connect application to the network\n\n* #### Connect with sdk through connection profile\n  - Navigate to the \u003cb\u003eOrganizations\u003c/b\u003e tab in the left navigation, and click on \u003cb\u003eVoter MSP\u003c/b\u003e.\n  - Click on \u003cb\u003eDownload Connection Profile\u003c/b\u003e. \n  - In the side panel that opens up, select `Yes` as the response for \u003cb\u003eInclude Voter CA for user registration and enrollment?\u003c/b\u003e. Under \u003cb\u003e Select peers to include\u003c/b\u003e, select `Voter Peer`. Then click \u003cb\u003eDownload connection profile\u003c/b\u003e. This will download the connection json which we will use to establish a connection between the Node.js web application and the Blockchain Network.\n\n\u003cbr\u003e\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"docs/doc-gifs/downloadCCP.gif\"\u003e\n\u003c/p\u003e\n\u003cbr\u003e\n\n\n* #### Create an application admin\n  - Navigate to the \u003cb\u003eNodes\u003c/b\u003e tab in the left navigation, and under \u003cb\u003eCertificate Authorities\u003c/b\u003e, choose \u003cb\u003eVoter CA\u003c/b\u003e.\n  - Click on the \u003cb\u003eRegister User +\u003c/b\u003e button. Give an \u003cb\u003eEnroll ID\u003c/b\u003e of `app-admin` and an \u003cb\u003eEnroll secret\u003c/b\u003e of `app-adminpw`. Set the \u003cb\u003eType\u003c/b\u003e for this identity as `client`. Specify to \u003cb\u003eUse root affiliation\u003c/b\u003e. Leave the \u003cb\u003eMaximum enrollments\u003c/b\u003e field blank. Click \u003cb\u003eNext\u003c/b\u003e.\n  - Click on \u003cb\u003eAdd attribute +\u003c/b\u003e. Enter the \u003cb\u003eattribute name\u003c/b\u003e as `hf.Registrar.Roles` and the \u003cb\u003eattribute value\u003c/b\u003e as `*`. Click \u003cb\u003eRegister user\u003c/b\u003e.\n\n\u003cbr\u003e\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"docs/doc-gifs/appAdmin.gif\"\u003e\n\u003c/p\u003e\n\u003cbr\u003e\n\n\n* #### Update application connection\n  - Copy the connection profile you downloaded into [server folder](./web-app/server)\n  - Rename the connection profile you downloaded **ibpConnection.json**\n  - Update the [config.json](server/config.json) file with:\n    - `ibpConnection.json`.\n    - The \u003cb\u003eenroll id\u003c/b\u003e and \u003cb\u003eenroll secret\u003c/b\u003e for your app admin, which we earlier provided as `app-admin` and `app-adminpw`.\n    - The orgMSP ID, which we provided as `votermsp`.\n    - The caName, which can be found in your connection json file under \"organizations\" -\u003e \"votermsp\" -\u003e certificateAuthorities\". This would be like an IP address and a port. You should also use the `https` version of the certificateAuthorities line.\n    - The username you would like to register.\n    - Update gateway discovery to `{ enabled: true, asLocalhost: false }` to connect to IBP.\n\n\u003cbr\u003e\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"docs/doc-gifs/updateConfig.gif\"\u003e\n\u003c/p\u003e\n\u003cbr\u003e\n\n- Once you are done, the final version of the **config.json** should look something like this:\n\n```js\n{\n    \"connection_file\": \"ibpConnection.json\",\n    \"appAdmin\": \"app-admin\",\n    \"appAdminSecret\": \"app-adminpw\",\n    \"orgMSPID\": \"votermsp\",\n    \"caName\": \"https://173.193.106.28:32634\",\n    \"userName\": \"V1\",\n    \"gatewayDiscovery\": { \"enabled\": true, \"asLocalhost\": false }\n}\n```\n\n\n## Step 6. Run the application\n\n* #### Enroll admin\n  - First, navigate to the `web-app/server` directory, and install the node dependencies.\n    ```bash\n    cd web-app/server\n    npm install\n    ```\n  \n  - Run the `enrollAdmin.js` script\n    ```bash\n    node enrollAdmin.js\n    ```\n\n  - You should see the following in the terminal:\n    ```bash\n    msg: Successfully enrolled admin user app-admin and imported it into the wallet\n    ```\n\n  - Start the server:\n    ```bash\n    npm start\n    ```\n\n\u003cbr\u003e\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"docs/doc-gifs/startServer.gif\"\u003e\n\u003c/p\u003e\n\u003cbr\u003e\n\n* #### Start the web client\n  - In a new terminal, open the `web-app/client` folder from the root directory. \n  Install the required dependencies with `npm install`.\n    ```bash\n    cd web-app/client\n    npm install\n    ```\n\n  - Start the client:\n    ```bash\n    npm run serve\n    ```\n\n  - In a browser of your choice, go to http://localhost:8080/#/.  If all goes well, you should see \n  something like the gif below:\n\n\u003cbr\u003e\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"docs/doc-gifs/runClient.gif\"\u003e\n\u003c/p\u003e\n\u003cbr\u003e\n\nYou can find the app running at http://localhost:8080/  If all goes well, you should be greeted \nwith the homepage that says \u003cb\u003e2020 Presidential Election\u003c/b\u003e\n\nNow, we can start interacting with the app.\n\nFirst, we need to register as a voter, and create our digital identity with \nwhich we will submit our vote with. To do this, we will need to enter \na uniqueId (drivers license) with a registrarId, and our first and last names.\nAfter we do that, and click `register` the world state will be updated with \nour voterId and our name and registrarId.\n\nIf all goes well, you should see `voter with voterId {} is updated in the world state. Use voterId to login above.`\n\u003cb\u003eNote: on the first try, the app can take a second to start up. If you click on `register` and nothing \nhappens, try to fill in the form and click register again!\u003c/b\u003e\n\nNext, we can login to the app with our voterId.\n\nOnce we login, we can cast our vote. We will use our voterId again to cast our \nvote. Since we are voting for the presidential\nelection for 2020, we can choose the party of our liking. Once we are done, we\ncan choose submit, and then our vote is cast. As long as this voterId hasn't \nvoted before, all is well. Next, we can view the poll standings by clicking\n`Get Poll Standings` and clicking `Check Poll`. This will query the world \nstate and get the current number of votes for each political party.\n\n\u003cbr\u003e\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"docs/doc-gifs/demo.gif\"\u003e\n\u003c/p\u003e\n\u003cbr\u003e\n\nIf we want to query for a particular voterId, we can do so in the `Query by Key` tab.\nIf we want to query by object, we can do so by clicking on the `Query by Type` \ntab, and entering a type, such as `voter`. This will return all voter objects \nthat are currently in the state. `QueryAll` will return all objects in the state.\n\n\u003cbr\u003e\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"docs/doc-gifs/query.gif\"\u003e\n\u003c/p\u003e\n\u003cbr\u003e\n\n\n## Extending the code pattern\nPull requests and contribution are always welcome. Remember that a code pattern is a path to a solution, \nand not a complete solution on its own. To make this a more complete solution,\nthis application can be expanded in a couple of ways:\n\n  * Use an API to verify the drivers license to make sure it is valid, and registered with the DMV.\n  * Use a more complex consensus mechanism where multiple organizations (DMV, US Federal Government, US State\n  Government) have to approve a vote before it is successfully recorded onto the blockchain.\n  * Use ordering service which uses Raft consensus mechanism.\n\n\n## Troubleshooting\n\n* If you get an error that says `Error: Calling register endpoint failed with error [Error: self signed certificate]`, you can get past this by adding `\"httpOptions\": {\"verify\": false}` to the certificateAuthorities section of the connection profile that was downloaded from IBM Blockchain Platform.\n\n\u003cbr\u003e\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"docs/troubleshooting-self-signed-certificate.png\"\u003e\n\u003c/p\u003e\n\u003cbr\u003e\n\n\u003cbr\u003e\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"docs/troubleshooting-https-options.png\"\u003e\n\u003c/p\u003e\n\u003cbr\u003e\n\n\n## Related Links\n* [Hyperledger Fabric Docs](http://hyperledger-fabric.readthedocs.io/en/latest/)\n* [IBM Code Patterns for Blockchain](https://developer.ibm.com/patterns/category/blockchain/)\n\n\n## License\nThis code pattern is licensed under the Apache Software License, Version 2. Separate third-party code objects invoked within this code pattern are licensed by their respective providers pursuant to their own separate licenses. Contributions are subject to the [Developer Certificate of Origin, Version 1.1 (DCO)](https://developercertificate.org/) and the [Apache Software License, Version 2](https://www.apache.org/licenses/LICENSE-2.0.txt).\n\n[Apache Software License (ASL) FAQ](https://www.apache.org/foundation/license-faq.html#WhatDoesItMEAN)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fibm%2Fevote","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fibm%2Fevote","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fibm%2Fevote/lists"}