Reputation-Based Governance

What it does:
Assigns voting power and governance influence to members based on reputation earned through contributions, participation, and verified achievements.

Why it matters:
Encourages active participation, rewards trustworthy behavior, and prevents governance capture by token whales or inactive members.

How it works:

  • Members earn reputation points through verified contributions, completed tasks, or audits

  • Reputation points determine voting weight or proposal eligibility

  • Smart contract tracks reputation changes transparently

  • Negative actions (fraud, rule violations) can reduce reputation

  • Voting and proposal execution respect reputation-weighted influence

  • Public dashboards display member reputations and influence history

  • Can integrate with DAOs, treasuries, and funding contracts for impact-aligned governance

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

import "@openzeppelin/contracts/access/Ownable.sol";

/**
 * @title ReputationBasedGovernance
 * @author Nam
 * @notice On-chain governance weighted by member reputation
 */
contract ReputationBasedGovernance is Ownable {

    struct Proposal {
        string description;
        uint256 votesFor;
        uint256 votesAgainst;
        bool executed;
    }

    uint256 public proposalCount;
    mapping(uint256 => Proposal) public proposals;
    mapping(address => uint256) public reputation;
    mapping(address => mapping(uint256 => bool)) public hasVoted;

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

    event ReputationUpdated(address member, uint256 newReputation);
    event ProposalCreated(uint256 indexed proposalId, string description);
    event Voted(uint256 indexed proposalId, address voter, bool support, uint256 weight);
    event ProposalExecuted(uint256 indexed proposalId);

    // -------------------- REPUTATION MANAGEMENT --------------------

    function updateReputation(address _member, uint256 _newReputation) external onlyOwner {
        reputation[_member] = _newReputation;
        emit ReputationUpdated(_member, _newReputation);
    }

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

    function createProposal(string calldata _description) external {
        proposalCount += 1;
        proposals[proposalCount] = Proposal({
            description: _description,
            votesFor: 0,
            votesAgainst: 0,
            executed: false
        });

        emit ProposalCreated(proposalCount, _description);
    }

    // -------------------- VOTING --------------------

    function vote(uint256 _proposalId, bool _support) external {
        require(reputation[msg.sender] > 0, "No reputation to vote");
        require(!hasVoted[msg.sender][_proposalId], "Already voted");

        Proposal storage p = proposals[_proposalId];
        require(!p.executed, "Proposal already executed");

        uint256 weight = reputation[msg.sender];
        if (_support) {
            p.votesFor += weight;
        } else {
            p.votesAgainst += weight;
        }

        hasVoted[msg.sender][_proposalId] = true;
        emit Voted(_proposalId, msg.sender, _support, weight);
    }

    // -------------------- EXECUTION --------------------

    function executeProposal(uint256 _proposalId) external {
        Proposal storage p = proposals[_proposalId];
        require(!p.executed, "Already executed");
        require(p.votesFor > p.votesAgainst, "Not approved");

        p.executed = true;
        emit ProposalExecuted(_proposalId);
    }
}