Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
- Contract name:
- NFTMulticlassFreeMint
- Optimization enabled
- true
- Compiler version
- v0.8.15+commit.e14f2714
- Optimization runs
- 200
- EVM Version
- default
- Verified at
- 2024-09-26T15:33:34.633606Z
Contract source code
// SPDX-License-Identifier: GPL pragma solidity ^0.8.0; abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } } abstract contract Ownable is Context { address internal _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. constructor() { _transferOwnership(_msgSender()); } */ /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ /* function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } */ /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } interface NFTInterface { function mintWithClass(uint256 classId) external returns (uint256 _newTokenID); function transfer(address _to, uint256 _tokenId, bytes calldata _data) external returns (bool); function addPropertyWithContent(uint256 _tokenId, string calldata _content) external; } contract NFTMulticlassFreeMint is Ownable{ event ClassMinterCreated(uint256 indexed tokenClassAuctionID); event TokenMinted(uint256 indexed tokenID, uint256 indexed tokenClassID, address indexed beneficiary); event NFTContractSet(address indexed newNFTContract, address indexed oldNFTContract); address public nft_contract; struct NFTClassMinter { uint256 amount_minted; mapping (address => bool) isOwner; string[] configuration_properties; } mapping (uint256 => NFTClassMinter) public classMinters; // Mapping from classID (at NFT contract) to set of variables // defining the auction for this token class. constructor() { _owner = msg.sender; } function createNFTClassMinter(uint256 _classID) public onlyOwner { classMinters[_classID].amount_minted = 0; emit ClassMinterCreated(_classID); } function setNFTContract(address _nftContract) public onlyOwner { emit NFTContractSet(_nftContract, nft_contract); nft_contract = _nftContract; } function mintNFT(uint256 _classID, address _to) public payable onlyOwner { require(classMinters[_classID].isOwner[_to] == false, "Token already minted to this address"); uint256 _mintedId = NFTInterface(nft_contract).mintWithClass(_classID); classMinters[_classID].amount_minted++; configureNFT(_mintedId, _classID); classMinters[_classID].isOwner[_to] = true; NFTInterface(nft_contract).transfer(_to, _mintedId, ""); emit TokenMinted(_mintedId, _classID, msg.sender); } function configureNFT(uint256 _tokenId, uint256 _classId) internal { //Add Serial Number to the created Token uint256 tokenSerialNumber = classMinters[_classId].amount_minted; NFTInterface(nft_contract).addPropertyWithContent(_tokenId, toString(tokenSerialNumber)); } function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/Strings.sol#L15-L35 if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } }
Contract ABI
[{"type":"constructor","stateMutability":"nonpayable","inputs":[]},{"type":"event","name":"ClassMinterCreated","inputs":[{"type":"uint256","name":"tokenClassAuctionID","internalType":"uint256","indexed":true}],"anonymous":false},{"type":"event","name":"NFTContractSet","inputs":[{"type":"address","name":"newNFTContract","internalType":"address","indexed":true},{"type":"address","name":"oldNFTContract","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"OwnershipTransferred","inputs":[{"type":"address","name":"previousOwner","internalType":"address","indexed":true},{"type":"address","name":"newOwner","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"TokenMinted","inputs":[{"type":"uint256","name":"tokenID","internalType":"uint256","indexed":true},{"type":"uint256","name":"tokenClassID","internalType":"uint256","indexed":true},{"type":"address","name":"beneficiary","internalType":"address","indexed":true}],"anonymous":false},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"amount_minted","internalType":"uint256"}],"name":"classMinters","inputs":[{"type":"uint256","name":"","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"createNFTClassMinter","inputs":[{"type":"uint256","name":"_classID","internalType":"uint256"}]},{"type":"function","stateMutability":"payable","outputs":[],"name":"mintNFT","inputs":[{"type":"uint256","name":"_classID","internalType":"uint256"},{"type":"address","name":"_to","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"nft_contract","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"owner","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setNFTContract","inputs":[{"type":"address","name":"_nftContract","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"transferOwnership","inputs":[{"type":"address","name":"newOwner","internalType":"address"}]}]
Contract Creation Code
0x608060405234801561001057600080fd5b50600080546001600160a01b0319163317905561095e806100326000396000f3fe6080604052600436106100705760003560e01c8063b8cef3871161004e578063b8cef387146100e1578063db3455161461011c578063f2fde38b1461013c578063fcdcdeee1461015c57600080fd5b8063669f5a51146100755780638da5cb5b1461008a578063a7ccabdf146100c1575b600080fd5b61008861008336600461072c565b61017c565b005b34801561009657600080fd5b506000546001600160a01b03165b6040516001600160a01b0390911681526020015b60405180910390f35b3480156100cd57600080fd5b506100886100dc366004610758565b6103b2565b3480156100ed57600080fd5b5061010e6100fc36600461077a565b60026020526000908152604090205481565b6040519081526020016100b8565b34801561012857600080fd5b5061008861013736600461077a565b610439565b34801561014857600080fd5b50610088610157366004610758565b61049e565b34801561016857600080fd5b506001546100a4906001600160a01b031681565b6000546001600160a01b031633146101af5760405162461bcd60e51b81526004016101a690610793565b60405180910390fd5b60008281526002602090815260408083206001600160a01b038516845260010190915290205460ff16156102315760405162461bcd60e51b8152602060048201526024808201527f546f6b656e20616c7265616479206d696e74656420746f2074686973206164646044820152637265737360e01b60648201526084016101a6565b600154604051633c65b3eb60e01b8152600481018490526000916001600160a01b031690633c65b3eb906024016020604051808303816000875af115801561027d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102a191906107c8565b60008481526002602052604081208054929350906102be836107f7565b91905055506102cd8184610539565b60008381526002602090815260408083206001600160a01b038681168086526001928301909452828520805460ff19168317905590549151635f22feb160e11b81526004810193909352602483018590526060604484015260648301939093529091169063be45fd62906084016020604051808303816000875af1158015610359573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061037d9190610810565b506040513390849083907ff371d67483809edbc84279729528d26a3e37ce67f1e3a911778dbf88ff927ca290600090a4505050565b6000546001600160a01b031633146103dc5760405162461bcd60e51b81526004016101a690610793565b6001546040516001600160a01b03918216918316907f048be79eb9eed95d1a5143dcb6b4b7a5ac915c1decaebd1bd13f267a3cc2dbba90600090a3600180546001600160a01b0319166001600160a01b0392909216919091179055565b6000546001600160a01b031633146104635760405162461bcd60e51b81526004016101a690610793565b6000818152600260205260408082208290555182917f6ea3dd1d908dae17264291defd43931b244a2494ecb4f7fe4e3f7ac2b463c7f091a250565b6000546001600160a01b031633146104c85760405162461bcd60e51b81526004016101a690610793565b6001600160a01b03811661052d5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016101a6565b610536816105b7565b50565b6000818152600260205260409020546001546001600160a01b031663290e008c8461056384610607565b6040518363ffffffff1660e01b8152600401610580929190610832565b600060405180830381600087803b15801561059a57600080fd5b505af11580156105ae573d6000803e3d6000fd5b50505050505050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60608160000361062e5750506040805180820190915260018152600360fc1b602082015290565b8160005b81156106585780610642816107f7565b91506106519050600a836108a5565b9150610632565b60008167ffffffffffffffff811115610673576106736108b9565b6040519080825280601f01601f19166020018201604052801561069d576020820181803683370190505b5090505b8415610708576106b26001836108cf565b91506106bf600a866108e6565b6106ca9060306108fa565b60f81b8183815181106106df576106df610912565b60200101906001600160f81b031916908160001a905350610701600a866108a5565b94506106a1565b949350505050565b80356001600160a01b038116811461072757600080fd5b919050565b6000806040838503121561073f57600080fd5b8235915061074f60208401610710565b90509250929050565b60006020828403121561076a57600080fd5b61077382610710565b9392505050565b60006020828403121561078c57600080fd5b5035919050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6000602082840312156107da57600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b600060018201610809576108096107e1565b5060010190565b60006020828403121561082257600080fd5b8151801515811461077357600080fd5b82815260006020604081840152835180604085015260005b818110156108665785810183015185820160600152820161084a565b81811115610878576000606083870101525b50601f01601f191692909201606001949350505050565b634e487b7160e01b600052601260045260246000fd5b6000826108b4576108b461088f565b500490565b634e487b7160e01b600052604160045260246000fd5b6000828210156108e1576108e16107e1565b500390565b6000826108f5576108f561088f565b500690565b6000821982111561090d5761090d6107e1565b500190565b634e487b7160e01b600052603260045260246000fdfea264697066735822122059449123cb3c1bb62946d3d66a270666da01c547b3e7ad54c392900225f71d1664736f6c634300080f0033
Deployed ByteCode
0x6080604052600436106100705760003560e01c8063b8cef3871161004e578063b8cef387146100e1578063db3455161461011c578063f2fde38b1461013c578063fcdcdeee1461015c57600080fd5b8063669f5a51146100755780638da5cb5b1461008a578063a7ccabdf146100c1575b600080fd5b61008861008336600461072c565b61017c565b005b34801561009657600080fd5b506000546001600160a01b03165b6040516001600160a01b0390911681526020015b60405180910390f35b3480156100cd57600080fd5b506100886100dc366004610758565b6103b2565b3480156100ed57600080fd5b5061010e6100fc36600461077a565b60026020526000908152604090205481565b6040519081526020016100b8565b34801561012857600080fd5b5061008861013736600461077a565b610439565b34801561014857600080fd5b50610088610157366004610758565b61049e565b34801561016857600080fd5b506001546100a4906001600160a01b031681565b6000546001600160a01b031633146101af5760405162461bcd60e51b81526004016101a690610793565b60405180910390fd5b60008281526002602090815260408083206001600160a01b038516845260010190915290205460ff16156102315760405162461bcd60e51b8152602060048201526024808201527f546f6b656e20616c7265616479206d696e74656420746f2074686973206164646044820152637265737360e01b60648201526084016101a6565b600154604051633c65b3eb60e01b8152600481018490526000916001600160a01b031690633c65b3eb906024016020604051808303816000875af115801561027d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102a191906107c8565b60008481526002602052604081208054929350906102be836107f7565b91905055506102cd8184610539565b60008381526002602090815260408083206001600160a01b038681168086526001928301909452828520805460ff19168317905590549151635f22feb160e11b81526004810193909352602483018590526060604484015260648301939093529091169063be45fd62906084016020604051808303816000875af1158015610359573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061037d9190610810565b506040513390849083907ff371d67483809edbc84279729528d26a3e37ce67f1e3a911778dbf88ff927ca290600090a4505050565b6000546001600160a01b031633146103dc5760405162461bcd60e51b81526004016101a690610793565b6001546040516001600160a01b03918216918316907f048be79eb9eed95d1a5143dcb6b4b7a5ac915c1decaebd1bd13f267a3cc2dbba90600090a3600180546001600160a01b0319166001600160a01b0392909216919091179055565b6000546001600160a01b031633146104635760405162461bcd60e51b81526004016101a690610793565b6000818152600260205260408082208290555182917f6ea3dd1d908dae17264291defd43931b244a2494ecb4f7fe4e3f7ac2b463c7f091a250565b6000546001600160a01b031633146104c85760405162461bcd60e51b81526004016101a690610793565b6001600160a01b03811661052d5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016101a6565b610536816105b7565b50565b6000818152600260205260409020546001546001600160a01b031663290e008c8461056384610607565b6040518363ffffffff1660e01b8152600401610580929190610832565b600060405180830381600087803b15801561059a57600080fd5b505af11580156105ae573d6000803e3d6000fd5b50505050505050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60608160000361062e5750506040805180820190915260018152600360fc1b602082015290565b8160005b81156106585780610642816107f7565b91506106519050600a836108a5565b9150610632565b60008167ffffffffffffffff811115610673576106736108b9565b6040519080825280601f01601f19166020018201604052801561069d576020820181803683370190505b5090505b8415610708576106b26001836108cf565b91506106bf600a866108e6565b6106ca9060306108fa565b60f81b8183815181106106df576106df610912565b60200101906001600160f81b031916908160001a905350610701600a866108a5565b94506106a1565b949350505050565b80356001600160a01b038116811461072757600080fd5b919050565b6000806040838503121561073f57600080fd5b8235915061074f60208401610710565b90509250929050565b60006020828403121561076a57600080fd5b61077382610710565b9392505050565b60006020828403121561078c57600080fd5b5035919050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6000602082840312156107da57600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b600060018201610809576108096107e1565b5060010190565b60006020828403121561082257600080fd5b8151801515811461077357600080fd5b82815260006020604081840152835180604085015260005b818110156108665785810183015185820160600152820161084a565b81811115610878576000606083870101525b50601f01601f191692909201606001949350505050565b634e487b7160e01b600052601260045260246000fd5b6000826108b4576108b461088f565b500490565b634e487b7160e01b600052604160045260246000fd5b6000828210156108e1576108e16107e1565b500390565b6000826108f5576108f561088f565b500690565b6000821982111561090d5761090d6107e1565b500190565b634e487b7160e01b600052603260045260246000fdfea264697066735822122059449123cb3c1bb62946d3d66a270666da01c547b3e7ad54c392900225f71d1664736f6c634300080f0033