Scholarship Distribution Contract
What it does:
Manages applications, approval, and distribution of scholarship funds to students transparently on-chain.
Why it matters:
Reduces administrative delays, ensures funds reach verified students, prevents fraud, and provides a fully auditable record of all scholarships awarded.
How it works:
-
Scholarship providers fund the contract with allocated capital
-
Students submit scholarship applications on-chain
-
Providers or DAO members review and approve applications
-
Approved funds are automatically released to student wallets
-
Students can track their received scholarships
-
All applications, approvals, and payouts are recorded on-chain
-
Unused funds can be reclaimed or reallocated
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
/**
* @title ScholarshipDistribution
* @author Nam
* @notice Decentralized scholarship application and distribution
*/
contract ScholarshipDistribution {
// -------------------- ROLES --------------------
address public admin;
uint256 public scholarshipCount;
// -------------------- STRUCTS --------------------
struct Scholarship {
address student;
string metadataHash; // IPFS / encrypted application
uint256 amount;
bool approved;
bool paid;
}
mapping(uint256 => Scholarship) public scholarships;
// -------------------- EVENTS --------------------
event Funded(address indexed donor, uint256 amount);
event ScholarshipApplied(uint256 indexed scholarshipId, address indexed student);
event ScholarshipApproved(uint256 indexed scholarshipId);
event ScholarshipPaid(uint256 indexed scholarshipId, address indexed student, uint256 amount);
// -------------------- MODIFIERS --------------------
modifier onlyAdmin() {
require(msg.sender == admin, "Not admin");
_;
}
// -------------------- CONSTRUCTOR --------------------
constructor() {
admin = msg.sender;
}
// -------------------- FUNDING --------------------
/**
* @notice Fund the scholarship pool
*/
function fund() external payable {
require(msg.value > 0, "No funds sent");
emit Funded(msg.sender, msg.value);
}
// -------------------- APPLICATIONS --------------------
/**
* @notice Submit a scholarship application
*/
function applyScholarship(string calldata _metadataHash, uint256 _amount) external {
require(_amount > 0, "Invalid amount");
scholarshipCount += 1;
scholarships[scholarshipCount] = Scholarship({
student: msg.sender,
metadataHash: _metadataHash,
amount: _amount,
approved: false,
paid: false
});
emit ScholarshipApplied(scholarshipCount, msg.sender);
}
/**
* @notice Approve a scholarship application
*/
function approveScholarship(uint256 _scholarshipId) external onlyAdmin {
Scholarship storage s = scholarships[_scholarshipId];
require(!s.approved, "Already approved");
s.approved = true;
emit ScholarshipApproved(_scholarshipId);
}
/**
* @notice Pay approved scholarship
*/
function payScholarship(uint256 _scholarshipId) external onlyAdmin {
Scholarship storage s = scholarships[_scholarshipId];
require(s.approved, "Not approved");
require(!s.paid, "Already paid");
require(address(this).balance >= s.amount, "Insufficient funds");
s.paid = true;
payable(s.student).transfer(s.amount);
emit ScholarshipPaid(_scholarshipId, s.student, s.amount);
}
// -------------------- FUNDING RECEIVED --------------------
receive() external payable {}
}