University Voting System
What it does:
Enables students, faculty, and staff to vote on university decisions such as policy changes, elections, or budget allocations using blockchain-based governance.
Why it matters:
Ensures transparent, tamper-proof, and verifiable decision-making, increases community engagement, and reduces administrative overhead and fraud.
How it works:
-
Eligible voters are registered with the system (students, faculty, staff)
-
Proposals for votes (e.g., elections, policy changes, fund allocation) are submitted on-chain
-
Voting period and rules (token-weighted or one-person-one-vote) are defined for each proposal
-
Voters cast votes through the smart contract within the allowed timeframe
-
Votes are tallied automatically and results are recorded immutably
-
Winning proposals trigger on-chain actions such as fund release or policy status updates
-
All voting history is auditable, ensuring transparency and accountability
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
/**
* @title UniversityVotingSystem
* @author Nam
* @notice On-chain voting and governance for universities
*/
contract UniversityVotingSystem {
address public admin;
uint256 public proposalCount;
struct Proposal {
string description;
uint256 votesFor;
uint256 votesAgainst;
uint256 deadline;
bool executed;
mapping(address => bool) voted;
}
mapping(uint256 => Proposal) public proposals;
mapping(address => bool) public eligibleVoters;
// -------------------- EVENTS --------------------
event VoterRegistered(address indexed voter);
event ProposalCreated(uint256 indexed proposalId, string description, uint256 deadline);
event Voted(uint256 indexed proposalId, address indexed voter, bool support);
event ProposalExecuted(uint256 indexed proposalId, bool success);
// -------------------- MODIFIERS --------------------
modifier onlyAdmin() {
require(msg.sender == admin, "Not admin");
_;
}
modifier onlyEligibleVoter() {
require(eligibleVoters[msg.sender], "Not eligible voter");
_;
}
modifier proposalActive(uint256 _proposalId) {
require(block.timestamp 0 && _proposalId 0, "Duration must be >0");
proposalCount += 1;
Proposal storage p = proposals[proposalCount];
p.description = _description;
p.deadline = block.timestamp + _votingDuration;
p.executed = false;
emit ProposalCreated(proposalCount, _description, p.deadline);
}
function vote(uint256 _proposalId, bool _support) external onlyEligibleVoter proposalActive(_proposalId) proposalExists(_proposalId) {
Proposal storage p = proposals[_proposalId];
require(!p.voted[msg.sender], "Already voted");
p.voted[msg.sender] = true;
if (_support) {
p.votesFor += 1;
} else {
p.votesAgainst += 1;
}
emit Voted(_proposalId, msg.sender, _support);
}
function executeProposal(uint256 _proposalId) external proposalExists(_proposalId) {
Proposal storage p = proposals[_proposalId];
require(!p.executed, "Already executed");
require(block.timestamp > p.deadline, "Voting still active");
bool success = p.votesFor > p.votesAgainst;
p.executed = true;
// Integration with university systems can be triggered here
emit ProposalExecuted(_proposalId, success);
}
}