Skip to content

milosdjurica/DAO-humanitarian-funding

Repository files navigation

Contributors Forks Stargazers Issues MIT License LinkedIn


Humanitarian DAO

Decentralized Autonomous Organization (DAO) with a goal to donate to individuals who lack the financial resources for medical treatment. Everyone deserves an equal chance, but unfortunately, that is not always the case. This DAO aims to address this issue by providing help to those in need.
Explore the docs »

View Funding Contract · Report Bug · Request Feature

Table of Contents

  1. About The Project
  2. Getting Started
  3. Usage
  4. Improvements
  5. Contributing
  6. License
  7. Contact

About The Project

Project implements a decentralized governance system with smart contracts deployed and verified on Sepolia Testnet. This DAO is created to provide financial help to individuals who lack resources for a medical treatment. Token holders (voters) can vote to add new voters, add new users that need help and adjust amount that those users need.

Contracts are deployed and verified on Sepolia Testnet:

(back to top)

Tools Used

(back to top)

Technical Overview

Contracts:

  1. Funding Contract:

    • This contract holds funds and list of users that needs funding.
    • DAO can add new users and update amount of funds that existing users need.
    • Winner is picked automatically with Chainlink Automation, using Chainlink VRF in order to pick random winner.
  2. VotingToken Contract:

    • This contract extends ERC20 functionality and integrates voting capabilities. Token holders use this token to vote on governance proposals.
    • Contract is owned by TimeLock. Only TimeLock contract can mint new tokens (add new voters to DAO).
  3. MyGovernor Contract:

    • A governance contract from the OpenZeppelin Contracts library.
    • It enables token holders to vote on proposals, managing the governance process.
  4. TimeLock Contract:

    • A time-lock mechanism built using OpenZeppelin's TimelockController.
    • It acts as the OWNER of the Funding and VotingToken contracts and executes proposals passed by the MyGovernor contract.

(back to top)

Dependencies

  1. OpenZeppelin Contracts:
    • Integrated for secure and audited smart contracts for DAO management.
  2. Chainlink VRF:
    • Integrated for randomness generation for picking the winner.
  3. Chainlink Automation:
    • Integrated for automatically picking the winner and funding them.

(back to top)

Coverage

Tests ->

  • Total number of 54 tests
  • Unit tests
  • Integration tests
  • Fuzz tests

Coverage % ->

  • Lines -> 97.83% (90/92)
  • Statements -> 95.16% (118/124)
  • Branches -> 92.86% (26/28)
  • Functions -> 84.85% (28/33)

Coverage image

(back to top)

Disclaimer

Although code coverage is very high, this code has not been audited by professionals, so it is NOT SAFE FOR PRODUCTION. Milos Djurica holds NO responsibility for the provided code. This is just a personal project created for learning purposes only. It aims to one day provide a solution to the world's existing problem, but it should be audited by professionals first.

(back to top)

Getting Started

Prerequisites

  1. Git
  2. Foundry -> Installation guide
  3. Get a free API Key for RPC requests at Alchemy. For fork testing and deploying
  4. Get a free API Key for verifying contracts at Etherscan

(back to top)

Installation

  1. Clone the repo
 git clone https://github.com/milosdjurica/DAO-funding-foundry.git
  1. Install dependencies
forge build

(back to top)

Testing

  1. Run tests
forge test
  1. Run only Unit tests
forge test --mc Unit
  1. Run only Fuzz tests
forge test --mc Fuzz
  1. Run tests with more details (logs) -> Foundry Docs
forge test -vvv
  1. See coverage
forge coverage

(back to top)

Deploying

  1. Get a free API Key for RPC requests at Alchemy

  2. Get a free API Key for verifying contracts at Etherscan

  3. Fill out your .env variables

    SEPOLIA_RPC_URL = "ENTER YOUR SEPOLIA API KEY";
    PRIVATE_KEY = "YOUR PRIVATE KEY";
    ETHERSCAN_API_KEY = "ENTER YOUR ETHERSCAN API KEY TO VERIFY CONTRACTS";
  4. Load your .env variables in terminal

    source .env
    
  5. Deploy and verify contracts

    forge script script/DeployAndSetUpContracts.s.sol:DeployAndSetUpContracts --rpc-url $SEPOLIA_RPC_URL --private-key $PRIVATE_KEY --broadcast --etherscan-api-key $ETHERSCAN_API_KEY --verify
    
  6. Register Chainlink Automation at -> https://automation.chain.link/

  7. Register Chainlink at -> https://vrf.chain.link/

(back to top)

Usage

To interact with the governance system, users can:

  • Vote on proposals using VotingToken.
  • Propose changes or actions through the MyGovernor contract.
  • Monitor the funding distribution process through the Funding contract.
  • TimeLock is owner of VotingToken and Funding contracts. After proposal has passed, TimeLock contract is the one that executes those proposals.

Examples

Write an example here:

  1. Giving voting power to new user:

    1. Someone proposes new user to be added as a voter
    2. Voters vote on proposal on MyGovernor contract
    3. If proposal has passed, TimeLock contracts executes it and mints VotingTokens to the new user.
  2. Adding new user to be funded:

    1. Someone proposes new user to be funded
    2. Voters vote on proposal on MyGovernor contract
    3. If proposal has passed, TimeLock contracts executes it and adds new user to array of users that need help in Funding contract.
    4. After required time has passed, Chainlink Automation and Chainlink VRF automatically and randomly pick a winner that gets the funds that are held by Funding smart contract

(back to top)

Improvements

Limitations

  • Chain limitation - because of VRF and Automation
  • Works only with VRF subscription 2.0 version

Known Issues

  • Malicious voters

Features

  • Add support for ERC20 tokens, not just native ETH currency

See the open issues for a full list of proposed features (and known issues).

(back to top)

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

License

Distributed under the MIT License. See LICENSE for more information.

(back to top)

Contact

Milos Djurica - linkedin.com/in/milosdjurica - [email protected]

Project Link: https://github.com/milosdjurica/DAO-funding-foundry

(back to top)

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published