# Governance & DAO Module

This module is designed to be developer-extensible and user-accessible—powering everything from small creator communities to protocol governance.

🧱 Architecture Overview

OmniSocial’s governance layer consists of two core contracts:

* `DAOFactory`: deploys new DAOs and tracks them
* `DAO`: each deployed instance is a fully functioning, upgradeable DAO with proposal, voting, and execution logic

#### Other integrated systems:

* `ReputationModule`: reputation-based voting weights
* `Timelock`: optional execution delay (for moderation and safety)
* `ProposalRegistry`: indexing proposals for frontend/subgraph use

🏗 DAOFactory Contract

Used to create and register new DAOs on-chain.

#### `createDAO(...)`

```solidity
function createDAO(
  string memory name,
  address[] memory initialMembers,
  uint256[] memory initialRep,
  uint256 quorum,
  uint256 votingPeriod,
  bool useTimelock
) external returns (address newDAO);
```

**Params:**

* `name`: DAO identifier (used in metadata & .omni subdomain)
* `initialMembers`: addresses of founding members
* `initialRep`: reputation scores assigned to each founder
* `quorum`: % of total rep needed for a vote to pass
* `votingPeriod`: time window (in seconds) for each vote
* `useTimelock`: enable/disable proposal delay before execution

🧠 DAO Contract

Each DAO contract is independent and manages its own proposals, votes, and execution state.

📜 Proposal Lifecycle

1. **Create Proposal**
2. **Voting Period**
3. **Quorum Check**
4. **Execution (or Expiry)**
5. **Post-execution events/logs**

***

#### `createProposal(...)`

```solidity
function createProposal(
  string memory title,
  string memory description,
  bytes[] calldata actions
) external returns (uint256 proposalId);
```

* `title` / `description`: Proposal metadata
* `actions`: array of encoded function calls to execute if approved

> The proposal is stored with a unique ID, state is set to `Active`.

***

#### `castVote(...)`

```solidity
function castVote(uint256 proposalId, bool support) external;
```

* Requires the sender to have non-zero reputation in the DAO
* Votes are **weighted by current reputation score** at time of vote

***

#### `executeProposal(...)`

```solidity
function executeProposal(uint256 proposalId) external;
```

* Checks that proposal passed quorum and voting period is over
* If `useTimelock` is `true`, the execution is delayed until after a set buffer

⏳ Timelock (Optional)

If enabled:

* Proposal is marked `Queued` upon passing vote
* Can only be executed after `minDelay` (e.g., 24 hours)
* Delay ensures DAO members can veto or leave if they disagree

🔄 Example: Proposal Flow

```solidity
// 1. Creator submits proposal to update DAO metadata
dao.createProposal(
  "Update Community Banner",
  "We propose changing the DAO profile banner image",
  [abi.encodeWithSignature("updateBanner(string)", "ipfs://QmNewHash")]
);

// 2. Members vote during active window
dao.castVote(1, true); // support
dao.castVote(1, false); // against

// 3. After voting ends, and if quorum met
dao.executeProposal(1); // triggers updateBanner(...)
```

🧾 Proposal Metadata Example (for frontends)

```json
{
  "id": 1,
  "title": "Fund a New Podcast",
  "description": "Proposal to allocate 100 OMNI to fund a podcast series.",
  "actions": [
    {
      "target": "0xFundingContract",
      "value": 0,
      "data": "0xa9059cbb000000000000000000000000..."
    }
  ],
  "status": "Active",
  "votesFor": 320,
  "votesAgainst": 50,
  "quorum": 300,
  "votingEnds": 1715529600
}
```

📊 Subgraph Support

You can query DAOs and their proposals using GraphQL:

```graphql
query AllDAOs {
  daos {
    id
    name
    quorum
    votingPeriod
  }
}
```

```graphql
query DAOProposals($daoId: ID!) {
  proposals(where: {dao: $daoId}) {
    id
    title
    description
    status
    votesFor
    votesAgainst
  }
}
```


---

# Agent Instructions: 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:

```
GET https://docs.omnisocial.dev/architecture-and-concepts/governance-and-dao-module.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
