Decentralized Autonomous Organization (DAO) application - Users can connect wallets, create polls, and vote.
- โ MetaMask wallet connection
- โ Poll/Proposal creation
- โ Voting on proposals
- โ Transparent recording on blockchain
- โ 7-day voting period
- Frontend: Next. js 14 + TypeScript + React 18
- Smart Contracts: Solidity 0.8.20
- Development Framework: Hardhat
- Web3 Library: ethers.js v6
- Blockchain: Ethereum (Sepolia Testnet)
alchemy_finalproject/
โโโ contracts/ # Solidity smart contracts
โ โโโ DAO. sol # Main DAO contract
โโโ scripts/ # Deployment scripts
โ โโโ deploy. js # Contract deployment
โโโ test/ # Smart contract tests
โ โโโ DAO.test.js # DAO tests
โโโ frontend/ # Next. js application
โ โโโ src/
โ โ โโโ app/ # Next.js App Router
โ โ โโโ components/# React components
โ โโโ public/ # Static files
โโโ hardhat.config. js # Hardhat configuration
โโโ package.json # Project dependencies
In the root directory:
npm installFor the frontend:
cd frontend
npm install
cd ..Copy .env.example to .env:
cp .env.example .envEdit the .env file:
SEPOLIA_RPC_URL=https://eth-sepolia.g.alchemy.com/v2/YOUR-API-KEY
PRIVATE_KEY=your-private-key-here
โ ๏ธ Warning: Never commit the.envfile to git!
npm run compilenpm testDeploy to local Hardhat network:
npx hardhat node # In one terminal window
npm run deploy # In another terminal windowDeploy to Sepolia testnet:
npm run deploy -- --network sepoliaNote the deployed contract address!
Copy frontend/.env.local.example to frontend/.env.local:
cd frontend
cp .env.local.example . env.localAdd the deployed contract address:
NEXT_PUBLIC_CONTRACT_ADDRESS=0xYourContractAddresscd frontend
npm run devThe application will run at http://localhost:3000.
-
MetaMask Setup
- Install the MetaMask browser extension
- Connect to Sepolia testnet
- Get test ETH: https://sepoliafaucet.com
-
Connect Wallet
- Open the application
- Click the "Connect Wallet" button
- Approve in MetaMask
-
Create Proposal
- Go to "Create New Proposal" section
- Write a description
- Confirm the transaction
-
Vote
- View active proposals
- Click on the proposal you want to vote on
- Confirm the transaction
Creates a new proposal.
- Parameters: Proposal description
- Returns: Proposal ID
Votes on a proposal.
- Parameters: Proposal ID
- Constraints: Each address can only vote once
Retrieves proposal details.
- Returns: ID, description, vote count, deadline, status, creator
Checks if an address has voted.
Run all tests:
npm testRun a specific test file:
npx hardhat test test/DAO.test.jsView test coverage:
npx hardhat coverage- Never share your private keys
- Don't add the
.envfile to git - Perform comprehensive tests before deploying to mainnet
- Have the smart contract professionally audited
- Token-based voting system
- Proposal execution mechanism
- Multi-choice voting
- Delegation system
- Time-locked tokens
- Proposal details with IPFS
- Mobile responsive design improvements
MIT License
- Fork it
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push your branch (
git push origin feature/amazing-feature) - Open a Pull Request
You can open an issue for your questions.
- Alchemy University
- Hardhat Team
- OpenZeppelin
- Ethereum Community