Thanks to visit codestin.com
Credit goes to Github.com

Skip to content

krsmer/dao_alchemy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

4 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

DAO Application

Decentralized Autonomous Organization (DAO) application - Users can connect wallets, create polls, and vote.

๐ŸŽฏ Features

  • โœ… MetaMask wallet connection
  • โœ… Poll/Proposal creation
  • โœ… Voting on proposals
  • โœ… Transparent recording on blockchain
  • โœ… 7-day voting period

๐Ÿ› ๏ธ Technology Stack

  • 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)

๐Ÿ“ Project Structure

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

๐Ÿš€ Installation

1. Install Dependencies

In the root directory:

npm install

For the frontend:

cd frontend
npm install
cd ..

2. Configure Environment Variables

Copy .env.example to .env:

cp .env.example .env

Edit 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 .env file to git!

3. Compile the Smart Contract

npm run compile

4. Run Tests

npm test

5. Deploy the Smart Contract

Deploy to local Hardhat network:

npx hardhat node  # In one terminal window
npm run deploy    # In another terminal window

Deploy to Sepolia testnet:

npm run deploy -- --network sepolia

Note the deployed contract address!

6. Frontend Configuration

Copy frontend/.env.local.example to frontend/.env.local:

cd frontend
cp .env.local.example . env.local

Add the deployed contract address:

NEXT_PUBLIC_CONTRACT_ADDRESS=0xYourContractAddress

7. Start the Frontend

cd frontend
npm run dev

The application will run at http://localhost:3000.

๐ŸŽฎ Usage

  1. MetaMask Setup

  2. Connect Wallet

    • Open the application
    • Click the "Connect Wallet" button
    • Approve in MetaMask
  3. Create Proposal

    • Go to "Create New Proposal" section
    • Write a description
    • Confirm the transaction
  4. Vote

    • View active proposals
    • Click on the proposal you want to vote on
    • Confirm the transaction

๐Ÿ“ Smart Contract Functions

createProposal(string description)

Creates a new proposal.

  • Parameters: Proposal description
  • Returns: Proposal ID

vote(uint256 proposalId)

Votes on a proposal.

  • Parameters: Proposal ID
  • Constraints: Each address can only vote once

getProposal(uint256 proposalId)

Retrieves proposal details.

  • Returns: ID, description, vote count, deadline, status, creator

hasVoted(uint256 proposalId, address voter)

Checks if an address has voted.

๐Ÿงช Testing

Run all tests:

npm test

Run a specific test file:

npx hardhat test test/DAO.test.js

View test coverage:

npx hardhat coverage

๐Ÿ”’ Security

  • Never share your private keys
  • Don't add the .env file to git
  • Perform comprehensive tests before deploying to mainnet
  • Have the smart contract professionally audited

๐Ÿ›ฃ๏ธ Roadmap

  • Token-based voting system
  • Proposal execution mechanism
  • Multi-choice voting
  • Delegation system
  • Time-locked tokens
  • Proposal details with IPFS
  • Mobile responsive design improvements

๐Ÿ“„ License

MIT License

๐Ÿค Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push your branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

๐Ÿ“ž Contact

You can open an issue for your questions.

๐Ÿ™ Acknowledgments

  • Alchemy University
  • Hardhat Team
  • OpenZeppelin
  • Ethereum Community

About

alchemy final project

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published