A secure, decentralized e-voting system built on Ethereum. Features admin-controlled elections, voter registration, encrypted vote storage on IPFS, and MetaMask wallet integration.
Choose your setup:
- π Local Development: Test on Ganache (local blockchain) - perfect for learning and development
- π Production Deployment: Deploy on Ethereum testnets/mainnet - ready for real-world use
- Frontend: https://voting-frontend-x6so.onrender.com/
- Backend API: https://blockchain-e-voting.onrender.com
- Smart Contract:
0xD08Bbdcb80496e4d53a0Ae769b535306Bb513716(Sepolia) - Network: Ethereum Sepolia Testnet
- Explorer: https://sepolia.etherscan.io/address/0xD08Bbdcb80496e4d53a0Ae769b535306Bb513716
MetaMask wallet integration for secure voter authentication
Clean, intuitive interface for casting votes on blockchain
Comprehensive admin controls for managing elections, candidates, and voters
Blockchain transaction confirmation with IPFS hash for vote verification
Deployed smart contract on Sepolia Etherscan showing verified transactions
contracts/- Solidity smart contractElection.solbackend/- Express.js API server with IPFS integration (Pinata)frontend/- React + Vite UI with MetaMask wallet connectionmigrations/- Contract deployment scriptsbuild/- Compiled contract artifacts and ABIs
- π Secure Voting: Votes stored encrypted on IPFS, hash on blockchain
- π€ Admin Controls: Add candidates, register voters, set voting periods
- π One Vote Per Person: Smart contract enforces single vote per address
- π Transparent Results: Real-time vote tallying on blockchain
- π MetaMask Integration: Web3 wallet authentication
- β° Timed Elections: Set start/end times for voting periods
- π‘οΈ Emergency Pause: Admin can pause contract in emergencies
Perfect for testing and development without spending real ETH.
Prerequisites:
Setup:
# 1. Clone repository
git clone https://github.com/mclovin22117/Blockchain-e-voting.git
cd Blockchain-e-voting
# 2. Install dependencies
npm install
cd backend && npm install
cd ../frontend && npm install
cd ..
# 3. Start Ganache
./start-ganache.sh
# Or open Ganache GUI on port 7545
# 4. Deploy smart contract locally
npx truffle migrate --reset --network development
#use --reset only when you make major changes and want to reset the session
# Note the deployed contract address
# 5. Configure environment variables
cp backend/.env.example backend/.env
cp frontend/.env.example frontend/.env
# Edit backend/.env:
# - Add your Pinata JWT token
# - Set CONTRACT_ADDRESS from step 4
# - Set FRONTEND_URL=http://localhost:5173
# Edit frontend/.env:
# - VITE_BACKEND_URL=http://localhost:3001
# - VITE_RPC_URL=http://127.0.0.1:7545
# - VITE_CONTRACT_ADDRESS=(from step 4)
# - VITE_CHAIN_ID=1337
# 6. Start backend
cd backend && npm start
# 7. Start frontend (new terminal)
cd frontend && npm startConfigure MetaMask for Local:
- Networks β Add Network β Add Manually
- Network Name:
Ganache Local - RPC URL:
http://127.0.0.1:7545 - Chain ID:
1337 - Currency:
ETH - Import Ganache account (see
GANACHE_ACCOUNTS.mdfor private keys)
Visit http://localhost:5173 - you're ready to vote locally! π
Deploy your own instance to Ethereum network.
Prerequisites:
- MetaMask with testnet ETH (or mainnet ETH for production)
- Render account (FREE tier available)
- Pinata account
Quick Deploy:
See detailed guides:
- π DEPLOY_WITH_REMIX.md - Step-by-step deployment
- π QUICK_START.md - Fast reference guide
Summary:
- Deploy contract on Remix IDE to Sepolia/Mainnet
- Deploy backend to Render (connect GitHub repo, set env vars)
- Deploy frontend to Render (static site, set env vars)
- Update CORS between frontend/backend
Get Testnet ETH:
- Sepolia: https://cloud.google.com/application/web3/faucet/ethereum/sepolia
- Or use other faucets from https://faucetlink.to/sepolia
This project uses environment variables for configuration. The .env.example files show all required variables.
# Required for both local and production
PINATA_JWT=your_jwt_token_from_pinata
CONTRACT_ADDRESS=0xYourContractAddress
NODE_ENV=development # or production
PORT=3001
# CORS Configuration
FRONTEND_URL=http://localhost:5173 # Local
# FRONTEND_URL=https://your-frontend.onrender.com # Production# Local Development (Ganache)
VITE_BACKEND_URL=http://localhost:3001
VITE_RPC_URL=http://127.0.0.1:7545
VITE_CONTRACT_ADDRESS=0xYourLocalContractAddress
VITE_CHAIN_ID=1337
VITE_CHAIN_NAME=Ganache Local
# Production (Sepolia Example)
# VITE_BACKEND_URL=https://your-backend.onrender.com
# VITE_RPC_URL=https://ethereum-sepolia-rpc.publicnode.com
# VITE_CONTRACT_ADDRESS=0xYourSepoliaContractAddress
# VITE_CHAIN_ID=11155111
# VITE_CHAIN_NAME=Sepolia TestnetImportant: Never commit actual .env files! They're gitignored for security.
- Connect MetaMask with the wallet that deployed the contract
- Access admin panel (automatically appears for owner)
- Add Candidates: Enter candidate names
- Register Voters: Add voter wallet addresses (one per line)
- Set Voting Period: Choose start/end times (Unix timestamps)
- Monitor Results: Real-time vote counts displayed
- Get Registered: Admin must add your wallet address
- Connect Wallet: Click "Connect Wallet" and approve MetaMask
- Login: System verifies you're registered
- Cast Vote: Select candidate and confirm transaction
- View Receipt: Get IPFS hash of encrypted vote for verification
Blockchain-e-voting/
βββ contracts/ # Solidity smart contracts
β βββ Election.sol # Main voting contract
β βββ Migrations.sol # Truffle migrations
βββ backend/ # Express.js API server
β βββ index.js # Server + IPFS integration
β βββ ipfs.js # Pinata IPFS functions
β βββ .env.example # Environment template
βββ frontend/ # React + Vite UI
β βββ src/
β β βββ App.jsx # Main component
β β βββ config.js # Web3 configuration
β β βββ components/ # UI components
β βββ .env.example # Environment template
βββ migrations/ # Truffle deployment scripts
βββ build/ # Compiled contract artifacts
βββ Election.abi.json # Contract ABI (for reference)
βββ *.md # Documentation files
- QUICK_START.md - Fast setup reference (local + production)
- DEPLOY_WITH_REMIX.md - Deploy contract with Remix IDE
- DEVELOPMENT_WORKFLOW.md - Local development guide
- IPFS_SETUP.md - IPFS/Pinata configuration
- GANACHE_ACCOUNTS.md - Test account private keys
- SMART_CONTRACT_FLOWCHART.md - Contract architecture diagrams
- TOOLS_TECHNOLOGIES.md - Complete tech stack reference
- β OpenZeppelin contracts (Pausable, ReentrancyGuard)
- β Voting periods with emergency pause
- β Rate limiting (100 req/15min per IP)
- β Input validation (Joi schemas)
- β Helmet.js security headers
- β CORS whitelist
- β Address validation (prevent addresses as candidate names)
- β One vote per address enforced on-chain
Production Contract (Sepolia Testnet):
- Address:
0xD08Bbdcb80496e4d53a0Ae769b535306Bb513716 - Network: Ethereum Sepolia Testnet
- Compiler: Solidity ^0.8.20
- Etherscan: https://sepolia.etherscan.io/address/0xD08Bbdcb80496e4d53a0Ae769b535306Bb513716
Local Development:
- Deploy your own contract on Ganache using
npx truffle migrate --reset --network development - Use the deployed address in your local
.envfiles
Local Testing:
# Start Ganache
./start-ganache.sh
# Deploy contract
npx truffle migrate --reset --network development
# Run application
npm run start:allProduction Testing:
- Visit live demo: https://voting-frontend-x6so.onrender.com/
- Connect MetaMask to Sepolia
- Get test ETH from faucet
- Test the voting flow
- Ethereum - Decentralized blockchain platform
- Solidity ^0.8.20 - Smart contract language
- OpenZeppelin - Secure contract libraries (Pausable, ReentrancyGuard)
- Truffle - Development framework (local only)
- Ganache - Local blockchain for testing
- Node.js - JavaScript runtime
- Express.js - Web server framework
- Pinata - IPFS pinning service
- Joi - Input validation
- Helmet.js - Security headers
- express-rate-limit - Rate limiting
- React 18 - UI library
- Vite - Build tool
- ethers.js - Ethereum library
- MetaMask - Web3 wallet
- Remix IDE - Contract deployment
- Render - Application hosting (free tier)
Contributions are welcome! Whether you're fixing bugs, improving documentation, or adding new features.
How to contribute:
- Fork the repository
- Create feature branch (
git checkout -b feature/AmazingFeature) - Make your changes
- Test locally on Ganache
- Commit changes (
git commit -m 'Add AmazingFeature') - Push to branch (
git push origin feature/AmazingFeature) - Open Pull Request
Guidelines:
- Follow existing code style
- Test changes thoroughly
- Update documentation as needed
- Keep commits atomic and descriptive
This project is for educational and research purposes. Use at your own risk.
- Testnet vs Mainnet: This demo runs on Sepolia testnet. For production mainnet:
- Conduct thorough security audits
- Comprehensive testing
- Gas optimization
- Professional security review
- Free Tier Limitations: Render free tier has cold starts (30-60s wake time)
- Security: Never share private keys, seed phrases, or API tokens
- Environment Variables: Always use
.envfiles (never commit them!)
- OpenZeppelin - Secure smart contract libraries
- Pinata - IPFS storage infrastructure
- Render - Free hosting services
- MetaMask - Web3 wallet integration
- Ethereum Foundation - Blockchain platform
- Issues: https://github.com/mclovin22117/Blockchain-e-voting/issues
- Discussions: https://github.com/mclovin22117/Blockchain-e-voting/discussions
This project is licensed under the MIT License - see the LICENSE file for details.
Made with β€οΈ for transparent and secure voting