Project Name | Stars | Downloads | Repos Using This | Packages Using This | Most Recent Commit | Total Releases | Latest Release | Open Issues | License | Language |
---|---|---|---|---|---|---|---|---|---|---|
Build Blockchain Insurance App | 715 | 7 months ago | 37 | apache-2.0 | JavaScript | |||||
Sample insurance application using Hyperledger Fabric | ||||||||||
Blockchain Reference | 390 | 3 months ago | mit | Racket | ||||||
blockchain reference 区块链参考资料 | ||||||||||
Evote | 266 | a year ago | 26 | apache-2.0 | JavaScript | |||||
A voting application that leverages Hyperledger Fabric and the IBM Blockchain Platform to record and tally ballots. | ||||||||||
Blockchain Vscode Extension | 259 | 4 months ago | 2 | other | TypeScript | |||||
IBM Blockchain Platform extension for Visual Studio Code (this project is no longer active) | ||||||||||
Blockchain Network On Kubernetes | 256 | 2 years ago | 8 | apache-2.0 | Shell | |||||
Demonstrates the steps involved in setting up your business network on Hyperledger Fabric using Kubernetes APIs on IBM Cloud Kubernetes Service. | ||||||||||
Road2blockchain | 248 | 5 years ago | 4 | |||||||
180天搞懂区块链。 区块链的浪潮已来, 当一个弄潮儿,随时准备冲上浪潮之巅。(由于时间精力的原因, 项目暂时搁置,不再更新。 抱歉, 有一腔热情,但是吹下的牛逼没有按时完成。不过对区块链依然保持关注, 欢迎大家关注公众号allinblockchain) | ||||||||||
Blockchain Samples | 155 | 4 years ago | 15 | apache-2.0 | Go | |||||
Samples demonstrating the use of Blockchain with IBM Watson IoT | ||||||||||
Study Blockchain Referrence | 135 | 5 years ago | mit | |||||||
区块链学习路上的一些资料作为参考 | ||||||||||
Fabcar Blockchain Sample | 107 | 5 months ago | 53 | apache-2.0 | JavaScript | |||||
Use a Kubernetes cluster to deploy a Fabric network smart contract onto blockchain | ||||||||||
Ibm Container Service | 81 | 5 years ago | 14 | apache-2.0 | Shell | |||||
IBM Blockchain Platform for Developers on IBM Container Service |
This repository will not be updated. I will check periodically for pull requests, but do not expect a quick response.
NOTE: This developer pattern creates a blockchain network on IBM Blockchain Platform version 2.5 using the Hyperledger Fabric version 1.4.
Have you ever wondered how exactly the votes in a presidential election counted? What if instead of having volunteers that are spending hours a day counting votes manually, we have an app that was backed by blockchain, recording each vote made by a voter, ensuring 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 drivers license, get a unique voterId which is used to login to the app, and cast the vote. The vote is tallied on the blockchain, and the web-app shows the current standings of the polls.
At the start of the application, the user registers to vote by providing their drivers license number, registrar district, and first and last name. In this step, we can check to see if the drivers license is valid, and has not been registered previously. If all goes well, we create a private and public key for the voter with our certificate authority that is running on the cloud, and add those keys to the wallet. To read more about public key infrastructure, and how Hyperledger Fabric implements identity using this technology, go here.
After that, we use our drivers license number to submit our vote, during which the application checks if this drivers license number has voted before and tells the user they have already submitted a vote if so. If all goes well, the political party which the voter has chosen is given a vote, and the world state is updated. The application then updates our current standings of the election to show how many votes each political party currently has.
Since each transaction that is submitted to the ordering service must have a signature from a valid public-private key pair, we can trace back each transaction to a registered voter of the application, in the case of an audit.
In conclusion, although this is a simple application, the developer can see how they can implement a Hyperledger Fabric web-app to decrease the chance of election-meddling, and enhance a voting application by using blockchain technology.
When the reader has completed this code pattern, they will understand how to:
This Cloud pattern assumes you have an IBM Cloud account.
You do not technically need VSCode or the IBM Blockchain Platform extension for VSCode if you are running the Cloud pattern, but if you want to make any changes to the smart contract, you will need the extension to package your smart contract project.
If you want to run this pattern locally, without any Cloud services, then all you need is VSCode and the IBM Blockchain Platform extension.
🚧🚧Note: you will need Node 8.x to run this pattern!🚧🚧
For example, to install and run Node 8.9.0:
brew install nvm
nvm install 8.9.0
nvm use 8.9.0
To run a local network, you can find steps here.
Git clone this repo onto your computer in the destination of your choice, then go into the web-app folder:
HoreaPorutiu$ git clone https://github.com/IBM/evote
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. The cluster takes around 20
minutes to provision, so please be patient!
Create the IBM Blockchain Platform service on the IBM Cloud. You can find the service in the Catalog
, and give a name.
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.
In the gif below, you can see me choosing my free cluster to deploy my IBM Blockchain Platform.
Once the Blockchain Platform is deployed on the Kubernetes cluster (which can take a couple of minutes, you can launch the console to start operating on your blockchain network by clicking on Launch the IBM Blockchain Platform.
We will build a network as provided by the IBM Blockchain Platform documentation. 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.
Voter CA
, a CA administrator enroll ID of admin
and a CA administrator enroll secret of adminpw
, then click Next.
admin
and an Enroll secret of adminpw
. Use the default value of Voter CA Admin
for the Identity display name.
admin
identity that was created for the CA is visible in the table.voterAdmin
and an Enroll secret of voterAdminpw
. Set the Type for this identity as admin
. Specify to Use root affiliation. Leave the Maximum enrollments field blank. Click Next.peer1
and an Enroll secret of peer1pw
. Set the Type for this identity as peer
. Specify to Use root affiliation. Leave the Maximum enrollments field blank. Click Next.
Voter MSP
and the MSP ID as votermsp
. Click Next.Voter CA
as the Root Certificate Authority. Click Next.voterAdmin
and voterAdminpw
respectively. Then, give the Identity name as Voter Admin
.
Voter Peer
and click Next.Voter CA
as the Certificate Authority. Then, give the Peer enroll ID and Peer enroll secret as peer1
and peer1pw
respectively. Select the Organization MSP as Voter MSP
. Leave the TLS CSR hostname blank and select 1.4.7-0
in the drop-down for Fabric version. Click Next.Voter Admin
as the Peer administrator identity and click Next.
Orderer CA
, a CA administrator enroll ID of admin
and a CA administrator enroll secret of adminpw
, then click Next.
admin
and an Enroll secret of adminpw
. Use the default value of Orderer CA Admin
for the Identity display name.
admin
identity that was created for the CA is visible in the table.ordererAdmin
and an Enroll secret of ordererAdminpw
. Set the Type for this identity as admin
. Specify to Use root affiliation. Leave the Maximum enrollments field blank. Click Next.orderer1
and an Enroll secret of orderer1pw
. Set the Type for this identity as orderer
. Specify to Use root affiliation. Leave the Maximum enrollments field blank. Click Next.
Orderer MSP
and the MSP ID as orderermsp
. Click Next.Orderer CA
as the Root Certificate Authority. Click Next.ordererAdmin
and ordererAdminpw
respectively. Then, give the Identity name as Orderer Admin
.
Orderer
and click Next.Orderer CA
as the Certificate Authority. Then, give the Ordering service enroll ID and Ordering service enroll secret as orderer1
and orderer1pw
respectively. Select the Organization MSP as Orderer MSP
. Leave the TLS CSR hostname blank and select 1.4.7-0
in the drop-down for Fabric version. Click Next.Orderer Admin
as the Orderer administrator identity and click Next.
Voter MSP (votermsp)
, as this is the MSP that represents the peer's organization "Voter".
mychannel
. Select Orderer
from the Ordering service drop-down list. Click Next.Voter MSP (votermsp)
from the drop-down list to add the organization "Voter" as a member of this channel. Click the Add button. Set the permissions for this member as Operator. Click Next.1 out of 1
. Click Next.Voter MSP (votermsp)
and the Identity as Voter Admin
. Click Next.
Voter Peer
. Once the peer is selected, a check mark will be displayed next to it. Ensure that Make anchor peer(s) is marked as Yes
. Click Join channel.
voterContract.cds
.
mychannel
on which to instantiate the smart contract. Click Next.Voter MSP
as the organization member to be included in the endorsement policy. Click Next.init
and leave the Arguments blank. Note: init is the method in the voterContract.js file that initiates the smart contracts on the peer.
Yes
as the response for Include Voter CA for user registration and enrollment?. Under Select peers to include, select Voter Peer
. Then click Download connection profile. This will download the connection json which we will use to establish a connection between the Node.js web application and the Blockchain Network.
app-admin
and an Enroll secret of app-adminpw
. Set the Type for this identity as client
. Specify to Use root affiliation. Leave the Maximum enrollments field blank. Click Next.hf.Registrar.Roles
and the attribute value as *
. Click Register user.
ibpConnection.json
.app-admin
and app-adminpw
.votermsp
.https
version of the certificateAuthorities line.{ enabled: true, asLocalhost: false }
to connect to IBP.
{
"connection_file": "ibpConnection.json",
"appAdmin": "app-admin",
"appAdminSecret": "app-adminpw",
"orgMSPID": "votermsp",
"caName": "https://173.193.106.28:32634",
"userName": "V1",
"gatewayDiscovery": { "enabled": true, "asLocalhost": false }
}
First, navigate to the web-app/server
directory, and install the node dependencies.
cd web-app/server
npm install
Run the enrollAdmin.js
script
node enrollAdmin.js
You should see the following in the terminal:
msg: Successfully enrolled admin user app-admin and imported it into the wallet
Start the server:
npm start
In a new terminal, open the web-app/client
folder from the root directory.
Install the required dependencies with npm install
.
cd web-app/client
npm install
Start the client:
npm run serve
In a browser of your choice, go to http://localhost:8080/#/. If all goes well, you should see something like the gif below:
You can find the app running at http://localhost:8080/ If all goes well, you should be greeted with the homepage that says 2020 Presidential Election
Now, we can start interacting with the app.
First, we need to register as a voter, and create our digital identity with
which we will submit our vote with. To do this, we will need to enter
a uniqueId (drivers license) with a registrarId, and our first and last names.
After we do that, and click register
the world state will be updated with
our voterId and our name and registrarId.
If all goes well, you should see voter with voterId {} is updated in the world state. Use voterId to login above.
Note: on the first try, the app can take a second to start up. If you click on register
and nothing
happens, try to fill in the form and click register again!
Next, we can login to the app with our voterId.
Once we login, we can cast our vote. We will use our voterId again to cast our
vote. Since we are voting for the presidential
election for 2020, we can choose the party of our liking. Once we are done, we
can choose submit, and then our vote is cast. As long as this voterId hasn't
voted before, all is well. Next, we can view the poll standings by clicking
Get Poll Standings
and clicking Check Poll
. This will query the world
state and get the current number of votes for each political party.
If we want to query for a particular voterId, we can do so in the Query by Key
tab.
If we want to query by object, we can do so by clicking on the Query by Type
tab, and entering a type, such as voter
. This will return all voter objects
that are currently in the state. QueryAll
will return all objects in the state.
Pull requests and contribution are always welcome. Remember that a code pattern is a path to a solution, and not a complete solution on its own. To make this a more complete solution, this application can be expanded in a couple of ways:
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.
This 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) and the Apache Software License, Version 2.