Skip to content

pragmaxim/famvote

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🗳️ FamilyVote DApp

A lightweight decentralized voting app for family decisions, built with Foundry, Solidity, and a minimal React frontend.

Family Vote Screenshot

✨ Features

🔐 Smart Contract (Solidity)

  • Create a poll with:
    • Question
    • Choices (e.g., Pizza, Pasta)
    • Whitelisted voter addresses
    • Voting deadline (in seconds)
  • Only allowed voters can vote
  • Each voter can vote once per poll
  • Anyone can read:
    • Current results
    • Past polls

🧪 Tests (Foundry)

  • Deploys the FamilyVote contract
  • Creates a test poll with 2 voters and 2 choices
  • Casts a vote and checks the results

🖥️ Frontend (React + Viem + Wagmi)

First version runs against Avil local node only for demo/dev

  • Connect your wallet (Metamask etc.)
  • Create a new poll
  • See active and past polls
  • Vote on active polls (if you're whitelisted)
  • View results and expiration time

🛠️ Installation

Prerequisites


🔧 Clone & Install

git clone https://github.com/pragmaxim/famvote.git
cd famvote
  1. Install dependencies:
cd frontend
npm install
  1. Start the development server:
npm run dev
  1. Open your browser and navigate to http://localhost:3000

Connecting to Anvil

  1. Start Anvil in a separate terminal:
anvil
  1. Import one of the Anvil private keys into Metamask:
  • Click on your account icon in Metamask
  • Select "Import Account"
  • Paste one of the private keys from the Anvil output
  • Click "Import"
  1. Connect Metamask to the Anvil network:
  1. Deploy the FamilyVote contract to Anvil:
# From the project root (not the frontend directory)
# Replace <PRIVATE_KEY> with one of the private keys from the Anvil output
# For example: 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
forge create src/FamilyVote.sol:FamilyVote --private-key <PRIVATE_KEY> --broadcast
  1. After successful deployment, you'll see output similar to:
Deployer: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266
Deployed to: 0x5FbDB2315678afecb367f032d93F642f64180aa3
Transaction hash: 0x...
  1. Update the CONTRACT_ADDRESS in frontend/src/hooks/useContract.js with the deployed contract address:
// Change this line
const CONTRACT_ADDRESS = '0x5FbDB2315678afecb367f032d93F642f64180aa3';

Building for Production

npm run build

The build output will be in the dist directory.

About

Playground for teaching kids coding dapps

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors