Skip to content

yashgo0018/maci-wrapper

Repository files navigation

Scaffold ETH 2 + MACI Voting Template

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.

Features

  • 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.

Requirements

Ensure you have the following tools installed before you proceed:

Quickstart

Jumpstart your development with these simple steps:

  1. Clone and Set Up the Project
git clone https://github.com/yashgo0018/maci-wrapper.git
cd maci-wrapper
yarn install
  1. Download the zkeys for the maci circuits

In your first terminal window, run:

yarn download-zkeys
  1. 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

  1. 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.

  1. 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.

  1. Launch the NextJS Application

In a third terminal, start the NextJS frontend:

yarn start
  1. Compute Results
  • Update packages/hardhat/deploy-config.json file, select the network, and in the Poll object, update coordinatorPubkey to the coordinator public key in the packages/hardhat/coordinatorKeyPair.json, and update useQuadraticVoting 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.

Usage

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.

Contributing

Your contributions are welcome! Feel free to report issues, submit fixes, or suggest new features to enhance the project.

License

This project is licensed under the MIT License.

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •