Skip to content

vitordhers/food_voter

Repository files navigation

Food voter app

This app aims to solve food controversial topics by allowing users to create voting ballots regarding controversial topics on food. Each ballot has title and description, setting ground for a topic that can be either accepted or rejected. For instance, "Does 🍍 pineapple belong in 🍕 pizza?". Users can create as many ballots as they wish (assuming they have the funds to do so), but only one vote is allowed to be cast per user. Votes can be either "accept" or "reject". After 7 days, the ballot is closed, and we have final results.

Before running

  1. Make sure to have MetaMask Wallet extension installed in your browser.

Test Setup

  1. In your browser, make sure to select Polygon Amoy Testnet in your MetaMask wallet, by clicking at MetaMask icon, then click at the top left to chose network, and insert:

Name: Polygon Amoy Testnet New RPC URL: https://rpc-amoy.polygon.technology/ Chain ID: 80002 Currency symbol: MATIC Block Explorer URL: https://amoy.polygonscan.com/ then save.

  1. In order to create ballots and cast votes, make sure to have funds in your wallet. Funds can be easily and freely obtrained via this faucet. Make sure, in that page, to select Polygon PoS (Amoy) network, and to provide your wallet correct address in Wallet Address field.

Running test

  1. Go to the root folder and run:
$ npm run prod
  1. Connect to the App.

  2. Connect your MetaMask wallet in order to create ballots and cast votes.

Local Setup

  1. Install Foundry Suite and NodeJs.
  2. Change directory to ```forge`` directory and start local Anvil node (keep this terminal running);
$ cd forge;
$ anvil

Store any private key provided by Anvil.

Running locally

  1. In another terminal, but same folder, add a .env file according to .env_template, and set the stored private key.

  2. In the same folder, in order to deploy BallotsManager contract via:

$ forge script TestDeployBallotsManagerScript --rpc-url http://127.0.0.1:8545  --broadcast;

Store deployed contract address.

  1. Now, back to root directory, create a .env.development file following .env_template template, providing as an env var the address from contract deployed in step above.

  2. Start a local instance of React by running npm run local. Don't forget to run npm install to install dependencies.

  3. In app tab, connect to Local RPC Anvil node using Metamask, by clicking at Metamask icon, then click at the top left to chose network, and insert:

Name: Anvil local node New RPC URL: http://127.0.0.1:8545 Chain ID: 31337 Currency symbol: GO

then save.

  1. Connect to the App and start creating ballots and casting votes.

  2. Connect your MetaMask wallet in order to create ballots and cast votes.

Running tests suite

  1. At forge directory, simply run
$ forge test 

To be Implemented

  • Pagination for User's Contracts;
  • Verification when a new Ballot is created;
  • Callback for updating Ballot State when Ballot finishes.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published