BasicDao

所属分类:NFT
开发工具:TypeScript
文件大小:356KB
下载次数:0
上传日期:2022-07-08 14:39:53
上 传 者sh-1993
说明:  基本的去中心化自治组织-智能合约、脚本、测试
(Basic decentralized autonomous organization - smart contracts, scripts, tests)

文件列表:
.env.example (245, 2022-07-08)
contracts (0, 2022-07-08)
contracts\Box.sol (563, 2022-07-08)
contracts\GovernanceTokenERC20.sol (1410, 2022-07-08)
contracts\GovernanceTokenERC721.sol (1858, 2022-07-08)
contracts\NftCollection.sol (1265, 2022-07-08)
contracts\governance_standard (0, 2022-07-08)
contracts\governance_standard\GovernorERC20.sol (3667, 2022-07-08)
contracts\governance_standard\GovernorERC721.sol (3542, 2022-07-08)
contracts\governance_standard\TimeLock.sol (658, 2022-07-08)
deploy (0, 2022-07-08)
deploy\01-deploy-governance-token.ts (1744, 2022-07-08)
deploy\02-deploy-time-lock.ts (1197, 2022-07-08)
deploy\03-deploy-governor-contract.ts (2183, 2022-07-08)
deploy\04-setup-governance-contracts.ts (1683, 2022-07-08)
deploy\05-deploy-execution-contract.ts (1740, 2022-07-08)
deployed-contract-data (0, 2022-07-08)
deployed-contract-data\info.txt (0, 2022-07-08)
deployed-contract-data\selfwritten.txt (178, 2022-07-08)
hardhat.config.ts (2167, 2022-07-08)
helper-hardhat-config.ts (2406, 2022-07-08)
helpfulScript.ts (1696, 2022-07-08)
package-lock.json (1126479, 2022-07-08)
package.json (832, 2022-07-08)
proposals.json (125, 2022-07-08)
scripts (0, 2022-07-08)
scripts\contractActions (0, 2022-07-08)
scripts\contractActions\executeProposalId.ts (779, 2022-07-08)
scripts\contractActions\mintAndDelegate.ts (1076, 2022-07-08)
scripts\contractActions\propose.ts (854, 2022-07-08)
scripts\contractActions\queue.ts (376, 2022-07-08)
scripts\contractActions\queueProposalId.ts (775, 2022-07-08)
scripts\contractActions\vote.ts (667, 2022-07-08)
scripts\createProposal.ts (0, 2022-07-08)
scripts\daoFunctions.ts (12276, 2022-07-08)
scripts\deploy-governor-token.ts (1042, 2022-07-08)
... ...

# BasicDao I created this dao by coding along at [How to build an on-chain DAO](https://www.youtube.com/watch?v=AhJtmUqhAqg&t=1668s) and adapted it for my needs. - [Configuration](#configuration) - [ERC721](#erc721) - [ERC20](#erc20) - [Governor contract](#governor) - [Getting Started](#getting-started) - [Requirements](#requirements) - [Installation](#installation) - [Execution after proposal](#execution) - [configuration 1 - Box.sol](#config1) - [configuration 2 - NftCollection.sol](#config2) - [Full DAO](#fulldaocycle) ## Configuration 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. ### ERC721 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"; ``` ### ERC20 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"; ``` ## Governor The GovernorContract is configured by the [openzeppeling wizzard](https://docs.openzeppelin.com/contracts/4.x/wizard) and adapted to handover the voting delay and voting period with the constructor. ``` constructor( IVotes _token, TimelockController _timelock, uint256 _votingDelay, uint256 _votingPeriod, uint256 _quorumPercentage ) ``` ## Getting started You can work with this repo in browser if you want with: [![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/MichiMich/BasicDao) ### Requirements - [git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) - You'll know you did it right if you can run `git --version` and you see a response like `git version x.x.x` - [Nodejs](https://nodejs.org/en/) - You'll know you've installed nodejs right if you can run: - `node --version`and get an ouput like: `vx.x.x` - [Yarn](https://classic.yarnpkg.com/lang/en/docs/install/) 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 ### Installation 1. Clone this repo: ``` git clone https://github.com/MichiMich/BasicDao cd Dao ``` 2. Install dependencies ``` yarn ``` or ``` npm i ``` 3. Add a `.env` file with the same contents of `.env.example`, but replaced with your variables. ![WARNING](https://via.placeholder.com/15/f03c15/000000?text=+)**WARNING** ![WARNING](https://via.placeholder.com/15/f03c15/000000?text=+) > 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! ## Execution ### config1 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")` ### config2 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)`. ## FullDaoCycle Run a full cycle of the dao on local network: 1. Mint tokens, delegate vote 2. propose 3. vote on that proposal 4. 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)**

近期下载者

相关文件


收藏者