Awesome
As of Jan. 15, 2024, this repo is archived. The underlying codebase for how to make a DAO has greatly changed due to the changing nature of many of the packages this codebase used, and I don't have time to continue to maintain it.
DAO Template
This has been updated to work with Sepolia over Goerli
<div id="top"></div>You can also see the python/brownie version of this here.
<!-- ABOUT THE PROJECT -->About
How to DAO
This repo is meant to give you all the knowledge you need to start a DAO and do governance. Since what's the point of a DAO if you can't make any decisions! There are 2 main kinds of doing governance.
Feature | On-Chain Governance | Hybrid Governance |
---|---|---|
Gas Costs | More Expensive | Cheaper |
Components | Just the blockchain | An oracle or trusted multisig |
A typical on-chain governance structure might look like:
- ERC20 based voting happens on a project like Tally, but could hypothetically be done by users manually calling the vote functions.
- Anyone can execute a proposal once it has passed Examples Compound
On-chain governance can be much more expensive, but involves fewer parts, and the tooling is still being developed.
A typical hybrid governance with an oracle might look like:
- ERC20 based voting happens on a project like Snapshot
- An oracle like Chainlink is used to retreive and execute the answers in a decentralized manner. (hint hint, someone should build this. )
A typical hybrid governance with a trusted multisig might looks like:
- ERC20 based voting happens on a project like Snapshot
- A trusted gnosis multisig is used to exectue the results of snapshot. Examples: Snapsafe
Hybrid governance is much cheaper, just as secure, but the tooling is still being developed.
Tools:
- Snapshot
- UI for off-chain voting / sentiment analysis
- Tally
- UI for on-chain voting
- Gnosis Safe
- Multi-sig
- Openzeppelin
- DAO code tools
- Zodiac
- More DAO code tools
- Openzeppelin Defender
- A tool to propose governance and other contract functions.
No Code Tools
The following have tools to help you start a DAO without having to deploy contracts yourself.
- DAO Stack
- Aragon
- lol, just kidding. Here is the real link.
- Colony
- DAOHaus
- DAO Leaderboard
Getting Started
Work with this repo in the browser (optional)<br/>
It's recommended that you've gone through the hardhat getting started documentation before proceeding here.
Requirements
- git
- You'll know you did it right if you can run
git --version
and you see a response likegit version x.x.x
- You'll know you did it right if you can run
- Nodejs
- You'll know you've installed nodejs right if you can run:
node --version
and get an ouput like:vx.x.x
- You'll know you've installed nodejs right if you can run:
- Yarn instead of
npm
- You'll know you've installed yarn right if you can run:
yarn --version
And get an output like:x.x.x
- You might need to install it with npm
- You'll know you've installed yarn right if you can run:
Installation
- Clone this repo:
git clone https://github.com/PatrickAlphaC/dao-template
cd dao-template
- Install dependencies
yarn
or
npm i
- Run the test suite (which also has all the functionality)
yarn hardhat test
or
npx hardhat test
If you want to deploy to a testnet:
4. Add a .env
file with the same contents of .env.example
, but replaced with your variables.
WARNING
<!-- USAGE EXAMPLES -->DO NOT PUSH YOUR PRIVATE_KEY TO GITHUB
Usage
On-Chain Governance Example
Here is the rundown of what the test suite does.
- We will deploy an ERC20 token that we will use to govern our DAO.
- We will deploy a Timelock contract that we will use to give a buffer between executing proposals.
- Note: The timelock is the contract that will handle all the money, ownerships, etc
- We will deploy our Governence contract
- Note: The Governance contract is in charge of proposals and such, but the Timelock executes!
- We will deploy a simple Box contract, which will be owned by our governance process! (aka, our timelock contract).
- We will propose a new value to be added to our Box contract.
- We will then vote on that proposal.
- We will then queue the proposal to be executed.
- Then, we will execute it!
Additionally, you can do it all manually on your own local network like so:
- Setup local blockchain
yarn hardhat node
- Propose a new value to be added to our Box contract
In a second terminal (leave your blockchain running)
yarn hardhat run scripts/propose.ts --network localhost
- Vote on that proposal
yarn hardhat run scripts/vote.ts --network localhost
- Queue & Execute proposal!
yarn hardhat run scripts/queue-and-execute.ts --network localhost
You can also use the Openzeppelin contract wizard to get other contracts to work with variations of this governance contract.
Off-Chain governance Example
This sectoin is still being developed.
Deploy your ERC20 and make proposals in snapshot.
<p align="right">(<a href="#top">back to top</a>)</p> <!-- ROADMAP -->Roadmap
- [] Add Upgradeability examples with the UUPS proxy pattern
- [] Add Chainlink Oracle Integration with Snapsafe example
See the open issues for a full list of proposed features (and known issues).
<p align="right">(<a href="#top">back to top</a>)</p> <!-- CONTRIBUTING -->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!
- 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
License
Distributed under the MIT License. See LICENSE.txt
for more information.
Contact
Hardhat - @HardhatHQ Patrick Collins - @patrickalphac
<p align="right">(<a href="#top">back to top</a>)</p> <!-- ACKNOWLEDGMENTS -->Acknowledgments
- Openzeppelin Governance Walkthrough
- Openzeppelin Governance Github
- Vitalik on DAOs
- Vitalik on On-Chain Governance
- Vitalik on Governance in General
You can check out the openzeppelin javascript tests for a full suite of an example of what is possible.