Create a dapp for voting where all of the votes and candidate registration happens on chain. Allow anyone to start an election with a registration period, voting period, and ending time. Allow anyone to sign up as a candidate during the registration period, and allow anyone to vote once during the voting period. Create a front end where voters can see the results and know how long is left in the election.
Assumptions:
- One election can be running and started by anyone.
- Anyone can sign up as a candidate.
- Voters can only vote once.
- Registration Starts immediately after an election is created.
- Voting starts immediately following the registration period.
- A new election can be started once this one has ended.
To get a local copy up and running follow these simple steps.
- Clone the repo
git clone https://github.com/0xdavinchee/ethhole-voting-dapp.git
- Install NPM packages
npm install
- Create a
.env
file and add the two following values:
INFURA_API_KEY
: You can get this from https://infura.io by signing up for a free account.RINKEBY_PRIVATE_KEY
(if you want to deploy to testnet).
To compile: npx hardhat compile
.
To run tests: npx hardhat test
.
Run npx hardhat node
to start up a local node.
Open up another terminal window and run npx hardhat deploy --network localhost
to deploy your project to localhost. You can similarly deploy to other networks like so: npx hardhat deploy --network <NETWORK>
To set up the graph you need to initialize a graph project, you can follow follow the instructions here: https://medium.com/blockrocket/dapp-development-with-a-local-subgraph-ganache-setup-566a4d4cbb.
I currently first verify my contract on rinkeby and then use graph init
to initialize the project using the deployed project so that the graph initializes the project with the correct ABI and some boilerplate code.
Distributed under the MIT License. See LICENSE
for more information.
@0xdavinchee - 0xdavinchee@gmail.com
Project Link: https://github.com/0xdavinchee/ethhole-voting-dapp