Git Product home page Git Product logo

dao's Introduction

On-Chain DAO Governance

Tools

  1. Node.js : v16.18.0
  2. Yarn
  3. Hardhat
  4. Open Zeppelin
  5. Slither : requires Python > 3.8 & Microsoft Visual C++ > 14.0

Contracts:

  1. GovernanceToken : is an ERC20 token that gives you the power to votes on new proposals.

  2. TimeLock: gives us the time concepts explained below to execute proposals and to handle ownerships.

  3. GovernanceContract : is the contract in charge of proposals while Time Lock executes the proposal if approved.

  4. Box : owned by Time Lock contract, where the new proposal will be introduced to the Box contract, voting process will take place, we will queue the proposal to be executed if approved, then finally it will be executed.

Time Concepts:

  1. votingDelay : Time interval between submitting a proposal and when voting power is fixed. This can be used to enforce a delay after a proposal is published for users to unstake tokens, or delegate their votes

  2. votingPeriod : starts after voting delay and when voting is open.

  3. minDelay : delay period before a passed proposal is executed. When the proposal is queued to give users the opportunity to exit DAO if they disagree.

  • Install Repo:

      git clone [email protected]:SashaFlores/DAO.git 
    
  • Install dependencies:

      yarn
    
  • Compile Contracts:

      yarn hardhat compile
    
  • Deploy Contracts:

      yarn hardhat deploy
    
  • To propose, queue, and execute a proposal you will run a local node, as testing & running scripts will require us to run the blockchain by one block to get to the time to vote which should be done in local blockchain not testing or main chains:

      yarn hardhat node
    
  • In another terminal you will run the propose script:

      yarn hardhat run scripts/propose.ts --network localhost
    
  • Vote on proposal:

      yarn hardhat run scripts/vote.ts --network localhost
    
  • Queue & Execute:

     yarn hardhat run scripts/queue-and-execute.ts --network localhost 
    
  • To run the test:

      yarn hardhat test
    

Note:

  • all slither reports for security audit is included in slither directory, for graph files you will need to install xdot that requires Linux. To install linux.

In powerShell with admin mode, run:

wsl --install

You will need to install Linux distribution Ubuntu or download from Microsoft Store.

Install xdot using Ubuntu:

sudo apt install xdot
  • Worth noting that in gas report, when changing one state variable in GovernanceToken contract from uint256 max_supply => uint256 constant max_supply, we saved 41% of gas cost.

References:

  1. Manage Gas and EVM Slots : EVM: From solidity to byte code

  2. Opcodes and gas consumption : EVM Opcodes

  3. Dynamic Gas Costs : Wolflo - GitHub

Special appreciation to Patrick Collins

dao's People

Contributors

sashaflores avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.