2.3 KiB
2.3 KiB
Overview
The VotingContract is a governance mechanism for decentralized voting and proposal management on the ChunkNet blockchain. It enables community members to create, vote on, and finalize proposals with built-in quorum and voting period mechanisms.
Interface
| Function | Parameters | Returns | Description |
|---|---|---|---|
| createProposal | string description | uint256 proposalId | Create a new governance proposal |
| castVote | uint256 proposalId, bool support | void | Cast a vote for or against a proposal |
| finalizeProposal | uint256 proposalId | void | Conclude voting and determine proposal status |
| getProposalDetails | uint256 proposalId | (address, string, uint256, uint256, ProposalStatus) | Retrieve detailed proposal information |
Events
ProposalCreated: Emitted when a new proposal is createdVoteCast: Logged when a participant votes on a proposalProposalStatusChanged: Triggered when a proposal's status is updated
Storage Layout
proposals: Mapping of proposal IDs to Proposal structsproposalCount: Total number of proposals created- Proposal struct contains voting metadata, status, and vote tracking
Access Control
- Proposal creation requires minimum stake (100 ether)
- Voting restricted to active proposal period
- Each address can vote only once per proposal
Security Considerations
- Prevent double voting through
hasVotedmapping - Enforce voting period constraints
- Implement quorum requirement for proposal passage
- Minimum proposal stake to prevent spam
Deployment
ChunkNet Deployment Parameters
- RPC URL: https://rpc.chunknet.org
- Chain ID: 214562
- Recommended Deployment Tools: Hardhat, Foundry
- Environment Variables:
CHUNK_CHAIN_RPC_URLPRIVATE_KEY
Deployment Script Snippet
bash
forge create VotingContract
--rpc-url https://rpc.chunknet.org
--private-key $PRIVATE_KEY
Testing
Test Scenarios
- Proposal creation with insufficient stake
- Voting within and outside proposal period
- Preventing double voting
- Proposal finalization with various vote scenarios
- Quorum calculation verification
Recommended Test Coverage
- Unit tests for each contract function
- Integration tests with governance flow
- Edge case handling
- Gas optimization verification