{ "language": "Solidity", "sources": { "contracts/HalloweedNFT.sol": { "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.8.9 <0.9.0;\n\nimport 'erc721a/contracts/extensions/ERC721AQueryable.sol';\nimport '@openzeppelin/contracts/access/Ownable.sol';\nimport '@openzeppelin/contracts/utils/cryptography/MerkleProof.sol';\nimport '@openzeppelin/contracts/security/ReentrancyGuard.sol';\n\ncontract HalloweedNFT is ERC721AQueryable, Ownable, ReentrancyGuard {\n\n using Strings for uint256;\n\n bytes32 public merkleRoot;\n mapping(address => bool) public whitelistClaimed;\n\n string public uriPrefix = '';\n string public uriSuffix = '.json';\n string public hiddenMetadataUri;\n \n uint256 public cost;\n uint256 public maxSupply;\n uint256 public maxMintAmountPerTx;\n\n bool public paused = true;\n bool public whitelistMintEnabled = false;\n bool public revealed = false;\n\n constructor(\n string memory _tokenName,\n string memory _tokenSymbol,\n uint256 _cost,\n uint256 _maxSupply,\n uint256 _maxMintAmountPerTx,\n string memory _hiddenMetadataUri\n ) ERC721A(_tokenName, _tokenSymbol) {\n setCost(_cost);\n maxSupply = _maxSupply;\n setMaxMintAmountPerTx(_maxMintAmountPerTx);\n setHiddenMetadataUri(_hiddenMetadataUri);\n }\n\n modifier mintCompliance(uint256 _mintAmount) {\n require(_mintAmount > 0 && _mintAmount <= maxMintAmountPerTx, 'Invalid mint amount!');\n require(totalSupply() + _mintAmount <= maxSupply, 'Max supply exceeded!');\n _;\n }\n\n modifier mintPriceCompliance(uint256 _mintAmount) {\n require(msg.value >= cost * _mintAmount, 'Insufficient funds!');\n _;\n }\n\n function whitelistMint(uint256 _mintAmount, bytes32[] calldata _merkleProof) public payable mintCompliance(_mintAmount) mintPriceCompliance(_mintAmount) {\n // Verify whitelist requirements\n require(whitelistMintEnabled, 'The whitelist sale is not enabled!');\n require(!whitelistClaimed[_msgSender()], 'Address already claimed!');\n bytes32 leaf = keccak256(abi.encodePacked(_msgSender()));\n require(MerkleProof.verify(_merkleProof, merkleRoot, leaf), 'Invalid proof!');\n\n whitelistClaimed[_msgSender()] = true;\n _safeMint(_msgSender(), _mintAmount);\n }\n\n function mint(uint256 _mintAmount) public payable mintCompliance(_mintAmount) mintPriceCompliance(_mintAmount) {\n require(!paused, 'The contract is paused!');\n\n _safeMint(_msgSender(), _mintAmount);\n }\n \n function mintForAddress(uint256 _mintAmount, address _receiver) public mintCompliance(_mintAmount) onlyOwner {\n _safeMint(_receiver, _mintAmount);\n }\n\n function _startTokenId() internal view virtual override returns (uint256) {\n return 1;\n }\n\n function tokenURI(uint256 _tokenId) public view virtual override returns (string memory) {\n require(_exists(_tokenId), 'ERC721Metadata: URI query for nonexistent token');\n\n if (revealed == false) {\n return hiddenMetadataUri;\n }\n\n string memory currentBaseURI = _baseURI();\n return bytes(currentBaseURI).length > 0\n ? string(abi.encodePacked(currentBaseURI, _tokenId.toString(), uriSuffix))\n : '';\n }\n\n function setRevealed(bool _state) public onlyOwner {\n revealed = _state;\n }\n\n function setCost(uint256 _cost) public onlyOwner {\n cost = _cost;\n }\n\n function setMaxMintAmountPerTx(uint256 _maxMintAmountPerTx) public onlyOwner {\n maxMintAmountPerTx = _maxMintAmountPerTx;\n }\n\n function setHiddenMetadataUri(string memory _hiddenMetadataUri) public onlyOwner {\n hiddenMetadataUri = _hiddenMetadataUri;\n }\n\n function setUriPrefix(string memory _uriPrefix) public onlyOwner {\n uriPrefix = _uriPrefix;\n }\n\n function setUriSuffix(string memory _uriSuffix) public onlyOwner {\n uriSuffix = _uriSuffix;\n }\n\n function setPaused(bool _state) public onlyOwner {\n paused = _state;\n }\n\n function setMerkleRoot(bytes32 _merkleRoot) public onlyOwner {\n merkleRoot = _merkleRoot;\n }\n\n function setWhitelistMintEnabled(bool _state) public onlyOwner {\n whitelistMintEnabled = _state;\n }\n\n function withdraw() public onlyOwner nonReentrant {\n // This will transfer the remaining contract balance to the owner.\n // Do not remove this otherwise you will not be able to withdraw the funds.\n // =============================================================================\n (bool os, ) = payable(owner()).call{value: address(this).balance}('');\n require(os);\n // =============================================================================\n }\n\n function _baseURI() internal view virtual override returns (string memory) {\n return uriPrefix;\n }\n}\n" }, "erc721a/contracts/extensions/ERC721AQueryable.sol": { "content": "// SPDX-License-Identifier: MIT\n// ERC721A Contracts v3.3.0\n// Creator: Chiru Labs\n\npragma solidity ^0.8.4;\n\nimport './IERC721AQueryable.sol';\nimport '../ERC721A.sol';\n\n/**\n * @title ERC721A Queryable\n * @dev ERC721A subclass with convenience query functions.\n */\nabstract contract ERC721AQueryable is ERC721A, IERC721AQueryable {\n /**\n * @dev Returns the `TokenOwnership` struct at `tokenId` without reverting.\n *\n * If the `tokenId` is out of bounds:\n * - `addr` = `address(0)`\n * - `startTimestamp` = `0`\n * - `burned` = `false`\n *\n * If the `tokenId` is burned:\n * - `addr` = `
`\n * - `startTimestamp` = `