{ "language": "Solidity", "sources": { "contracts/TwelveCubes.sol": { "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.13;\nimport \"operator-filter-registry/src/DefaultOperatorFilterer.sol\";\nimport '@openzeppelin/contracts/access/Ownable.sol';\nimport '@openzeppelin/contracts/security/ReentrancyGuard.sol';\nimport 'erc721a/contracts/extensions/ERC721AQueryable.sol';\n\ncontract TwelveCubes is ERC721A, Ownable, ReentrancyGuard, DefaultOperatorFilterer {\n using Strings for uint256;\n\n // Mint States\n bool public paused = true;\n bool public revealed = true;\n\n // Metadata\n string public prefixURI = 'ipfs://QmRSrhyvLFbru4R86ScDU94yyScga8XtjbFYH7p53wFftv/';\n string public fileFormat = '.json';\n \n // Mint Info\n uint256 public cost;\n uint256 public maxSupply;\n uint256 public freeRemaining = 400;\n uint256 public freePerTx = 1;\n uint256 public freePerWallet = 1;\n uint256 public maxMintAmountPerTx;\n\n // Wallet Constraints\n mapping(address => uint256) public walletLimits;\n\n constructor(\n string memory _tokenName,\n string memory _tokenSymbol,\n uint256 _cost,\n uint256 _maxSupply,\n uint256 _maxMintAmountPerTx\n ) ERC721A(_tokenName, _tokenSymbol) {\n setCost(_cost);\n maxSupply = _maxSupply;\n setMaxMintAmountPerTx(_maxMintAmountPerTx);\n }\n\n modifier mintCheck(uint256 _mintAmount) {\n require(_mintAmount > 0 && _mintAmount <= maxMintAmountPerTx, 'Invalid mint amount!');\n require(totalSupply() + _mintAmount <= maxSupply, 'Max supply exceeded!');\n\n if (msg.value < cost * _mintAmount) {\n require(freeRemaining > 0, \"Free supply is over\");\n require(_mintAmount < freePerTx + 1, 'You are minting too many free tokens per tx');\n require(walletLimits[msg.sender] + _mintAmount < freePerWallet + 1, 'You have minted your free token allocation');\n } else {\n require(msg.value >= cost * _mintAmount, 'Insufficient funds!');\n }\n _;\n }\n\n function mint(uint256 _mintAmount) public payable mintCheck(_mintAmount) {\n require(!paused, 'The contract is paused!');\n require(tx.origin == msg.sender, \"Contracts not allowed to mint.\");\n if (msg.value < cost * _mintAmount) {\n freeRemaining -= _mintAmount;\n walletLimits[msg.sender] += _mintAmount;\n }\n _safeMint(_msgSender(), _mintAmount);\n }\n\n function treasuryAllocate(uint quantity) public onlyOwner {\n require(quantity > 0, \"Wrong mint amount\");\n require(totalSupply() + quantity <= maxSupply, \"Max supply exceeded\");\n _safeMint(msg.sender, quantity);\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) {\n return _baseURI();\n }\n\n string memory currentBaseURI = _baseURI();\n return bytes(currentBaseURI).length > 0\n ? string(abi.encodePacked(currentBaseURI, _tokenId.toString(), fileFormat))\n : '';\n }\n\n function transferFrom(address from, address to, uint256 tokenId) public override onlyAllowedOperator(from) {\n super.transferFrom(from, to, tokenId);\n }\n\n function safeTransferFrom(address from, address to, uint256 tokenId) public override onlyAllowedOperator(from) {\n super.safeTransferFrom(from, to, tokenId);\n }\n\n function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) public override onlyAllowedOperator(from) {\n super.safeTransferFrom(from, to, tokenId, data);\n }\n\n function mintForPromise(uint256 _mintAmount, address _receiver) public onlyOwner {\n _safeMint(_receiver, _mintAmount);\n }\n\n function setCost(uint256 _cost) public onlyOwner {\n cost = _cost;\n }\n\n function setFree(uint256 _amount) public onlyOwner {\n freeRemaining = _amount;\n }\n\n function setfreePerWallet(uint256 _amount) public onlyOwner {\n freePerWallet = _amount;\n }\n\n function setfreePerTx(uint256 _amount) public onlyOwner {\n freePerTx = _amount;\n }\n\n function setMaxMintAmountPerTx(uint256 _maxMintAmountPerTx) public onlyOwner {\n maxMintAmountPerTx = _maxMintAmountPerTx;\n }\n\n function setprefixURI(string memory _prefixURI) public onlyOwner {\n prefixURI = _prefixURI;\n }\n\n function setfileFormat(string memory _fileFormat) public onlyOwner {\n fileFormat = _fileFormat;\n }\n\n function setPaused(bool _state) public onlyOwner {\n paused = _state;\n }\n\n function setRevealed(bool _state) public onlyOwner {\n revealed = _state;\n }\n\n function _baseURI() internal view virtual override returns (string memory) {\n return prefixURI;\n }\n\n function withdraw() public onlyOwner nonReentrant {\n (bool os, ) = payable(owner()).call{value: address(this).balance}('');\n require(os);\n }\n}" }, "operator-filter-registry/src/DefaultOperatorFilterer.sol": { "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\nimport {OperatorFilterer} from \"./OperatorFilterer.sol\";\n\n/**\n * @title DefaultOperatorFilterer\n * @notice Inherits from OperatorFilterer and automatically subscribes to the default OpenSea subscription.\n */\nabstract contract DefaultOperatorFilterer is OperatorFilterer {\n address constant DEFAULT_SUBSCRIPTION = address(0x3cc6CddA760b79bAfa08dF41ECFA224f810dCeB6);\n\n constructor() OperatorFilterer(DEFAULT_SUBSCRIPTION, true) {}\n}\n" }, "@openzeppelin/contracts/access/Ownable.sol": { "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the deployer as the initial owner.\n */\n constructor() {\n _transferOwnership(_msgSender());\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions anymore. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby removing any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n" }, "@openzeppelin/contracts/security/ReentrancyGuard.sol": { "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (security/ReentrancyGuard.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Contract module that helps prevent reentrant calls to a function.\n *\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\n * available, which can be applied to functions to make sure there are no nested\n * (reentrant) calls to them.\n *\n * Note that because there is a single `nonReentrant` guard, functions marked as\n * `nonReentrant` may not call one another. This can be worked around by making\n * those functions `private`, and then adding `external` `nonReentrant` entry\n * points to them.\n *\n * TIP: If you would like to learn more about reentrancy and alternative ways\n * to protect against it, check out our blog post\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\n */\nabstract contract ReentrancyGuard {\n // Booleans are more expensive than uint256 or any type that takes up a full\n // word because each write operation emits an extra SLOAD to first read the\n // slot's contents, replace the bits taken up by the boolean, and then write\n // back. This is the compiler's defense against contract upgrades and\n // pointer aliasing, and it cannot be disabled.\n\n // The values being non-zero value makes deployment a bit more expensive,\n // but in exchange the refund on every call to nonReentrant will be lower in\n // amount. Since refunds are capped to a percentage of the total\n // transaction's gas, it is best to keep them low in cases like this one, to\n // increase the likelihood of the full refund coming into effect.\n uint256 private constant _NOT_ENTERED = 1;\n uint256 private constant _ENTERED = 2;\n\n uint256 private _status;\n\n constructor() {\n _status = _NOT_ENTERED;\n }\n\n /**\n * @dev Prevents a contract from calling itself, directly or indirectly.\n * Calling a `nonReentrant` function from another `nonReentrant`\n * function is not supported. It is possible to prevent this from happening\n * by making the `nonReentrant` function external, and making it call a\n * `private` function that does the actual work.\n */\n modifier nonReentrant() {\n _nonReentrantBefore();\n _;\n _nonReentrantAfter();\n }\n\n function _nonReentrantBefore() private {\n // On the first call to nonReentrant, _status will be _NOT_ENTERED\n require(_status != _ENTERED, \"ReentrancyGuard: reentrant call\");\n\n // Any calls to nonReentrant after this point will fail\n _status = _ENTERED;\n }\n\n function _nonReentrantAfter() private {\n // By storing the original value once again, a refund is triggered (see\n // https://eips.ethereum.org/EIPS/eip-2200)\n _status = _NOT_ENTERED;\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` = `