false
false
0

Contract Address Details

0x34891468C8be5f9Ad48600c56Ee1f13a79BaBff0

Contract Name
NFTMulticlassFreeMint
Creator
0x964070–829cff at 0xb3eddb–be425c
Balance
0 CLO
Tokens
Fetching tokens...
Transactions
Fetching transactions...
Transfers
Fetching transfers...
Gas Used
Fetching gas used...
Last Balance Update
16289170
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.17+commit.8df45f5f




Optimization runs
1000
EVM Version
default




Verified at
2024-09-26T15:33:35.435973Z

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;
        uint256 max_amount;
        mapping (address => bool) isOwner;
    }

    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, uint256 _max_amount) public onlyOwner
    {
        classMinters[_classID].amount_minted = 0; 
        classMinters[_classID].max_amount = _max_amount; 

        emit ClassMinterCreated(_classID);
    }

    function setNFTContract(address _nftContract) public onlyOwner
    {
        emit NFTContractSet(_nftContract, nft_contract);

        nft_contract = _nftContract;
    }

    function getIsOwner(uint _classID, address _address) public view returns (bool) {
        return classMinters[_classID].isOwner[_address];
    }

    function mintNFT(uint256 _classID, address _to) public onlyOwner
    {
        require(classMinters[_classID].max_amount > classMinters[_classID].amount_minted, "There are no more NFTs left");
        require(classMinters[_classID].isOwner[_to] == false, "Token already minted to this address");
        uint256 _mintedId = NFTInterface(nft_contract).mintWithClass(_classID);
        unchecked{
            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) {
            unchecked{
                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"},{"type":"uint256","name":"max_amount","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":"uint256","name":"_max_amount","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"getIsOwner","inputs":[{"type":"uint256","name":"_classID","internalType":"uint256"},{"type":"address","name":"_address","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","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

Verify & Publish
0x608060405234801561001057600080fd5b50600080546001600160a01b03191633179055610b0c806100326000396000f3fe608060405234801561001057600080fd5b50600436106100885760003560e01c8063b8cef3871161005b578063b8cef38714610102578063d4786e8b1461013e578063f2fde38b14610151578063fcdcdeee1461016457600080fd5b8063669f5a511461008d5780638da5cb5b146100a2578063a4cbe513146100cc578063a7ccabdf146100ef575b600080fd5b6100a061009b366004610916565b610177565b005b6000546001600160a01b03165b6040516001600160a01b0390911681526020015b60405180910390f35b6100df6100da366004610916565b61047c565b60405190151581526020016100c3565b6100a06100fd366004610942565b6104ab565b610129610110366004610964565b6002602052600090815260409020805460019091015482565b604080519283526020830191909152016100c3565b6100a061014c36600461097d565b61056f565b6100a061015f366004610942565b61060b565b6001546100af906001600160a01b031681565b6000546001600160a01b031633146101d65760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064015b60405180910390fd5b60008281526002602052604090208054600190910154116102395760405162461bcd60e51b815260206004820152601b60248201527f546865726520617265206e6f206d6f7265204e465473206c656674000000000060448201526064016101cd565b60008281526002602081815260408084206001600160a01b0386168552909201905290205460ff16156102d35760405162461bcd60e51b8152602060048201526024808201527f546f6b656e20616c7265616479206d696e74656420746f20746869732061646460448201527f726573730000000000000000000000000000000000000000000000000000000060648201526084016101cd565b6001546040517f3c65b3eb000000000000000000000000000000000000000000000000000000008152600481018490526000916001600160a01b031690633c65b3eb906024016020604051808303816000875af1158015610338573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061035c919061099f565b600084815260026020526040902080546001019055905061037d81846106ed565b60008381526002602081815260408084206001600160a01b0387811680875291909401909252808420805460ff191660019081179091555490517fbe45fd6200000000000000000000000000000000000000000000000000000000815260048101929092526024820185905260606044830152606482019390935291169063be45fd62906084016020604051808303816000875af1158015610423573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061044791906109b8565b506040513390849083907ff371d67483809edbc84279729528d26a3e37ce67f1e3a911778dbf88ff927ca290600090a4505050565b60008281526002602081815260408084206001600160a01b0386168552909201905290205460ff165b92915050565b6000546001600160a01b031633146105055760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016101cd565b6001546040516001600160a01b03918216918316907f048be79eb9eed95d1a5143dcb6b4b7a5ac915c1decaebd1bd13f267a3cc2dbba90600090a36001805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0392909216919091179055565b6000546001600160a01b031633146105c95760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016101cd565b6000828152600260205260408082208281556001018390555183917f6ea3dd1d908dae17264291defd43931b244a2494ecb4f7fe4e3f7ac2b463c7f091a25050565b6000546001600160a01b031633146106655760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016101cd565b6001600160a01b0381166106e15760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016101cd565b6106ea8161076b565b50565b6000818152600260205260409020546001546001600160a01b031663290e008c84610717846107c8565b6040518363ffffffff1660e01b81526004016107349291906109da565b600060405180830381600087803b15801561074e57600080fd5b505af1158015610762573d6000803e3d6000fd5b50505050505050565b600080546001600160a01b0383811673ffffffffffffffffffffffffffffffffffffffff19831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60608160000361080b57505060408051808201909152600181527f3000000000000000000000000000000000000000000000000000000000000000602082015290565b8160005b811561082a57600101610823600a83610a5c565b915061080f565b60008167ffffffffffffffff81111561084557610845610a70565b6040519080825280601f01601f19166020018201604052801561086f576020820181803683370190505b5090505b84156108f257610884600183610a86565b9150610891600a86610a99565b61089c906030610aad565b60f81b8183815181106108b1576108b1610ac0565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053506108eb600a86610a5c565b9450610873565b949350505050565b80356001600160a01b038116811461091157600080fd5b919050565b6000806040838503121561092957600080fd5b82359150610939602084016108fa565b90509250929050565b60006020828403121561095457600080fd5b61095d826108fa565b9392505050565b60006020828403121561097657600080fd5b5035919050565b6000806040838503121561099057600080fd5b50508035926020909101359150565b6000602082840312156109b157600080fd5b5051919050565b6000602082840312156109ca57600080fd5b8151801515811461095d57600080fd5b82815260006020604081840152835180604085015260005b81811015610a0e578581018301518582016060015282016109f2565b506000606082860101526060601f19601f830116850101925050509392505050565b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600082610a6b57610a6b610a30565b500490565b634e487b7160e01b600052604160045260246000fd5b818103818111156104a5576104a5610a46565b600082610aa857610aa8610a30565b500690565b808201808211156104a5576104a5610a46565b634e487b7160e01b600052603260045260246000fdfea2646970667358221220bf7aefb0f0b0c336d9895ed2283c51abd8c60d0d24251094e7465c01feadd27064736f6c63430008110033

Deployed ByteCode

0x608060405234801561001057600080fd5b50600436106100885760003560e01c8063b8cef3871161005b578063b8cef38714610102578063d4786e8b1461013e578063f2fde38b14610151578063fcdcdeee1461016457600080fd5b8063669f5a511461008d5780638da5cb5b146100a2578063a4cbe513146100cc578063a7ccabdf146100ef575b600080fd5b6100a061009b366004610916565b610177565b005b6000546001600160a01b03165b6040516001600160a01b0390911681526020015b60405180910390f35b6100df6100da366004610916565b61047c565b60405190151581526020016100c3565b6100a06100fd366004610942565b6104ab565b610129610110366004610964565b6002602052600090815260409020805460019091015482565b604080519283526020830191909152016100c3565b6100a061014c36600461097d565b61056f565b6100a061015f366004610942565b61060b565b6001546100af906001600160a01b031681565b6000546001600160a01b031633146101d65760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064015b60405180910390fd5b60008281526002602052604090208054600190910154116102395760405162461bcd60e51b815260206004820152601b60248201527f546865726520617265206e6f206d6f7265204e465473206c656674000000000060448201526064016101cd565b60008281526002602081815260408084206001600160a01b0386168552909201905290205460ff16156102d35760405162461bcd60e51b8152602060048201526024808201527f546f6b656e20616c7265616479206d696e74656420746f20746869732061646460448201527f726573730000000000000000000000000000000000000000000000000000000060648201526084016101cd565b6001546040517f3c65b3eb000000000000000000000000000000000000000000000000000000008152600481018490526000916001600160a01b031690633c65b3eb906024016020604051808303816000875af1158015610338573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061035c919061099f565b600084815260026020526040902080546001019055905061037d81846106ed565b60008381526002602081815260408084206001600160a01b0387811680875291909401909252808420805460ff191660019081179091555490517fbe45fd6200000000000000000000000000000000000000000000000000000000815260048101929092526024820185905260606044830152606482019390935291169063be45fd62906084016020604051808303816000875af1158015610423573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061044791906109b8565b506040513390849083907ff371d67483809edbc84279729528d26a3e37ce67f1e3a911778dbf88ff927ca290600090a4505050565b60008281526002602081815260408084206001600160a01b0386168552909201905290205460ff165b92915050565b6000546001600160a01b031633146105055760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016101cd565b6001546040516001600160a01b03918216918316907f048be79eb9eed95d1a5143dcb6b4b7a5ac915c1decaebd1bd13f267a3cc2dbba90600090a36001805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0392909216919091179055565b6000546001600160a01b031633146105c95760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016101cd565b6000828152600260205260408082208281556001018390555183917f6ea3dd1d908dae17264291defd43931b244a2494ecb4f7fe4e3f7ac2b463c7f091a25050565b6000546001600160a01b031633146106655760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016101cd565b6001600160a01b0381166106e15760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016101cd565b6106ea8161076b565b50565b6000818152600260205260409020546001546001600160a01b031663290e008c84610717846107c8565b6040518363ffffffff1660e01b81526004016107349291906109da565b600060405180830381600087803b15801561074e57600080fd5b505af1158015610762573d6000803e3d6000fd5b50505050505050565b600080546001600160a01b0383811673ffffffffffffffffffffffffffffffffffffffff19831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60608160000361080b57505060408051808201909152600181527f3000000000000000000000000000000000000000000000000000000000000000602082015290565b8160005b811561082a57600101610823600a83610a5c565b915061080f565b60008167ffffffffffffffff81111561084557610845610a70565b6040519080825280601f01601f19166020018201604052801561086f576020820181803683370190505b5090505b84156108f257610884600183610a86565b9150610891600a86610a99565b61089c906030610aad565b60f81b8183815181106108b1576108b1610ac0565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053506108eb600a86610a5c565b9450610873565b949350505050565b80356001600160a01b038116811461091157600080fd5b919050565b6000806040838503121561092957600080fd5b82359150610939602084016108fa565b90509250929050565b60006020828403121561095457600080fd5b61095d826108fa565b9392505050565b60006020828403121561097657600080fd5b5035919050565b6000806040838503121561099057600080fd5b50508035926020909101359150565b6000602082840312156109b157600080fd5b5051919050565b6000602082840312156109ca57600080fd5b8151801515811461095d57600080fd5b82815260006020604081840152835180604085015260005b81811015610a0e578581018301518582016060015282016109f2565b506000606082860101526060601f19601f830116850101925050509392505050565b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600082610a6b57610a6b610a30565b500490565b634e487b7160e01b600052604160045260246000fd5b818103818111156104a5576104a5610a46565b600082610aa857610aa8610a30565b500690565b808201808211156104a5576104a5610a46565b634e487b7160e01b600052603260045260246000fdfea2646970667358221220bf7aefb0f0b0c336d9895ed2283c51abd8c60d0d24251094e7465c01feadd27064736f6c63430008110033