A production-ready decentralized autonomous organization (DAO) voting application built with Next.js and Solidity.
- Create Proposals: Submit governance proposals with custom voting durations
- Democratic Voting: Vote for or against proposals
- Proposal Execution: Execute passed proposals after voting period ends
- Real-time Updates: Live proposal updates using contract events
- Modern UI: Beautiful glassmorphic design with smooth animations
- Wallet Integration: Connect with MetaMask, Rainbow, and other popular wallets
- Solidity ^0.8.28
- Hardhat 2.22.17
- Ethers v6
- Next.js 15 (App Router)
- React 19
- TypeScript
- Wagmi v2 (Ethereum interactions)
- RainbowKit (Wallet connection)
- Shadcn UI (Component library)
- Tailwind CSS (Styling)
- Node.js 18+
- npm or yarn
- MetaMask or compatible Web3 wallet
- Clone the repository
cd dao-voting-dapp- Install contract dependencies
cd packages/contract
npm install- Install frontend dependencies
cd ../frontend
npm install- Start Hardhat local node (in terminal 1)
cd packages/contract
npx hardhat node- Deploy the contract (in terminal 2)
cd packages/contract
npx hardhat run scripts/deploy.js --network localhostNote the deployed contract address (should be 0x5FbDB2315678afecb367f032d93F642f64180aa3)
- Start the frontend (in terminal 3)
cd packages/frontend
npm run dev-
Open your browser Navigate to
http://localhost:3000 -
Connect your wallet
- Click "Connect Wallet" in the top right
- Select your wallet (MetaMask, Rainbow, etc.)
- Important: Switch to "Localhost 8545" network in MetaMask
- Import a test account from Hardhat (use private key from terminal 1)
Hardhat provides test accounts with 10,000 ETH each. Import these into MetaMask:
Account #0: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266
Private Key: 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
Account #1: 0x70997970C51812dc3A010C7d01b50e0d17dc79C8
Private Key: 0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d
The main contract implements:
createProposal(description, durationInMinutes): Create a new proposalvote(proposalId, support): Vote on a proposal (true = for, false = against)executeProposal(proposalId): Execute a passed proposalgetProposal(proposalId): Get proposal details
- Local Network:
0x5FbDB2315678afecb367f032d93F642f64180aa3 - Sepolia Testnet: Deploy using your own RPC URL
- Connect your wallet
- Fill in the "Create New Proposal" form
- Set a duration (in minutes)
- Click "Submit Proposal"
- Confirm the transaction
- Find an active proposal
- Click "Vote For" or "Vote Against"
- Confirm the transaction
- Watch the vote count update in real-time
- Wait for the voting period to end
- If proposal passed (more votes for than against)
- Click "Execute Proposal"
- Confirm the transaction
dao-voting-dapp/
├── packages/
│ ├── contract/ # Hardhat project
│ │ ├── contracts/ # Solidity contracts
│ │ ├── scripts/ # Deployment scripts
│ │ ├── test/ # Contract tests
│ │ └── hardhat.config.js
│ └── frontend/ # Next.js application
│ ├── app/ # Next.js app router
│ ├── components/ # React components
│ ├── lib/ # Utilities & contract config
│ └── public/ # Static assets
- Get Sepolia ETH from a faucet
- Update hardhat.config.js:
networks: {
sepolia: {
url: `https://sepolia.infura.io/v3/YOUR_INFURA_KEY`,
accounts: [process.env.PRIVATE_KEY]
}
}- Deploy:
npx hardhat run scripts/deploy.js --network sepolia- Update frontend contract address in
lib/contract.ts
- ✅ Production-ready contract code
- ✅ No reentrancy vulnerabilities
- ✅ Proper access control
- ✅ Event logging for transparency
⚠️ For testnet/demo purposes - conduct professional audit before mainnet
MIT
Pull requests welcome! Please ensure tests pass before submitting.
Built with ❤️ using Next.js, Hardhat, and RainbowKit






