Truffle-Ballot-Dapp
Language
简体中文 | Engish
Overview
The Truffle-Ballot-Dapp is a Ethereum-Based Ballot demo, including the features like giving ballot to the person you want based on smart-contart and making sure that any address(voters) only have one ballot. Further more, The program contains ABI(Application Binary Interface) to link Contract Layer to Application Layer. Fore more detail, you could clone
this repositories.
Front-End page is as follow:
Dependencies
- Npm
For more information , Get from https://nodejs.org/en/
- Metamask
A crypto wallet & gateway to blockchain apps, Get from https://metamask.io
- Yarn(optional)
Yarn is a package manager that doubles down as project manager, which can fix some bug from NPM.
Quick Start
You should install the Dependencies above before getting start.
- Install
Truffle
globally.
npm install -g truffle
- Run the development console.
truffle develop
- You can alternatively choose one step as follow.
- Compile and migrate the smart contracts. Note inside the development console we don't preface commands with truffle.(Recommand)
compile
migrate
- Using Ganache-CLI for build (Alternatively).
It's as easy as modifying the config file! Check out the documentation on adding network configurations. Depending on the port you're using, you'll also need to update line 29 of client/src/utils/getWeb3.js.
truffle compile
truffle migrate
- Start React pages
In the client directory, we run the React app. Smart contract changes must be manually recompiled and migrated.
cd client
And then ,
npm install
or if you have Yarn
yarn
- Open the URL at
Chrome
orFireFox
withmetamask
You should login the Account with metamask and have a ballot. To pay the gas you should have some ETH. You can import the privacy key in metamask and get about 100 ETH in your test network.
Limitation
- Adding new candidates
- Anonymous Accounts to ballot
- Privacy protect method
To-Do-List
- Using random-response for ballot result
- Take some privacy method such as differential privacy (DP) to protect the Accounts' ballot result.
Reference
https://github.com/truffle-box/react-box