Mental Health Support DAO

What it does:
Creates a decentralized organization that funds mental health support programs, subsidizes therapy sessions, and governs community-driven wellness initiatives.

Why it matters:
Reduces stigma, improves access to mental health care, and enables transparent, community-led funding without relying on centralized institutions or opaque decision-making.

How it works:

  • DAO members contribute funds to a shared treasury

  • Members receive governance tokens representing voting power

  • Mental health initiatives submit funding proposals

  • Community votes on proposals through on-chain governance

  • Approved proposals receive milestone-based funding

  • All spending and decisions are transparently recorded

      // SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

/**
 * @title MentalHealthSupportDAO
 * @author Nam
 * @notice DAO for funding mental health support initiatives
 */
contract MentalHealthSupportDAO {

    // -------------------- DAO STATE --------------------

    uint256 public proposalCount;
    uint256 public votingDuration;

    mapping(address => uint256) public governanceTokens;

    // -------------------- PROPOSALS --------------------

    struct Proposal {
        address payable recipient;
        uint256 amount;
        string description;
        uint256 voteEnd;
        uint256 yesVotes;
        uint256 noVotes;
        bool executed;
    }

    mapping(uint256 => Proposal) public proposals;

    // -------------------- EVENTS --------------------

    event TokensMinted(address indexed member, uint256 amount);
    event ProposalCreated(uint256 indexed proposalId, address indexed recipient);
    event VoteCast(uint256 indexed proposalId, address indexed voter, bool support);
    event ProposalExecuted(uint256 indexed proposalId, uint256 amount);

    // -------------------- CONSTRUCTOR --------------------

    constructor(uint256 _votingDuration) {
        votingDuration = _votingDuration;
    }

    // -------------------- TREASURY --------------------

    /**
     * @notice Contribute ETH and receive governance tokens
     */
    function contribute() external payable {
        require(msg.value > 0, "No contribution");

        governanceTokens[msg.sender] += msg.value;
        emit TokensMinted(msg.sender, msg.value);
    }

    // -------------------- GOVERNANCE --------------------

    /**
     * @notice Create a funding proposal
     */
    function createProposal(
        address payable _recipient,
        uint256 _amount,
        string calldata _description
    )
        external
    {
        require(governanceTokens[msg.sender] > 0, "Not a member");
        require(_amount <= address(this).balance, "Insufficient treasury");

        proposalCount += 1;

        proposals[proposalCount] = Proposal({
            recipient: _recipient,
            amount: _amount,
            description: _description,
            voteEnd: block.timestamp + votingDuration,
            yesVotes: 0,
            noVotes: 0,
            executed: false
        });

        emit ProposalCreated(proposalCount, _recipient);
    }

    /**
     * @notice Vote on a proposal
     */
    function vote(uint256 _proposalId, bool _support) external {
        Proposal storage p = proposals[_proposalId];

        require(block.timestamp  0, "No voting power");

        uint256 weight = governanceTokens[msg.sender];

        if (_support) {
            p.yesVotes += weight;
        } else {
            p.noVotes += weight;
        }

        emit VoteCast(_proposalId, msg.sender, _support);
    }

    /**
     * @notice Execute approved proposal
     */
    function executeProposal(uint256 _proposalId) external {
        Proposal storage p = proposals[_proposalId];

        require(block.timestamp > p.voteEnd, "Voting ongoing");
        require(!p.executed, "Already executed");
        require(p.yesVotes > p.noVotes, "Proposal rejected");

        p.executed = true;
        p.recipient.transfer(p.amount);

        emit ProposalExecuted(_proposalId, p.amount);
    }
}