Home

Awesome

DAO in Clarity

team

Moloch DAO

A conversion of Moloch DAO 2.1 in Solidity into Clarity

Moloch DAO is a grant-making internet community contract that can hold multiple tokens, make investments, give grants, trade tokens. Members of the dao can vote for proposal. A proposal passes with a simple majority. However, members who did not vote yes can quit the community and take their fair shares. This incentivises proposals that all member can live with. The more members ragequit with their fair share the more the shares of the remaining members is diluted.

It has a small set of features to make it understandable and less error prone. It has been described in various places and forms:

The Solidity version has been deployed to the Ethereum chain and xDai chain and is accessible via https://daohaus.club

The contract has NOT been tested thoroughly. Use with care!

Implementation in Clarity

The Clarity code is very close to the origin Solidity code, the same variables and functions names have been used. Users familiar with the Solidity contract should be able to recognize most of the code in Clarity.

The main functions are

  1. submit-proposal* and cancel-proposal
  2. sponsor-proposal
  3. submit-vote
  4. process-proposal*
  5. ragequit and ragequit

Other functions are available to manage tokens.

The contract supports any token that implements a basic fungible token trait. The trait is defined in a separate contract so that it can be replaced with a standard trait when available.

Testing

The contract can be deployed to the mocknet or testnet.

Unit Tests

Basic unit tests are available to check the syntax of the contracts. The contracts can't be tested beyond syntax checking in the Clarity VM because the DAO contract depends on block times which are not available in the VM (Failed to get block data.). For unit tests run:

yarn mocha test/dao

Setup for Tests on Mocknet

Start your mocknet with the provided Stacks.toml.

stacks-node testnet start --config=./Stacks.toml

Deploy the contracts using

yarn mocha test/deploy
Proposal flow

In test/integration.ts the relevant functions are defined to go through a basic proposal flow. After the contracts are deployed (due to the length of the dao contract it takes longer than usual). Run

yarn mocha test/proposal-life-cycle.ts

Application as Web App

Currently, there is not working UI. Some work to adapt https://daohaus.club to support Moloch DAOs on the Stacks chain has been started at friedger/daohaus-web and friedger/pokemol-web. It also requires modications of stacks-node-api to better match the moloch server API. This is still work to be done.

ui

Application as CLI

The application can be used with mocha tests:

  1. get tokens from faucet: yarn mocha -g "faucet"
  2. submit proposal: yarn mocha -g "submit proposal"
  3. sponsor proposal: yarn mocha -g "sponsor proposal"
  4. submit votes: yarn mocha -g "submit votes"
  5. process proposal: yarn mocha -g "process proposal"

Explainer video

Remarks

General warning: The contract has NOT been tested thoroughly. Use with care!