Voting Application using Smart Contract

Please read some useful posts first:

In this demo, I use web3 version 1.0.0-beta.33, solidity 0.4.21. We can implement on frontend or backend separately.

Approach 1

We can implement on server, all request from client must send to server handle. But the limitation is server must have private key of wallet to sign transaction and sending.

Approach 1

Approach 2

Implement on frontend only using Metamask provider for payment. But the limitation is Metamask not support for subscribe event emit from Ethereum network.

Approach 2

Approach 3

Implement both on frontend and backend also, connect its by socket.io and use backend listen event and transit to frontend.

Approach 3

My demo project just stop at a haft of Approach 3. It implement on both frontend and backend also, listen event on backend but not implement socket communication to send event to frontend. It can be easy. But I don’t have VPS so to deploy backend, so I wont. Do it yourself 😀

Simple smart contract source

Demo: https://nhancv.github.io/nc-smartcontract/home/index.html

Github repo

https://github.com/nhancv/nc-smartcontract

Leave a Reply

Your email address will not be published.Required fields are marked *