I created this dao by coding along at How to build an on-chain DAO and adapted it for my needs.
The governor and voting can take place by an ERC20 or ERC721 token, depending on the config at helper-hardhat-config.ts
The settings of governorContractName
and governanceTokenContractName
define the contract name which will be deployed at /deploy/01-deploy-governor-token.ts
and /deploy/03-deploy-governor-contract.ts
.
Furthermore it defines with which contracts the tests in the folder /test/
interact.
Running with ERC721 config will mint an ERC721 token, delegate the voting power and voting with an ERC721 token. 1 Token = 1 Vote, 1 token max per wallet see the mint() functions
at /contracts/GovernanceTokenERC721.sol.
Configuration for voting with an ERC721 token at helper-hardhat-config.ts:
export const governorContractName = "GovernorERC721";
export const governanceTokenContractName = "GovernanceTokenERC721";
Running with ERC20 config will mint an ERC20 token, delegate the voting power and voting with an ERC20 token. 1 token max per wallet see the mint() functions
at /contracts/GovernanceTokenERC20.sol. /will be adapted/
Configuration for voting with an ERC20 token at helper-hardhat-config.ts:
export const governorContractName = "GovernorERC20";
export const governanceTokenContractName = "GovernanceTokenERC20";
The GovernorContract is configured by the openzeppeling wizzard and adapted to handover the voting delay and voting period with the constructor.
constructor(
IVotes _token,
TimelockController _timelock,
uint256 _votingDelay,
uint256 _votingPeriod,
uint256 _quorumPercentage
)
You can work with this repo in browser if you want with:
- 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:
- Clone this repo:
git clone https://github.com/MichiMich/BasicDao
cd Dao
- Install dependencies
yarn
or
npm i
- Add a
.env
file with the same contents of.env.example
, but replaced with your variables.
DO NOT PUSH YOUR PRIVATE_KEY TO GITHUB
Add your data at the .env file and add .env to the gitignore file. It is highly recommended to create and use a development wallet for this only, whithout mainnet tokens in it!
at helper-hardhat-config.ts - interact with NftCollection.sol
export const contractNameWhereActionTakesPlace = "NftCollection";
export const argsForFuncExecution = ["0xaf6344bc7bc538dcf7179c36fc57ccae302c1bbb", "OCAA"];
export const FUNC = "addCollection";
export const PROPOSAL_DESCRIPTION = "Proposal #1 add ocaa to nft collection";
This calls the addCollection
function of the contract NftCollection.sol
the contract address "0xaf6344bc7bc538dcf7179c36fc57ccae302c1bbb" and the name "OCAA" if
the proposal succeeds - Nftcollection.addCollection("0xaf6344bc7bc538dcf7179c36fc57ccae302c1bbb","OCAA")
at helper-hardhat-config.ts - interact with Box.sol
export const contractNameWhereActionTakesPlace = "Box";
export const argsForFuncExecution = [77];
export const FUNC = "store";
export const PROPOSAL_DESCRIPTION = "Proposal #1: Store 77 in the Box!";
This calls the store
function with the value 77
of the contract Box.sol
if the proposal succeeded - Box.store(77)
.
Run a full cycle of the dao on local network:
- Mint tokens, delegate vote
- propose
- vote on that proposal
- if proposal succeeded: queue- and execute the proposal
first terminal, run the local node with (deploys all contracts at /deploy/):
yarn hardhat node
second terminal, run the script:
yarn hardhat run scripts/runVoteCycle.ts --network localhost
or:
yarn hardhat test --network localhost --grep "mint tokens,propose, succeed vote, queue and execute"
If working on testnet or mainnet:
Remember on testnet the delays like VOTING_PERIOD and VOTING_DELAY need to pass (which are moved at local chain)