Welcome to the Scaffold ETH 2 + MACI Voting Template! This template is a powerful starting point for developers aiming to build decentralized voting applications that prioritize privacy and resist collusion. Combining the rapid development environment of Scaffold ETH with the innovative Minimal Anti-Collusion Infrastructure (MACI), this template offers a robust foundation for creating secure and transparent voting systems on the Ethereum blockchain.
- Voter Registration: Secure registration process through the MACI contract, enabling eligible voting.
- Poll Management: Admins can easily create and manage polls, including question and options setup.
- Secure Voting: Leverage MACI's privacy-preserving technology to ensure votes are cast anonymously and securely.
- Results Display: Transparent display of poll results after the voting phase concludes.
- Admin Dashboard: Comprehensive admin interface for poll oversight, including current status and results analytics.
Ensure you have the following tools installed before you proceed:
- Node (>= v18.17)
- Yarn (v1 or v2+)
- Git
Jumpstart your development with these simple steps:
- Clone and Set Up the Project
git clone https://github.com/yashgo0018/maci-wrapper.git
cd maci-wrapper
yarn install
- Download the zkeys for the maci circuits
In your first terminal window, run:
yarn download-zkeys
- Update the environment variables
Copy the env example files to env files
cp packages/hardhat/.env.example packages/hardhat/.env
cp packages/nextjs/.env.example packages/nextjs/.env.local
Update the values of the env variables in these new .env files
- Start a Local Ethereum Network
In your first terminal window, run:
yarn chain
This initiates a local Ethereum network via Hardhat for development and testing purposes. Adjust the network settings in hardhat.config.ts
as needed.
- Deploy Contracts
In a second terminal, deploy your test contract with:
yarn deploy
Find the contract in packages/hardhat/contracts
. This script deploys your contract to the local network, with customization available in packages/hardhat/deploy
.
- Launch the NextJS Application
In a third terminal, start the NextJS frontend:
yarn start
- Compute Results
- Update
packages/hardhat/deploy-config.json
file, select the network, and in thePoll
object, updatecoordinatorPubkey
to the coordinator public key in thepackages/hardhat/coordinatorKeyPair.json
, and updateuseQuadraticVoting
if you want to compute results for a non quadratic vote. - Merge the poll, using
yarn hardhat merge --poll {poll id}
- Generate proof, using
yarn hardhat prove --poll {poll id} --output-dir {proof ouput dir} --coordinator-private-key {coordinator private key} --tally-file {tally output file}
Navigate to http://localhost:3000
to interact with your dApp. Modify your app configuration in packages/nextjs/scaffold.config.ts
and packages/hardhat/constants.ts
as necessary.
The deployed contracts will be saved to the file packages/hardhat/contractAddresses.json
, this file is compatible with maci cli.
The coordinator keys will be stored in the file packages/hardhat/coordinatorKeyPair.json
.
After setting up the project, you can:
- Register: Use the app's interface to register with the MACI contract and gain voting rights.
- Create Polls: As an admin, you can create polls with custom questions and options.
- Vote: Registered voters can participate in polls, utilizing MACI's secure voting mechanism.
- View Results: Access poll outcomes after the voting phase ends.
- Admin Dashboard: Monitor and manage ongoing polls, including viewing detailed poll status.
Your contributions are welcome! Feel free to report issues, submit fixes, or suggest new features to enhance the project.
This project is licensed under the MIT License.