> For the complete documentation index, see [llms.txt](https://docs.bvm.network/bvm/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.bvm.network/bvm/bitcoin-dapps/evm-code-tutorials/operate-your-project-using-a-dao.md).

# Operate your project using a DAO

Build a decentralized autonomous organization for your community where people can submit and then vote on proposals.

{% hint style="info" %}
Since your ZK Rollup is EVM-compatible, dApps should be written in Solidity. If you are new to this programming language, please learn more about it [here](https://docs.soliditylang.org/en/v0.8.26/).
{% endhint %}

## Write a DAO smart contract

Extending the OpenZeppelin Governor contract, we create a governance contract that let the community makes decisions for the protocol.&#x20;

```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.2;

import "@openzeppelin/contracts/governance/Governor.sol";
import "@openzeppelin/contracts/governance/compatibility/GovernorCompatibilityBravo.sol";
import "@openzeppelin/contracts/governance/extensions/GovernorVotes.sol";
import "@openzeppelin/contracts/governance/extensions/GovernorVotesQuorumFraction.sol";
import "./ERC20Vote.sol";

contract GovernorVote is Governor, GovernorCompatibilityBravo, GovernorVotes, GovernorVotesQuorumFraction {
    constructor(IVotes _token)
    Governor("MyGovernor")
    GovernorVotes(_token)
    GovernorVotesQuorumFraction(4)
    {}

    function votingDelay() public pure override returns (uint256) {
        return 20; // 20 blocks
    }

    function votingPeriod() public pure override returns (uint256) {
        return 100; // 100 blocks
    }

    function proposalThreshold() public pure override returns (uint256) {
        return 0;
    }

    // The functions below are overrides required by Solidity.

    function state(uint256 proposalId)
    public
    view
    override(Governor, IGovernor)
    returns (ProposalState)
    {
        return super.state(proposalId);
    }

    function propose(address[] memory targets, uint256[] memory values, bytes[] memory calldatas, string memory description)
    public
    override(Governor, GovernorCompatibilityBravo)
    returns (uint256)
    {
        return super.propose(targets, values, calldatas, description);
    }

    function _execute(uint256 proposalId, address[] memory targets, uint256[] memory values, bytes[] memory calldatas, bytes32 descriptionHash)
    internal
    override(Governor)
    {
        super._execute(proposalId, targets, values, calldatas, descriptionHash);
    }

    function _cancel(address[] memory targets, uint256[] memory values, bytes[] memory calldatas, bytes32 descriptionHash)
    internal
    override(Governor)
    returns (uint256)
    {
        return super._cancel(targets, values, calldatas, descriptionHash);
    }

    function _executor()
    internal
    view
    override(Governor)
    returns (address)
    {
        return super._executor();
    }

    function supportsInterface(bytes4 interfaceId)
    public
    view
    override(Governor, IERC165)
    returns (bool)
    {
        return super.supportsInterface(interfaceId);
    }

    // override unused functions
    function proposalEta(uint256) public pure override returns (uint256) {
        return 0;
    }

    function timelock() public pure override returns (address) {
        return address(0x0);
    }

    function queue(
        address[] memory,
        uint256[] memory,
        bytes[] memory,
        bytes32
    ) public pure override returns (uint256) {
        return 0;
    }
}

contract DAO is GovernorVote {
    constructor() GovernorVote(new MyERC20VoteToken()) {
        IERC20(address(token)).transfer(msg.sender, 1e22); // 10000 tokens
    }
}

```

## Clone the smart contract examples

We've prepared a few different examples for you to get started.

```bash
git clone https://github.com/trustlesscomputer/smart-contract-examples.git
```

## Compile and Deploy the contracts

Refer to the [tutorial](https://docs.bvm.network/bvm/more/how-to-deploy-a-smart-contract-to-supersonic).

## Interact with the contracts

Once the contracts are deployed, you can interact with them. We've prepared a few `hardhat tasks` to make it easy for you to interact with the contracts.

```bash
npx hardhat createProposal --target <your-address-to-receive-funds> --value <proposal-amount> --description <proposal-description>
npx hardhat castVote --id <proposal-id> --vote <voting-amount>
npx hardhat getState --id <proposal-id>
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.bvm.network/bvm/bitcoin-dapps/evm-code-tutorials/operate-your-project-using-a-dao.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
