Last active
February 9, 2024 15:56
-
-
Save Oluwatobilobaoke/03a78e3b1c717748a490fbd1ea5fea25 to your computer and use it in GitHub Desktop.
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.24+commit.e11b9ed9.js&optimize=false&runs=200&gist=
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: GPL-3.0 | |
pragma solidity ^0.8.20; | |
import "./schoolrecord.sol"; | |
contract SchoolFactory { | |
address public owner; // Contract owner | |
mapping(address => School) public deployedSchools; // Deployed schools mapping | |
event SchoolCreated(address schoolAddress, address creator); | |
constructor() { | |
owner = msg.sender; | |
} | |
/// @dev Deploys a new School contract instance | |
function createSchool( | |
string memory name, | |
address principalAddress | |
) public payable { | |
School school = new School(principalAddress, name); | |
deployedSchools[school.principal()] = school; // Map school to principal | |
emit SchoolCreated(address(school), msg.sender); | |
} | |
modifier onlyOwner() { | |
require(msg.sender == owner, "Only owner can perform this action"); | |
_; | |
} | |
} | |
Link to school contract | |
https://gist.github.com/Oluwatobilobaoke/742da21bfba5b0772afd4cf510d94fca |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment