Last active
July 20, 2023 04:15
-
-
Save sullof/34ef732de7ddcc252d1a976dfc5c1052 to your computer and use it in GitHub Desktop.
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: MIT | |
pragma solidity ^0.8.9; | |
import "@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol"; | |
import "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721EnumerableUpgradeable.sol"; | |
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; | |
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; | |
import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; | |
import "@openzeppelin/contracts-upgradeable/utils/CountersUpgradeable.sol"; | |
contract BruceLeeCyberBot is Initializable, ERC721Upgradeable, ERC721EnumerableUpgradeable, OwnableUpgradeable, UUPSUpgradeable { | |
using CountersUpgradeable for CountersUpgradeable.Counter; | |
CountersUpgradeable.Counter private _tokenIdCounter; | |
address public partner; | |
modifier onlyPartner() { | |
require(msg.sender == partner, "minter not allowed"); | |
_; | |
} | |
/// @custom:oz-upgrades-unsafe-allow constructor | |
constructor() { | |
_disableInitializers(); | |
} | |
function initialize(address partner_) initializer public { | |
__ERC721_init("BruceLeeCyberBot", "BLCB"); | |
__ERC721Enumerable_init(); | |
__Ownable_init(); | |
__UUPSUpgradeable_init(); | |
partner = partner_; | |
} | |
function _baseURI() internal pure override returns (string memory) { | |
return "https://meta.byte.city/cyber-bruce-lee/test/bnbchain/"; | |
} | |
function safeMint(address to) public onlyOwner { | |
uint256 tokenId = _tokenIdCounter.current(); | |
_tokenIdCounter.increment(); | |
_safeMint(to, tokenId); | |
} | |
function _authorizeUpgrade(address newImplementation) | |
internal | |
onlyOwner | |
override | |
{} | |
// The following functions are overrides required by Solidity. | |
function _beforeTokenTransfer(address from, address to, uint256 tokenId, uint256 batchSize) | |
internal | |
override(ERC721Upgradeable, ERC721EnumerableUpgradeable) | |
{ | |
super._beforeTokenTransfer(from, to, tokenId, batchSize); | |
} | |
function supportsInterface(bytes4 interfaceId) | |
public | |
view | |
override(ERC721Upgradeable, ERC721EnumerableUpgradeable) | |
returns (bool) | |
{ | |
return super.supportsInterface(interfaceId); | |
} | |
function mint(address to) public onlyPartner { | |
uint256 tokenId = _tokenIdCounter.current(); | |
if (tokenId > 9999) { | |
revert("minting ended"); | |
} | |
_tokenIdCounter.increment(); | |
_safeMint(to, tokenId); | |
} | |
function mintMany(address to, uint256 amount) external onlyPartner { | |
for (uint256 i; i < amount; i++) { | |
mint(to); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment