πŸŽ‰ 75% of content is free forever β€” Unlock Premium from $10/mo β†’
CW
Search courses…
πŸ’Ό Servicesℹ️ Aboutβœ‰οΈ ContactView Pricing Plansfrom $10

Governance Mechanisms

Governance🟒 Free Lesson

Advertisement

Governance Mechanisms

On-chain governance, off-chain voting, governance attacks, and design.

Overview

Governance enables decentralized decision-making.

Governance Models

ModelDescription
Token Voting1 token = 1 vote
QuadraticSquare root weighting
ConvictionTime-weighted
DelegationRepresentative voting

Governor Contract

import "@openzeppelin/contracts/governance/Governor.sol";
import "@openzeppelin/contracts/governance/extensions/GovernorCountingSimple.sol";
import "@openzeppelin/contracts/governance/extensions/GovernorVotes.sol";
import "@openzeppelin/contracts/governance/extensions/GovernorVotesQuorumFraction.sol";

contract MyGovernor is Governor, GovernorCountingSimple, GovernorVotes, GovernorVotesQuorumFraction {
    constructor(IVotes _token, uint48 _votingDelay, uint32 _votingPeriod, uint256 _quorumPercentage)
        Governor("MyGovernor")
        GovernorVotes(_token)
        GovernorVotesQuorumFraction(_quorumPercentage)
    {
        votingDelay = _votingDelay;
        votingPeriod = _votingPeriod;
    }
    
    function propose(address[] memory targets, uint256[] memory values, bytes[] memory calldatas, string memory description)
        public override returns (uint256)
    {
        return super.propose(targets, values, calldatas, description);
    }
}

Voting Power

def calculate_voting_power(tokens, delegation_time):
    # Time-weighted voting
    weight = min(delegation_time / (365 * 24 * 60 * 60), 1)
    return tokens * weight

Governance Attacks

AttackDescription
Flash LoanTemporary voting power
Vote BuyingBribery
SybilFake identities
PlutocracyWhale dominance

Best Practices

  1. Timelock β€” Delay execution
  2. Quorum β€” Minimum participation
  3. Delegation β€” Enable representation
  4. Transparency β€” Clear proposals

Practice

Deploy a governance system with a timelock.

⭐

Premium Content

Governance Mechanisms

Unlock this lesson and 900+ advanced tutorials with a Premium plan.

🎯End-to-end Projects
πŸ’ΌInterview Prep
πŸ“œCertificates
🀝Community Access

Already a member? Log in

Need Expert Blockchain Help?

Get personalized tutoring, project support, or professional consulting.

Advertisement