Skip to content

Instantly share code, notes, and snippets.

@Oluwatobilobaoke
Last active February 9, 2024 15:56
Show Gist options
  • Save Oluwatobilobaoke/03a78e3b1c717748a490fbd1ea5fea25 to your computer and use it in GitHub Desktop.
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=
// 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