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
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.
- Solidity v^0.8.20
- Foundry
- Chainlink Automation
- Chainlink Verified Random Number Generator v2.0
- Openzeppelin Governance v5.x
- Slither - Static analyzer
- Aderyn - Rust based static analyzer for Solidity
- Solidity-code-metrics - VSCode extension
-
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.
-
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
. OnlyTimeLock
contract can mint new tokens (add new voters to DAO).
-
MyGovernor
Contract:- A governance contract from the OpenZeppelin Contracts library.
- It enables token holders to vote on proposals, managing the governance process.
-
TimeLock
Contract:- A time-lock mechanism built using OpenZeppelin's
TimelockController
. - It acts as the OWNER of the
Funding
andVotingToken
contracts and executes proposals passed by theMyGovernor
contract.
- A time-lock mechanism built using OpenZeppelin's
-
OpenZeppelin Contracts:
- Integrated for secure and audited smart contracts for DAO management.
-
Chainlink VRF:
- Integrated for randomness generation for picking the winner.
-
Chainlink Automation:
- Integrated for automatically picking the winner and funding them.
- Total number of 54 tests
- Unit tests
- Integration tests
- Fuzz tests
- Lines -> 97.83% (90/92)
- Statements -> 95.16% (118/124)
- Branches -> 92.86% (26/28)
- Functions -> 84.85% (28/33)
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.
- Git
- Foundry -> Installation guide
- Get a free API Key for RPC requests at Alchemy. For fork testing and deploying
- Get a free API Key for verifying contracts at Etherscan
- Clone the repo
git clone https://github.com/milosdjurica/DAO-funding-foundry.git
- Install dependencies
forge build
- Run tests
forge test
- Run only Unit tests
forge test --mc Unit
- Run only Fuzz tests
forge test --mc Fuzz
- Run tests with more details (logs) -> Foundry Docs
forge test -vvv
- See coverage
forge coverage
-
Get a free API Key for RPC requests at Alchemy
-
Get a free API Key for verifying contracts at Etherscan
-
Fill out your
.env
variablesSEPOLIA_RPC_URL = "ENTER YOUR SEPOLIA API KEY"; PRIVATE_KEY = "YOUR PRIVATE KEY"; ETHERSCAN_API_KEY = "ENTER YOUR ETHERSCAN API KEY TO VERIFY CONTRACTS";
-
Load your .env variables in terminal
source .env
-
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
-
Register Chainlink Automation at -> https://automation.chain.link/
-
Register Chainlink at -> https://vrf.chain.link/
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 ofVotingToken
andFunding
contracts. After proposal has passed,TimeLock
contract is the one that executes those proposals.
-
Giving voting power to new user:
- Someone proposes new user to be added as a voter
- Voters vote on proposal on
MyGovernor
contract - If proposal has passed,
TimeLock
contracts executes it and mintsVotingToken
s to the new user.
-
Adding new user to be funded:
- Someone proposes new user to be funded
- Voters vote on proposal on
MyGovernor
contract - If proposal has passed,
TimeLock
contracts executes it and adds new user to array of users that need help inFunding
contract. - After required time has passed,
Chainlink Automation
andChainlink VRF
automatically and randomly pick a winner that gets the funds that are held byFunding
smart contract
- Chain limitation - because of VRF and Automation
- Works only with VRF subscription 2.0 version
- Malicious voters
- Add support for ERC20 tokens, not just native ETH currency
See the open issues for a full list of proposed features (and known issues).
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!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the MIT License. See LICENSE
for more information.
Milos Djurica - linkedin.com/in/milosdjurica - [email protected]
Project Link: https://github.com/milosdjurica/DAO-funding-foundry