File size: 4,136 Bytes
f998fcd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
// This contract is part of Zellic’s smart contract dataset, which is a collection of publicly available contract code gathered as of March 2023.

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

import "./ERC721.sol";
import "./ERC721Burnable.sol";
import "./AccessControl.sol";
import "./Ownable.sol";
import "./Pausable.sol";
import "./Counters.sol";
import "./DefaultOperatorFilterer.sol";

contract QC is ERC721, DefaultOperatorFilterer, Ownable {
    bytes32 public constant MANAGER_ROLE = keccak256("MANAGER_ROLE");
    bytes32 public constant AIRDROP_ROLE = keccak256("AIRDROP_ROLE");

    using Counters for Counters.Counter;

    string public baseURI;
    uint256 public maxSupply;
    uint256 public publicMint;
    bool public publicMintEnabled;
    mapping (address => bool) private minters;
    uint256 public cost;

    Counters.Counter private tokenIdCounter;

    constructor() payable
        ERC721("Queen Chamade", "QUEENCHAMADE")
    {
        baseURI = "https://ipfs.io/ipfs/QmeHtLMpUHKSFg2K5QukqyGs1AcEuyGEjqr3BeiJ8MRD7p/";
        maxSupply = 800;
        publicMint = 800;
        cost = 0.002 ether;
        publicMintEnabled = false;
    }

     // Operator Registry Controls
    function updateOperator(address _operator, bool _filtered) public onlyOwner {
        OPERATOR_FILTER_REGISTRY.updateOperator(address(this), _operator, _filtered);
    }

    // F2O
    function mint(uint256 amount)
        external payable
    {
        require(tokenIdCounter.current() < maxSupply, "QueenChamade: exceeds max supply");
        require(balanceOf(_msgSender()) == 0, "QueenChamade: exceeds mint limit");
        require(minters[_msgSender()] == false, "QueenChamade: exceeds mint limit");
        require(publicMintEnabled == true, "QueenChamade: public mint not enabled");
        require(publicMint > 0, "QueenChamade: no public mint allocation");
        require(tx.origin == _msgSender(), "QueenChamade: invalid eoa");
        require(amount <= 10, "QueenChamade: exceeds mint limit");
        require(amount > 0, "QueenChamade: invalid eoa");
        require((publicMint - amount) > 0, "QueenChamade: exceeds mint limit");
        require(msg.value == (amount * cost), "QueenChamade: invalid price");
        minters[_msgSender()] = true;
        
        
        publicMint -= amount;
        
        for(uint i = 0; i < amount; i++) {
            uint256 tokenId = tokenIdCounter.current();
            tokenIdCounter.increment();
            _safeMint(_msgSender(), tokenId);
        }
    }

    function transferFrom(address from, address to, uint256 tokenId) public override onlyAllowedOperator(from) {
        super.transferFrom(from, to, tokenId);
    }

    function safeTransferFrom(address from, address to, uint256 tokenId) public override onlyAllowedOperator(from) {
        super.safeTransferFrom(from, to, tokenId);
    }


    function setPublicMintEnabled(bool enabled)
        public
        onlyOwner
    {
        publicMintEnabled = enabled;
    }

    function setBaseURI(string calldata baseURI_)
        public 
        onlyOwner
    {
        baseURI = baseURI_;
    }

    function _baseURI()
        internal
        view
        override
        returns (string memory)
    {
        return baseURI;
    }


    function withdrawETH() external onlyOwner {
        Address.sendValue(payable(msg.sender), address(this).balance);
    }

     // Registry Validated Transfers 
    function setApprovalForAll(address operator, bool approved) public override onlyAllowedOperatorApproval(operator) {
        super.setApprovalForAll(operator, approved);
    }

    function approve(address operator, uint256 tokenId) public override onlyAllowedOperatorApproval(operator) {
        super.approve(operator, tokenId);
    }


    function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data)
        public
        override
        onlyAllowedOperator(from)
    {
        super.safeTransferFrom(from, to, tokenId, data);
    }

}