2.7 KiB
2.7 KiB
Overview
The GovernanceContract is a decentralized governance mechanism for managing community proposals and voting processes on the ChunkNet blockchain. It provides a transparent, secure method for community members to create, vote on, and finalize governance proposals.
Interface
| Function | Parameters | Returns | Description |
|---|---|---|---|
createProposal |
string _description |
uint256 |
Create a new governance proposal |
vote |
uint256 _proposalId, bool _support |
void |
Cast a vote on an active proposal |
finalizeProposal |
uint256 _proposalId |
void |
Conclude voting and determine proposal status |
getProposalDetails |
uint256 _proposalId |
Proposal |
Retrieve detailed information about a specific proposal |
Events
ProposalCreated: Emitted when a new proposal is createdProposalVoted: Triggered when a community member votesProposalStatusChanged: Signals changes in proposal status
Storage Layout
proposals: Mapping of proposal IDs to Proposal structsproposalCount: Total number of proposals createdvotingContract: Reference to the VotingContract for voting power calculations- Constant parameters:
VOTING_PERIOD: 7 daysQUORUM_PERCENTAGE: 30%PASS_THRESHOLD_PERCENTAGE: 50%
Access Control
- Proposal creation: Open to all registered community members
- Voting: Restricted to members with valid voting power
- Proposal finalization: Can be called by any participant after voting period ends
Security Considerations
- Prevents double voting through
hasVotedmapping - Uses voting power from external VotingContract
- Implements time-based voting restrictions
- Requires quorum and pass threshold for proposal validation
- Prevents proposal manipulation through cryptographic hashing
Deployment
Blockchain Environment:
- RPC URL: https://rpc.chunknet.org
- Chain ID: 214562
- Network: ChunkNet DevNet
Deployment Steps:
- Deploy VotingContract first
- Pass VotingContract address to GovernanceContract constructor
- Verify contract parameters
- Set appropriate access controls
Recommended Deployment Configuration:
bash
forge create GovernanceContract
--rpc-url https://rpc.chunknet.org
--private-key $DEPLOYER_PRIVATE_KEY
--constructor-args $VOTING_CONTRACT_ADDRESS
Testing
Test cases should cover:
- Proposal creation validation
- Voting mechanism
- Quorum and threshold calculations
- Proposal status transitions
- Edge cases and potential attack vectors
Recommended test scenarios:
- Create proposal with empty description
- Vote before and after voting period
- Test voting power calculations
- Validate proposal finalization logic
- Check event emissions