contract Ghostmice is ERC721, ERC721Enumerable, ERC721Burnable, Ownable {
    using Counters for Counters.Counter;
    using SafeMath for uint256;
    using Strings for uint256;

    Counters.Counter private _tokenIdCounter;

    string public baseURI;

    uint256 public constant MAX_PURCHASE = 20;

    uint256 public constant _price = 0.02 * 10**18;

    uint256 public maxSupply = 6444;

    bool public _saleIsActive = false;

    address creator = 0xf36C793240a57099CbA1a8F0bb83F3Ff8bF7F2c0; // Contract Creator

    constructor(string memory initialBaseURI) ERC721("Ghostmice", "GM") {
        baseURI = initialBaseURI;
    }

    function mintNFT(uint256 mintCount) public payable {
        require(_saleIsActive, "Sale is not Active");

        require(totalSupply() < maxSupply, "Sale has ended");

        require(mintCount > 0, "Cannot buy 0");

        require(
            mintCount <= MAX_PURCHASE,
            "You may not buy that many NFTs at once"
        );

        require(
            totalSupply().add(mintCount) <= maxSupply,
            "Exceeds max supply"
        );

        require(msg.value >= _price * mintCount, "Insufficent Payment Value");

        for (uint256 i = 0; i < mintCount; i++) {
            uint256 mintIndex = totalSupply();
            _safeMint(msg.sender, mintIndex);
        }
    }

    function withdrawAll() public payable {
        uint256 balance = address(this).balance;
        require(payable(creator).send(balance));
    }

    function tokenURI(uint256 tokenId)
        public
        view
        virtual
        override
        returns (string memory)
    {
        return string(abi.encodePacked(baseURI, tokenId.toString(), ".json"));
    }

    function updateBaseURI(string calldata newBaseURI) external onlyOwner {
        baseURI = newBaseURI;
    }

    // Start The Sale
    function saleStart() public onlyOwner {
        _saleIsActive = true;
    }

    // Pause the sale
    function saleStop() public onlyOwner {
        _saleIsActive = false;
    }

    function _beforeTokenTransfer(
        address from,
        address to,
        uint256 tokenId
    ) internal override(ERC721, ERC721Enumerable) {
        super._beforeTokenTransfer(from, to, tokenId);
    }

    function supportsInterface(bytes4 interfaceId)
        public
        view
        override(ERC721, ERC721Enumerable)
        returns (bool)
    {
        return super.supportsInterface(interfaceId);
    }
}
// 
function saleStart() public onlyOwner {
    _saleIsActive = true;
}

// Start The Sale