Skip to content

Instantly share code, notes, and snippets.

@LeoHChen
Created September 22, 2024 23:12
Show Gist options
  • Select an option

  • Save LeoHChen/45da5079e7103f4416f5c96f0db6626f to your computer and use it in GitHub Desktop.

Select an option

Save LeoHChen/45da5079e7103f4416f5c96f0db6626f to your computer and use it in GitHub Desktop.
Badge Factory Contract
// 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