Created
September 22, 2024 23:12
-
-
Save LeoHChen/45da5079e7103f4416f5c96f0db6626f to your computer and use it in GitHub Desktop.
Badge Factory Contract
This file contains hidden or 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: MIT | |
| pragma solidity ^0.8.0; | |
| import "./BadgeNFT.sol"; | |
| contract BadgeFactory { | |
| address public owner; | |
| BadgeNFT[] public deployedBadges; | |
| event BadgeCreated(address badgeAddress, string badgeName, uint256 supplyLimit); | |
| modifier onlyOwner() { | |
| require(msg.sender == owner, "Only the owner can call this function"); | |
| _; | |
| } | |
| constructor() { | |
| owner = msg.sender; | |
| } | |
| function createBadge(string memory name, string memory symbol, uint256 supplyLimit, string memory baseURI) public onlyOwner { | |
| BadgeNFT newBadge = new BadgeNFT(name, symbol, supplyLimit, baseURI, msg.sender); | |
| deployedBadges.push(newBadge); | |
| emit BadgeCreated(address(newBadge), name, supplyLimit); | |
| } | |
| function getDeployedBadges() public view returns (BadgeNFT[] memory) { | |
| return deployedBadges; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment