{ "language": "Solidity", "sources": { "/contracts/MiamiMetaCity.sol": { "content": "// SPDX-License-Identifier: MIT LICENSE\n\npragma solidity ^0.8.13;\n\nimport \"@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol\";\nimport \"@openzeppelin/contracts/security/Pausable.sol\";\nimport \"@openzeppelin/contracts/security/ReentrancyGuard.sol\";\nimport \"./utils/Helpers.sol\";\nimport \"./utils/Security.sol\";\nimport \"./Metacity.sol\";\nimport \"./CITY.sol\";\n\ncontract MiamiMetacity is Ownable, IERC721Receiver, Pausable, ReentrancyGuard, Security {\n\n // struct to store a stake's token, owner, and earning values\n struct Stake {\n uint16 tokenId;\n address owner;\n uint80 resetTime;\n uint256 earned;\n }\n\n event NFTStaked(address indexed owner, uint256 indexed tokenId);\n event NFTClaimed(uint256 indexed tokenId, uint256 earned, uint256 cityTax, uint256 ratTax);\n event RatAttacked(uint256 indexed tokenId, uint256 indexed zenTokenId, uint256 attackAmount, bool success);\n\n // reference to the Metacity NFT contract\n Metacity metacity;\n // reference to the $CITY contract for minting $CITY earnings\n CITY city;\n // city owner address\n address public cityOwnerAddress;\n // rats claim address\n address public ratsClaimAddress;\n // city zens\n uint16[] public cityZens;\n // num of city rats\n uint256 public numOfRats;\n // maps tokenId to a stake\n mapping(uint256 => Stake) private stakes;\n // tracks location of each tokenId in City\n mapping(uint256 => uint256) private cityIndexes;\n // maps tokenId to vacation until\n mapping(uint256 => uint256) public vacations;\n // maps tokenId to last action made\n mapping(uint256 => uint256) public ratActions;\n // counter\n uint256 private actionCounter = 0;\n // daily rate\n uint256 public DAILY_EARN_RATE = 100; // percentage\n // power gain rate\n uint256 public POWER_GAIN_RATE = 300; // percentage\n // power starting point\n uint256 public POWER_STARTING_POINT = 20; // percentage\n // vacation time\n uint256 public ZEN_VACATION_TIME = 48 hours; // hours\n // rat freeze time\n uint256 public RAT_FREEZE_TIME = 1 hours; // hours\n // city tax\n uint256 public CITY_TAX = 10; // percentage\n // rats tax\n uint256 public RATS_TAX = 30; // percentage\n // there will only ever be (roughly) 100 million $CITY earned through staking\n uint256 public MAXIMUM_CITY = 100_000_000 ether;\n\n // amount of $CITY earned so far\n uint256 public totalCityEarned;\n\n // emergency rescue to allow unstaking without any checks but without $CITY\n bool public rescueEnabled = false;\n\n /// @param _metacity reference to the Metacity NFT contract\n /// @param _city reference to the $CITY token\n constructor(address _metacity, address _city) { \n metacity = Metacity(_metacity);\n city = CITY(_city);\n }\n\n // STAKING\n\n /// @dev adds zens and rets to the MetaCity\n /// @param tokenIds the IDs of the zens to stake\n function addCityZensAndRats(uint16[] calldata tokenIds) external whenNotPaused nonReentrant isEOA {\n for (uint i = 0; i < tokenIds.length; i++) {\n // counter for randoms\n actionCounter++;\n require(metacity.ownerOf(tokenIds[i]) == _msgSender(), \"Not the owner\");\n require(vacations[tokenIds[i]] < block.timestamp, \"On vacation\");\n require(ratActions[tokenIds[i]] < block.timestamp, \"Too soon\");\n metacity.transferFrom(_msgSender(), address(this), tokenIds[i]);\n stakes[tokenIds[i]] = Stake({\n owner: _msgSender(),\n tokenId: uint16(tokenIds[i]),\n resetTime: uint80(block.timestamp),\n earned: 0\n });\n if (metacity.isZen(tokenIds[i])) {\n cityZens.push(uint16(tokenIds[i]));\n cityIndexes[tokenIds[i]] = cityZens.length - 1;\n } else {\n ratActions[tokenIds[i]] = block.timestamp + RAT_FREEZE_TIME;\n numOfRats++;\n }\n emit NFTStaked(_msgSender(), tokenIds[i]);\n }\n }\n\n // ATTACK\n\n /// @dev Rat attacks the MetaCity\n /// @param tokenId the ID of the Rat on the MetaCity\n function ratAttack(uint256 tokenId) external whenNotPaused nonReentrant isEOA {\n require(stakes[tokenId].owner == _msgSender(), \"Not the owner\");\n require(ratActions[tokenId] < block.timestamp, \"Too soon\");\n require(!metacity.isZen(tokenId), \"Only rats can attack\");\n // counter for randoms\n actionCounter++;\n // get rat info\n uint256 _ratPower = ratPower(tokenId);\n // generate random number\n uint256 seed = Helpers.random(actionCounter);\n // check rat attack\n bool successfullyAttacked = (seed % 100) <= _ratPower;\n // anyway choose the zen to attack\n seed >>= 16;\n uint256 zenIndex = seed % cityZens.length;\n uint16 zenTokenId = cityZens[zenIndex];\n uint256 _zenEarned = earned(zenTokenId);\n // update rat next action\n ratActions[tokenId] = block.timestamp + RAT_FREEZE_TIME;\n // reset the rat reset time to now (rat power back to starting point)\n stakes[tokenId].resetTime = uint80(block.timestamp);\n // update zen and rat earnings\n if (successfullyAttacked) {\n // remove zen earnings\n stakes[zenTokenId].resetTime = uint80(block.timestamp);\n // pay the rat\n stakes[tokenId].earned += _zenEarned;\n } else { // just to keep the same gas cost\n // remove zen earnings (not really)\n stakes[zenTokenId].resetTime = stakes[zenTokenId].resetTime;\n // pay the rat (not really)\n stakes[tokenId].earned += 0;\n }\n emit RatAttacked(tokenId, zenTokenId, _zenEarned, successfullyAttacked);\n }\n\n // CLAIMING / UNSTAKING\n\n /// @dev unstake zens and rets to the MetaCity\n /// @param tokenIds the IDs of the zens to unstake\n function vacationCityZensAndRats(uint16[] calldata tokenIds) external whenNotPaused nonReentrant isEOA {\n // total for all tokens\n uint256 _earned = 0;\n uint256 _cityTax = 0;\n uint256 _ratTax = 0;\n // loop tokens\n for (uint i = 0; i < tokenIds.length; i++) {\n // counter for randoms\n actionCounter++;\n Stake memory stake = stakes[tokenIds[i]];\n require(stake.owner == _msgSender(), \"Metacity was not staked by user\");\n // token stake values\n uint256 tokenEarned = 0;\n uint256 tokenCityTax = 0;\n uint256 tokenRatTax = 0;\n // check CITY left\n if (totalCityEarned < MAXIMUM_CITY) {\n tokenEarned = earned(tokenIds[i]);\n if (tokenEarned > MAXIMUM_CITY - totalCityEarned) {\n // not enough $CITY\n tokenEarned = MAXIMUM_CITY - totalCityEarned;\n }\n totalCityEarned += tokenEarned;\n }\n if (metacity.isZen(tokenIds[i])) {\n vacations[tokenIds[i]] = block.timestamp + ZEN_VACATION_TIME;\n _removeZenFromCity(stake);\n // pay taxes\n tokenCityTax = tokenEarned * CITY_TAX / 100;\n tokenRatTax = tokenEarned * RATS_TAX / 100;\n tokenEarned = tokenEarned - tokenCityTax - tokenRatTax;\n } else {\n require(ratActions[tokenIds[i]] < block.timestamp, \"Too soon\");\n ratActions[tokenIds[i]] = block.timestamp + RAT_FREEZE_TIME;\n numOfRats--;\n }\n \n delete stakes[tokenIds[i]];\n\n metacity.safeTransferFrom(address(this), _msgSender(), tokenIds[i]);\n\n _earned += tokenEarned;\n _cityTax += tokenCityTax;\n _ratTax += tokenRatTax;\n\n emit NFTClaimed(tokenIds[i], tokenEarned, tokenCityTax, tokenRatTax);\n }\n if (_earned > 0) {\n city.mint(_msgSender(), _earned);\n }\n // TAX AND RAT TAX\n if (_cityTax > 0) {\n city.mint(cityOwnerAddress, _cityTax);\n }\n if (_ratTax > 0) {\n city.mint(ratsClaimAddress, _ratTax);\n }\n }\n\n /// @dev earnings\n /// @param tokenId the ID of the nft on the MetaCity\n /// @return earned amount earned so far\n function earned(uint256 tokenId) public view returns(uint256) {\n Stake memory _stake = stakes[tokenId];\n require(block.timestamp > _stake.resetTime, \"Can't get earnings on the attacking / staking block\");\n if (_stake.tokenId != tokenId) {\n return 0;\n }\n return metacity.isZen(tokenId) ? metacity.level(tokenId) * DAILY_EARN_RATE * 1e18 * (block.timestamp - _stake.resetTime) / 86400 / 100 : stakes[tokenId].earned;\n }\n\n /// @dev rat power\n /// @param tokenId the ID of the rat on the MetaCity\n /// @return power amount of power gained so far\n function ratPower(uint256 tokenId) public view returns(uint256) {\n require(!metacity.isZen(tokenId), \"Only rats have power\");\n Stake memory _stake = stakes[tokenId];\n if (_stake.tokenId != tokenId) {\n return 0;\n }\n uint256 power = POWER_STARTING_POINT + metacity.level(tokenId) * POWER_GAIN_RATE * (block.timestamp - _stake.resetTime) / 86400 / 100;\n return power > 100 ? 100 : power;\n }\n\n /// @dev Unstake without earnings\n /// @param tokenIds the IDs of the zens to unstake\n function rescue(uint16[] calldata tokenIds) external whenPaused nonReentrant isEOA {\n require(rescueEnabled, \"rescue is not enabled\");\n for (uint i = 0; i < tokenIds.length; i++) {\n Stake memory stake = stakes[tokenIds[i]];\n require(stake.owner == _msgSender(), \"Metacity was not staked by user\");\n delete stakes[tokenIds[i]];\n delete cityIndexes[tokenIds[i]];\n\n metacity.safeTransferFrom(address(this), _msgSender(), tokenIds[i]);\n }\n }\n\n /// @dev remove from stakes array\n /// @param stake current tokenId stake\n function _removeZenFromCity(Stake memory stake) internal {\n uint256 lastTokenId = cityZens[cityZens.length - 1];\n cityZens[cityIndexes[stake.tokenId]] = uint16(lastTokenId); // Shuffle last tokenId to current position\n cityIndexes[lastTokenId] = cityIndexes[stake.tokenId];\n delete cityIndexes[stake.tokenId];\n cityZens.pop(); // Remove duplicate\n }\n\n /** ADMIN */\n\n /// @dev sets the city owner address\n /// @param _cityOwnerAddress address if the city owner\n function setCityOwnerAddress(address _cityOwnerAddress) external onlyOwner {\n cityOwnerAddress = _cityOwnerAddress;\n }\n\n /// @dev sets the rats claim address\n /// @param _ratsClaimAddress address if the city owner\n function setRatsClaimAddress(address _ratsClaimAddress) external onlyOwner {\n ratsClaimAddress = _ratsClaimAddress;\n }\n\n /// @dev allows owner to enable \"rescue mode\"\n /// @param _enabled boolean\n function setRescueEnabled(bool _enabled) external onlyOwner {\n rescueEnabled = _enabled;\n }\n\n /// @dev enables owner to pause / unpause minting\n /// @param _paused boolean\n function setPaused(bool _paused) external onlyOwner {\n if (_paused) _pause();\n else _unpause();\n }\n\n function setCityParams(\n uint256 dailyEarnRate,\n uint256 powerGainRate,\n uint256 powerStartingPoint,\n uint256 zenVacationTime,\n uint256 ratFreezeTime,\n uint256 cityTax,\n uint256 ratsTax,\n uint256 maximumCity\n ) external onlyOwner {\n DAILY_EARN_RATE = dailyEarnRate;\n POWER_GAIN_RATE = powerGainRate;\n POWER_STARTING_POINT = powerStartingPoint;\n ZEN_VACATION_TIME = zenVacationTime;\n RAT_FREEZE_TIME = ratFreezeTime; // hours\n CITY_TAX = cityTax;\n RATS_TAX = ratsTax; // percentage\n MAXIMUM_CITY = maximumCity;\n }\n\n function onERC721Received(\n address,\n address from,\n uint256,\n bytes calldata\n ) external pure override returns (bytes4) {\n require(from == address(0x0), \"Cannot send tokens to MetaCity directly\");\n return IERC721Receiver.onERC721Received.selector;\n }\n\n \n}" }, "/contracts/utils/Security.sol": { "content": "// SPDX-License-Identifier: MIT LICENSE\n\npragma solidity ^0.8.13;\n\nimport \"@openzeppelin/contracts/utils/Address.sol\";\n\ncontract Security {\n /// @dev Check if caller is a wallet\n modifier isEOA() {\n require(!(Address.isContract(msg.sender)) && tx.origin == msg.sender, \"Only EOA\");\n _;\n }\n}" }, "/contracts/utils/Helpers.sol": { "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\nlibrary Helpers {\n /// @dev generates a pseudorandom number\n /// @param seed a value ensure different outcomes for different sources in the same block\n /// @return a pseudorandom value\n function random(uint256 seed) internal view returns (uint256) {\n return uint256(keccak256(abi.encodePacked(\n tx.origin,\n blockhash(block.number - 1),\n block.difficulty,\n block.timestamp,\n seed\n )));\n }\n\n string internal constant TABLE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\n\n function base64(bytes memory data) internal pure returns (string memory) {\n if (data.length == 0) return '';\n \n // load the table into memory\n string memory table = TABLE;\n\n // multiply by 4/3 rounded up\n uint256 encodedLen = 4 * ((data.length + 2) / 3);\n\n // add some extra buffer at the end required for the writing\n string memory result = new string(encodedLen + 32);\n\n assembly {\n // set the actual output length\n mstore(result, encodedLen)\n \n // prepare the lookup table\n let tablePtr := add(table, 1)\n \n // input ptr\n let dataPtr := data\n let endPtr := add(dataPtr, mload(data))\n \n // result ptr, jump over length\n let resultPtr := add(result, 32)\n \n // run over the input, 3 bytes at a time\n for {} lt(dataPtr, endPtr) {}\n {\n dataPtr := add(dataPtr, 3)\n \n // read 3 bytes\n let input := mload(dataPtr)\n \n // write 4 characters\n mstore(resultPtr, shl(248, mload(add(tablePtr, and(shr(18, input), 0x3F)))))\n resultPtr := add(resultPtr, 1)\n mstore(resultPtr, shl(248, mload(add(tablePtr, and(shr(12, input), 0x3F)))))\n resultPtr := add(resultPtr, 1)\n mstore(resultPtr, shl(248, mload(add(tablePtr, and(shr( 6, input), 0x3F)))))\n resultPtr := add(resultPtr, 1)\n mstore(resultPtr, shl(248, mload(add(tablePtr, and( input, 0x3F)))))\n resultPtr := add(resultPtr, 1)\n }\n \n // padding with '='\n switch mod(mload(data), 3)\n case 1 { mstore(sub(resultPtr, 2), shl(240, 0x3d3d)) }\n case 2 { mstore(sub(resultPtr, 1), shl(248, 0x3d)) }\n }\n \n return result;\n }\n\n}\n" }, "/contracts/Metacity.sol": { "content": "// SPDX-License-Identifier: MIT LICENSE\n\npragma solidity ^0.8.13;\n\nimport \"@openzeppelin/contracts/utils/Address.sol\";\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\nimport \"@openzeppelin/contracts/security/Pausable.sol\";\nimport \"@openzeppelin/contracts/security/ReentrancyGuard.sol\";\nimport \"@openzeppelin/contracts/utils/cryptography/ECDSA.sol\";\nimport \"./ERC721Opensea.sol\";\nimport \"./utils/Helpers.sol\";\nimport \"./utils/Security.sol\";\nimport \"./Interfaces/IMetacity.sol\";\nimport \"./Interfaces/ITraits.sol\";\nimport \"./CITY.sol\";\n\n\ncontract Metacity is IMetacity, ERC721Opensea, Ownable, Pausable, ReentrancyGuard, Security {\n\n using ECDSA for bytes32;\n\n uint256 public startTime = 1669053600; // Monday, November 21, 2022 18:00:00\n\n // first round\n uint256 public constant firstRoundSupply = 5000;\n uint256 public constant firstRoundPrice = 0.02 ether; // ETH\n uint256 public constant firstRoundMaxWlPerUser = 3;\n // second round\n uint256 public constant secondRoundSupply = 800;\n uint256 public secondRoundPrice = 1 ether; // ETH\n // third round\n uint256 public thirdRoundPrice = 500 ether; // CITY\n\n uint256 public constant ratChance = 10; // percentage\n\n uint256 public maxSupply = 15_800;\n\n // open / close rounds\n bool public firstRoundOpen = true;\n bool public secondRoundOpen = false;\n bool public thirdRoundOpen = false;\n // wl\n bool public wlOnly = true;\n\n // saving for max per round\n mapping(address => uint256) public firstRoundWlMints;\n mapping(address => bool) public secondRoundMinted;\n\n // number of tokens that have been minted\n uint16 public totalSupply;\n // mapping from tokenId to an array containing the token's traits\n mapping(uint256 => uint256[]) private tokenTraits;\n // mapping from tokenId to bool isZen\n mapping(uint256 => bool) private isZens;\n // mapping from hashed(tokenTrait) to the tokenId it's associated with\n // used to ensure there are no duplicates\n mapping(uint256 => uint256) public existingCombinations;\n // mint block per token id\n mapping(uint256 => uint256) public mintBlocks;\n // allowed to add traits after mint in game / shop\n mapping(address => bool) public controllers;\n // allowed to sign whitelist addresses\n mapping(address => bool) private signers;\n // reference to $CITY for mint\n CITY public city;\n // reference to Traits\n ITraits public traits;\n\n /// @dev instantiates contract and rarity tables\n constructor(address _city, address _traits) ERC721Opensea(\"MetaCity\", 'METACITY') { \n city = CITY(_city);\n traits = ITraits(_traits);\n }\n\n /** EXTERNAL */\n\n function mintGen0(uint256 amount, bytes memory sig) external payable nonReentrant whenNotPaused {\n require(block.timestamp >= startTime, \"Sale haven't started yet\");\n require(firstRoundOpen, \"Round is closed\");\n require(amount > 0 && totalSupply + amount <= firstRoundSupply, \"Round ended\");\n require(amount * firstRoundPrice == msg.value, \"Invalid payment amount\");\n if (wlOnly) {\n require(isWhitelisted(_msgSender(), sig), \"Address is not whitelisted\");\n require(amount + firstRoundWlMints[_msgSender()] <= firstRoundMaxWlPerUser, \"Invalid mint amount\"); // max per mint\n firstRoundWlMints[_msgSender()] += amount;\n }\n\n _mint(amount, ratChance);\n }\n\n function mintGen1(bytes memory sig) external payable nonReentrant whenNotPaused {\n require(totalSupply >= firstRoundSupply, \"Round not started yet\");\n require(secondRoundOpen, \"Round is closed\");\n require(totalSupply + 1 <= (firstRoundSupply + secondRoundSupply), \"Round ended\");\n require(secondRoundPrice == msg.value, \"Invalid payment amount\");\n require(!secondRoundMinted[_msgSender()], \"Already minted\");\n if (wlOnly) {\n require(isWhitelisted(_msgSender(), sig), \"Address is not whitelisted\");\n }\n secondRoundMinted[_msgSender()] = true;\n\n _mint(1, 100);\n }\n\n function mintGen2(uint256 amount) external nonReentrant whenNotPaused {\n require(thirdRoundOpen, \"Round is closed\");\n require(totalSupply >= (firstRoundSupply + secondRoundSupply), \"Round not started yet\");\n require(amount > 0 && totalSupply + amount <= maxSupply, \"Round ended\");\n\n // payment\n uint256 totalCityCost = amount * thirdRoundPrice;\n city.transferFrom(_msgSender(), address(this), totalCityCost);\n\n _mint(amount, ratChance);\n }\n\n function _mint(uint256 amount, uint256 _ratChance) internal {\n uint256 seed;\n for (uint i = 0; i < amount; i++) {\n totalSupply++;\n seed = Helpers.random(totalSupply);\n bool _isZen = (seed & 0xFFFF) % 100 >= _ratChance; // % getting a rat\n generate(totalSupply, seed, _isZen);\n mintBlocks[totalSupply] = block.number;\n _safeMint(_msgSender(), totalSupply);\n }\n }\n\n /** INTERNAL */\n\n /**\n * generates traits for a specific token, checking to make sure it's unique\n * @param tokenId the id of the token to generate traits for\n * @param seed a pseudorandom 256 bit number to derive traits from\n */\n function generate(uint256 tokenId, uint256 seed, bool _isZen) internal {\n uint256[] memory t = traits.selectTraits(seed, _isZen);\n isZens[tokenId] = _isZen;\n if (_isZen) { // zens are unique\n uint256 traitsHash = uint256(keccak256(abi.encodePacked(t)));\n if (existingCombinations[traitsHash] == 0) {\n tokenTraits[tokenId] = t;\n existingCombinations[traitsHash] = tokenId;\n return;\n } else {\n return generate(tokenId, Helpers.random(seed), _isZen);\n }\n } else {\n tokenTraits[tokenId] = t;\n return;\n }\n }\n\n function setTrait(uint256 tokenId, uint256 traitIdx, uint256 traitValue) external {\n require(controllers[_msgSender()], \"Only controllers can add traits\");\n require(tokenTraits[tokenId].length >= traitIdx, \"Trait index invalid\");\n\n if (tokenTraits[tokenId].length == traitIdx) { // new trait\n tokenTraits[tokenId].push(traitValue);\n } else { // edit trait\n tokenTraits[tokenId][traitIdx] = traitValue;\n }\n }\n\n function getTokenTraits(uint256 tokenId) external view override returns (uint256[] memory) {\n require(mintBlocks[tokenId] < block.number, \"Reavel only the next block\");\n return tokenTraits[tokenId];\n }\n\n function tokenURI(uint256 tokenId) public view override returns (string memory) {\n require(_exists(tokenId), \"ERC721Metadata: URI query for nonexistent token\");\n require(mintBlocks[tokenId] < block.number, \"Reavel only the next block\");\n return traits.tokenURI(tokenId);\n }\n\n function level(uint256 tokenId) public view returns (uint256) {\n require(_exists(tokenId), \"Query for nonexistent token\");\n require(mintBlocks[tokenId] < block.number, \"Reavel only the next block\");\n return traits.level(tokenId);\n }\n\n function isZen(uint256 tokenId) public view override returns (bool) {\n require(_exists(tokenId), \"Query for nonexistent token\");\n require(mintBlocks[tokenId] < block.number, \"Reavel only the next block\");\n return isZens[tokenId];\n }\n\n /// @dev check if an address was off chain whitelisted\n /// @param account the address to check\n /// @return isValid boolean\n function isWhitelisted(address account, bytes memory sig) public view returns (bool isValid) {\n return signers[keccak256(abi.encodePacked(account)).toEthSignedMessageHash().recover(sig)];\n }\n\n /** ADMIN */\n /**\n * @param _traits the address of the Traits\n */\n function setTraits(address _traits) external onlyOwner {\n traits = ITraits(_traits);\n }\n\n /**\n * allows owner to withdraw funds from minting\n */\n function withdraw(address token) external onlyOwner {\n if (token == address(0))\n payable(owner()).transfer(address(this).balance);\n else\n CITY(token).transfer(owner(), CITY(token).balanceOf(address(this)));\n }\n\n /**\n * enables owner to pause / unpause minting\n */\n function setPaused(bool _paused) external onlyOwner {\n if (_paused) _pause();\n else _unpause();\n }\n\n /// @dev // add list of addresses that can sign\n /// @param accounts list of addresses\n function addSigners(address[] memory accounts) external onlyOwner {\n for (uint i = 0; i < accounts.length; i++) {\n if (accounts[i] != address(0)) {\n signers[accounts[i]] = true;\n }\n }\n }\n\n /// @dev // remove address that can sign\n /// @param account address to remove from signers\n function removeSigner(address account) external onlyOwner {\n signers[account] = false;\n }\n\n /**\n * enables an address to mint / burn\n * @param controller the address to enable\n */\n function addController(address controller) external onlyOwner {\n controllers[controller] = true;\n }\n\n /**\n * disables an address from minting / burning\n * @param controller the address to disbale\n */\n function removeController(address controller) external onlyOwner {\n controllers[controller] = false;\n }\n\n function setFirstRoundOpen(bool _isOpen) external onlyOwner {\n firstRoundOpen = _isOpen;\n }\n\n function setSecondRoundOpen(bool _isOpen) external onlyOwner {\n secondRoundOpen = _isOpen;\n }\n\n function setThirdRoundOpen(bool _isOpen) external onlyOwner {\n thirdRoundOpen = _isOpen;\n }\n\n function setWlOnly(bool _wlOnly) external onlyOwner {\n wlOnly = _wlOnly;\n }\n\n function setStartTime(uint256 _startTime) external onlyOwner {\n startTime = _startTime;\n }\n\n function setSecondRoundPrice(uint256 _secondRoundPrice) external onlyOwner {\n secondRoundPrice = _secondRoundPrice;\n }\n\n function setThirdRoundPrice(uint256 _thirdRoundPrice) external onlyOwner {\n thirdRoundPrice = _thirdRoundPrice;\n }\n\n function setMaxSupply(uint256 _maxSupply) external onlyOwner {\n require(_maxSupply < maxSupply, \"max supply can only be reduced\");\n maxSupply = _maxSupply;\n }\n}" }, "/contracts/Interfaces/ITraits.sol": { "content": "// SPDX-License-Identifier: MIT LICENSE \n\npragma solidity ^0.8.13;\n\ninterface ITraits {\n function selectTraits(uint256 seed, bool _isZen) external view returns (uint256[] memory t);\n function tokenURI(uint256 tokenId) external view returns (string memory);\n function level(uint256 tokenId) external view returns (uint256);\n}" }, "/contracts/Interfaces/IMetacity.sol": { "content": "// SPDX-License-Identifier: MIT LICENSE\n\npragma solidity ^0.8.13;\n\ninterface IMetacity {\n function getTokenTraits(uint256 tokenId) external view returns (uint256[] memory);\n function isZen(uint256 tokenId) external view returns (bool);\n}" }, "/contracts/ERC721Opensea.sol": { "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\nimport \"@openzeppelin/contracts/token/ERC721/ERC721.sol\";\nimport \"operator-filter-registry/src/DefaultOperatorFilterer.sol\";\n\n/**\n * @title ExampleERC721\n * @notice This example contract is configured to use the DefaultOperatorFilterer, which automatically registers the\n * token and subscribes it to OpenSea's curated filters.\n * Adding the onlyAllowedOperator modifier to the transferFrom and both safeTransferFrom methods ensures that\n * the msg.sender (operator) is allowed by the OperatorFilterRegistry. Adding the onlyAllowedOperatorApproval\n * modifier to the approval methods ensures that owners do not approve operators that are not allowed.\n */\nabstract contract ERC721Opensea is ERC721, DefaultOperatorFilterer {\n constructor(string memory _name, string memory _symbol) ERC721(_name, _symbol) {}\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)\n public\n override\n onlyAllowedOperator(from)\n {\n super.safeTransferFrom(from, to, tokenId, data);\n }\n}\n" }, "/contracts/CITY.sol": { "content": "// SPDX-License-Identifier: MIT LICENSE\n\npragma solidity ^0.8.13;\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\n\ncontract CITY is ERC20, Ownable {\n\n uint256 public constant MAXIMUM_SUPPLY = 1000000000 ether;\n mapping(address => bool) minters;\n \n constructor() ERC20(\"MetaCity\", \"CITY\") { }\n\n /**\n * mints $CITY to a recipient\n * @param to the recipient of the $CITY\n * @param amount the amount of $CITY to mint\n */\n function mint(address to, uint256 amount) external {\n require(minters[msg.sender], \"Only minters can mint\");\n require(totalSupply() + amount <= MAXIMUM_SUPPLY, \"Can't go above Max supply\");\n _mint(to, amount);\n }\n\n /**\n * enables an address to mint / burn\n * @param minter the address to enable\n */\n function addMinter(address minter) external onlyOwner {\n minters[minter] = true;\n }\n\n /**\n * disables an address from minting / burning\n * @param minter the address to disbale\n */\n function removeMinter(address minter) external onlyOwner {\n minters[minter] = false;\n }\n}" }, "operator-filter-registry/src/OperatorFilterer.sol": { "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\nimport {IOperatorFilterRegistry} from \"./IOperatorFilterRegistry.sol\";\n\nabstract contract OperatorFilterer {\n error OperatorNotAllowed(address operator);\n\n IOperatorFilterRegistry constant operatorFilterRegistry =\n IOperatorFilterRegistry(0x000000000000AAeB6D7670E522A718067333cd4E);\n\n constructor(address subscriptionOrRegistrantToCopy, bool subscribe) {\n // If an inheriting token contract is deployed to a network without the registry deployed, the modifier\n // will not revert, but the contract will need to be registered with the registry once it is deployed in\n // order for the modifier to filter addresses.\n if (address(operatorFilterRegistry).code.length > 0) {\n if (subscribe) {\n operatorFilterRegistry.registerAndSubscribe(address(this), subscriptionOrRegistrantToCopy);\n } else {\n if (subscriptionOrRegistrantToCopy != address(0)) {\n operatorFilterRegistry.registerAndCopyEntries(address(this), subscriptionOrRegistrantToCopy);\n } else {\n operatorFilterRegistry.register(address(this));\n }\n }\n }\n }\n\n modifier onlyAllowedOperator(address from) virtual {\n // Check registry code length to facilitate testing in environments without a deployed registry.\n if (address(operatorFilterRegistry).code.length > 0) {\n // Allow spending tokens from addresses with balance\n // Note that this still allows listings and marketplaces with escrow to transfer tokens if transferred\n // from an EOA.\n if (from == msg.sender) {\n _;\n return;\n }\n if (\n !(\n operatorFilterRegistry.isOperatorAllowed(address(this), msg.sender)\n && operatorFilterRegistry.isOperatorAllowed(address(this), from)\n )\n ) {\n revert OperatorNotAllowed(msg.sender);\n }\n }\n _;\n }\n}\n" }, "operator-filter-registry/src/IOperatorFilterRegistry.sol": { "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\ninterface IOperatorFilterRegistry {\n function isOperatorAllowed(address registrant, address operator) external view returns (bool);\n function register(address registrant) external;\n function registerAndSubscribe(address registrant, address subscription) external;\n function registerAndCopyEntries(address registrant, address registrantToCopy) external;\n function updateOperator(address registrant, address operator, bool filtered) external;\n function updateOperators(address registrant, address[] calldata operators, bool filtered) external;\n function updateCodeHash(address registrant, bytes32 codehash, bool filtered) external;\n function updateCodeHashes(address registrant, bytes32[] calldata codeHashes, bool filtered) external;\n function subscribe(address registrant, address registrantToSubscribe) external;\n function unsubscribe(address registrant, bool copyExistingEntries) external;\n function subscriptionOf(address addr) external returns (address registrant);\n function subscribers(address registrant) external returns (address[] memory);\n function subscriberAt(address registrant, uint256 index) external returns (address);\n function copyEntriesOf(address registrant, address registrantToCopy) external;\n function isOperatorFiltered(address registrant, address operator) external returns (bool);\n function isCodeHashOfFiltered(address registrant, address operatorWithCode) external returns (bool);\n function isCodeHashFiltered(address registrant, bytes32 codeHash) external returns (bool);\n function filteredOperators(address addr) external returns (address[] memory);\n function filteredCodeHashes(address addr) external returns (bytes32[] memory);\n function filteredOperatorAt(address registrant, uint256 index) external returns (address);\n function filteredCodeHashAt(address registrant, uint256 index) external returns (bytes32);\n function isRegistered(address addr) external returns (bool);\n function codeHashOf(address addr) external returns (bytes32);\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\nabstract contract DefaultOperatorFilterer is OperatorFilterer {\n address constant DEFAULT_SUBSCRIPTION = address(0x3cc6CddA760b79bAfa08dF41ECFA224f810dCeB6);\n\n constructor() OperatorFilterer(DEFAULT_SUBSCRIPTION, true) {}\n}\n" }, "@openzeppelin/contracts/utils/introspection/IERC165.sol": { "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n" }, "@openzeppelin/contracts/utils/introspection/ERC165.sol": { "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165.sol\";\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n *\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n" }, "@openzeppelin/contracts/utils/cryptography/ECDSA.sol": { "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.3) (utils/cryptography/ECDSA.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../Strings.sol\";\n\n/**\n * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.\n *\n * These functions can be used to verify that a message was signed by the holder\n * of the private keys of a given address.\n */\nlibrary ECDSA {\n enum RecoverError {\n NoError,\n InvalidSignature,\n InvalidSignatureLength,\n InvalidSignatureS,\n InvalidSignatureV\n }\n\n function _throwError(RecoverError error) private pure {\n if (error == RecoverError.NoError) {\n return; // no error: do nothing\n } else if (error == RecoverError.InvalidSignature) {\n revert(\"ECDSA: invalid signature\");\n } else if (error == RecoverError.InvalidSignatureLength) {\n revert(\"ECDSA: invalid signature length\");\n } else if (error == RecoverError.InvalidSignatureS) {\n revert(\"ECDSA: invalid signature 's' value\");\n } else if (error == RecoverError.InvalidSignatureV) {\n revert(\"ECDSA: invalid signature 'v' value\");\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature` or error string. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {toEthSignedMessageHash} on it.\n *\n * Documentation for signature generation:\n * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]\n * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]\n *\n * _Available since v4.3._\n */\n function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {\n if (signature.length == 65) {\n bytes32 r;\n bytes32 s;\n uint8 v;\n // ecrecover takes the signature parameters, and the only way to get them\n // currently is to use assembly.\n /// @solidity memory-safe-assembly\n assembly {\n r := mload(add(signature, 0x20))\n s := mload(add(signature, 0x40))\n v := byte(0, mload(add(signature, 0x60)))\n }\n return tryRecover(hash, v, r, s);\n } else {\n return (address(0), RecoverError.InvalidSignatureLength);\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature`. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {toEthSignedMessageHash} on it.\n */\n function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, signature);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.\n *\n * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]\n *\n * _Available since v4.3._\n */\n function tryRecover(\n bytes32 hash,\n bytes32 r,\n bytes32 vs\n ) internal pure returns (address, RecoverError) {\n bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);\n uint8 v = uint8((uint256(vs) >> 255) + 27);\n return tryRecover(hash, v, r, s);\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.\n *\n * _Available since v4.2._\n */\n function recover(\n bytes32 hash,\n bytes32 r,\n bytes32 vs\n ) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, r, vs);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `v`,\n * `r` and `s` signature fields separately.\n *\n * _Available since v4.3._\n */\n function tryRecover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal pure returns (address, RecoverError) {\n // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\n // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\n // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most\n // signatures from current libraries generate a unique signature with an s-value in the lower half order.\n //\n // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value\n // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or\n // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept\n // these malleable signatures as well.\n if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\n return (address(0), RecoverError.InvalidSignatureS);\n }\n if (v != 27 && v != 28) {\n return (address(0), RecoverError.InvalidSignatureV);\n }\n\n // If the signature is valid (and not malleable), return the signer address\n address signer = ecrecover(hash, v, r, s);\n if (signer == address(0)) {\n return (address(0), RecoverError.InvalidSignature);\n }\n\n return (signer, RecoverError.NoError);\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `v`,\n * `r` and `s` signature fields separately.\n */\n function recover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, v, r, s);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Returns an Ethereum Signed Message, created from a `hash`. This\n * produces hash corresponding to the one signed with the\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n * JSON-RPC method as part of EIP-191.\n *\n * See {recover}.\n */\n function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {\n // 32 is the length in bytes of hash,\n // enforced by the type signature above\n return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n32\", hash));\n }\n\n /**\n * @dev Returns an Ethereum Signed Message, created from `s`. This\n * produces hash corresponding to the one signed with the\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n * JSON-RPC method as part of EIP-191.\n *\n * See {recover}.\n */\n function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n\", Strings.toString(s.length), s));\n }\n\n /**\n * @dev Returns an Ethereum Signed Typed Data, created from a\n * `domainSeparator` and a `structHash`. This produces hash corresponding\n * to the one signed with the\n * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]\n * JSON-RPC method as part of EIP-712.\n *\n * See {recover}.\n */\n function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(\"\\x19\\x01\", domainSeparator, structHash));\n }\n}\n" }, "@openzeppelin/contracts/utils/Strings.sol": { "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev String operations.\n */\nlibrary Strings {\n bytes16 private constant _HEX_SYMBOLS = \"0123456789abcdef\";\n uint8 private constant _ADDRESS_LENGTH = 20;\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n */\n function toString(uint256 value) internal pure returns (string memory) {\n // Inspired by OraclizeAPI's implementation - MIT licence\n // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\n\n if (value == 0) {\n return \"0\";\n }\n uint256 temp = value;\n uint256 digits;\n while (temp != 0) {\n digits++;\n temp /= 10;\n }\n bytes memory buffer = new bytes(digits);\n while (value != 0) {\n digits -= 1;\n buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\n value /= 10;\n }\n return string(buffer);\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n */\n function toHexString(uint256 value) internal pure returns (string memory) {\n if (value == 0) {\n return \"0x00\";\n }\n uint256 temp = value;\n uint256 length = 0;\n while (temp != 0) {\n length++;\n temp >>= 8;\n }\n return toHexString(value, length);\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n */\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n bytes memory buffer = new bytes(2 * length + 2);\n buffer[0] = \"0\";\n buffer[1] = \"x\";\n for (uint256 i = 2 * length + 1; i > 1; --i) {\n buffer[i] = _HEX_SYMBOLS[value & 0xf];\n value >>= 4;\n }\n require(value == 0, \"Strings: hex length insufficient\");\n return string(buffer);\n }\n\n /**\n * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.\n */\n function toHexString(address addr) internal pure returns (string memory) {\n return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);\n }\n}\n" }, "@openzeppelin/contracts/utils/Context.sol": { "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n}\n" }, "@openzeppelin/contracts/utils/Address.sol": { "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length > 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCall(target, data, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n require(isContract(target), \"Address: call to non-contract\");\n\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n require(isContract(target), \"Address: static call to non-contract\");\n\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(isContract(target), \"Address: delegate call to non-contract\");\n\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n }\n}\n" }, "@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol": { "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC721.sol\";\n\n/**\n * @title ERC-721 Non-Fungible Token Standard, optional metadata extension\n * @dev See https://eips.ethereum.org/EIPS/eip-721\n */\ninterface IERC721Metadata is IERC721 {\n /**\n * @dev Returns the token collection name.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the token collection symbol.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.\n */\n function tokenURI(uint256 tokenId) external view returns (string memory);\n}\n" }, "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol": { "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @title ERC721 token receiver interface\n * @dev Interface for any contract that wants to support safeTransfers\n * from ERC721 asset contracts.\n */\ninterface IERC721Receiver {\n /**\n * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\n * by `operator` from `from`, this function is called.\n *\n * It must return its Solidity selector to confirm the token transfer.\n * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.\n *\n * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.\n */\n function onERC721Received(\n address operator,\n address from,\n uint256 tokenId,\n bytes calldata data\n ) external returns (bytes4);\n}\n" }, "@openzeppelin/contracts/token/ERC721/IERC721.sol": { "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/IERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Required interface of an ERC721 compliant contract.\n */\ninterface IERC721 is IERC165 {\n /**\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\n */\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\n */\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\n */\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n /**\n * @dev Returns the number of tokens in ``owner``'s account.\n */\n function balanceOf(address owner) external view returns (uint256 balance);\n\n /**\n * @dev Returns the owner of the `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function ownerOf(uint256 tokenId) external view returns (address owner);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes calldata data\n ) external;\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Transfers `tokenId` token from `from` to `to`.\n *\n * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n * The approval is cleared when the token is transferred.\n *\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\n *\n * Requirements:\n *\n * - The caller must own the token or be an approved operator.\n * - `tokenId` must exist.\n *\n * Emits an {Approval} event.\n */\n function approve(address to, uint256 tokenId) external;\n\n /**\n * @dev Approve or remove `operator` as an operator for the caller.\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\n *\n * Requirements:\n *\n * - The `operator` cannot be the caller.\n *\n * Emits an {ApprovalForAll} event.\n */\n function setApprovalForAll(address operator, bool _approved) external;\n\n /**\n * @dev Returns the account approved for `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function getApproved(uint256 tokenId) external view returns (address operator);\n\n /**\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n *\n * See {setApprovalForAll}\n */\n function isApprovedForAll(address owner, address operator) external view returns (bool);\n}\n" }, "@openzeppelin/contracts/token/ERC721/ERC721.sol": { "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/ERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC721.sol\";\nimport \"./IERC721Receiver.sol\";\nimport \"./extensions/IERC721Metadata.sol\";\nimport \"../../utils/Address.sol\";\nimport \"../../utils/Context.sol\";\nimport \"../../utils/Strings.sol\";\nimport \"../../utils/introspection/ERC165.sol\";\n\n/**\n * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including\n * the Metadata extension, but not including the Enumerable extension, which is available separately as\n * {ERC721Enumerable}.\n */\ncontract ERC721 is Context, ERC165, IERC721, IERC721Metadata {\n using Address for address;\n using Strings for uint256;\n\n // Token name\n string private _name;\n\n // Token symbol\n string private _symbol;\n\n // Mapping from token ID to owner address\n mapping(uint256 => address) private _owners;\n\n // Mapping owner address to token count\n mapping(address => uint256) private _balances;\n\n // Mapping from token ID to approved address\n mapping(uint256 => address) private _tokenApprovals;\n\n // Mapping from owner to operator approvals\n mapping(address => mapping(address => bool)) private _operatorApprovals;\n\n /**\n * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.\n */\n constructor(string memory name_, string memory symbol_) {\n _name = name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {\n return\n interfaceId == type(IERC721).interfaceId ||\n interfaceId == type(IERC721Metadata).interfaceId ||\n super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev See {IERC721-balanceOf}.\n */\n function balanceOf(address owner) public view virtual override returns (uint256) {\n require(owner != address(0), \"ERC721: address zero is not a valid owner\");\n return _balances[owner];\n }\n\n /**\n * @dev See {IERC721-ownerOf}.\n */\n function ownerOf(uint256 tokenId) public view virtual override returns (address) {\n address owner = _owners[tokenId];\n require(owner != address(0), \"ERC721: invalid token ID\");\n return owner;\n }\n\n /**\n * @dev See {IERC721Metadata-name}.\n */\n function name() public view virtual override returns (string memory) {\n return _name;\n }\n\n /**\n * @dev See {IERC721Metadata-symbol}.\n */\n function symbol() public view virtual override returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev See {IERC721Metadata-tokenURI}.\n */\n function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {\n _requireMinted(tokenId);\n\n string memory baseURI = _baseURI();\n return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : \"\";\n }\n\n /**\n * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each\n * token will be the concatenation of the `baseURI` and the `tokenId`. Empty\n * by default, can be overridden in child contracts.\n */\n function _baseURI() internal view virtual returns (string memory) {\n return \"\";\n }\n\n /**\n * @dev See {IERC721-approve}.\n */\n function approve(address to, uint256 tokenId) public virtual override {\n address owner = ERC721.ownerOf(tokenId);\n require(to != owner, \"ERC721: approval to current owner\");\n\n require(\n _msgSender() == owner || isApprovedForAll(owner, _msgSender()),\n \"ERC721: approve caller is not token owner nor approved for all\"\n );\n\n _approve(to, tokenId);\n }\n\n /**\n * @dev See {IERC721-getApproved}.\n */\n function getApproved(uint256 tokenId) public view virtual override returns (address) {\n _requireMinted(tokenId);\n\n return _tokenApprovals[tokenId];\n }\n\n /**\n * @dev See {IERC721-setApprovalForAll}.\n */\n function setApprovalForAll(address operator, bool approved) public virtual override {\n _setApprovalForAll(_msgSender(), operator, approved);\n }\n\n /**\n * @dev See {IERC721-isApprovedForAll}.\n */\n function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {\n return _operatorApprovals[owner][operator];\n }\n\n /**\n * @dev See {IERC721-transferFrom}.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public virtual override {\n //solhint-disable-next-line max-line-length\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: caller is not token owner nor approved\");\n\n _transfer(from, to, tokenId);\n }\n\n /**\n * @dev See {IERC721-safeTransferFrom}.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public virtual override {\n safeTransferFrom(from, to, tokenId, \"\");\n }\n\n /**\n * @dev See {IERC721-safeTransferFrom}.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) public virtual override {\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: caller is not token owner nor approved\");\n _safeTransfer(from, to, tokenId, data);\n }\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * `data` is additional data, it has no specified format and it is sent in call to `to`.\n *\n * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.\n * implement alternative mechanisms to perform token transfer, such as signature-based.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function _safeTransfer(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) internal virtual {\n _transfer(from, to, tokenId);\n require(_checkOnERC721Received(from, to, tokenId, data), \"ERC721: transfer to non ERC721Receiver implementer\");\n }\n\n /**\n * @dev Returns whether `tokenId` exists.\n *\n * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.\n *\n * Tokens start existing when they are minted (`_mint`),\n * and stop existing when they are burned (`_burn`).\n */\n function _exists(uint256 tokenId) internal view virtual returns (bool) {\n return _owners[tokenId] != address(0);\n }\n\n /**\n * @dev Returns whether `spender` is allowed to manage `tokenId`.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {\n address owner = ERC721.ownerOf(tokenId);\n return (spender == owner || isApprovedForAll(owner, spender) || getApproved(tokenId) == spender);\n }\n\n /**\n * @dev Safely mints `tokenId` and transfers it to `to`.\n *\n * Requirements:\n *\n * - `tokenId` must not exist.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function _safeMint(address to, uint256 tokenId) internal virtual {\n _safeMint(to, tokenId, \"\");\n }\n\n /**\n * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is\n * forwarded in {IERC721Receiver-onERC721Received} to contract recipients.\n */\n function _safeMint(\n address to,\n uint256 tokenId,\n bytes memory data\n ) internal virtual {\n _mint(to, tokenId);\n require(\n _checkOnERC721Received(address(0), to, tokenId, data),\n \"ERC721: transfer to non ERC721Receiver implementer\"\n );\n }\n\n /**\n * @dev Mints `tokenId` and transfers it to `to`.\n *\n * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible\n *\n * Requirements:\n *\n * - `tokenId` must not exist.\n * - `to` cannot be the zero address.\n *\n * Emits a {Transfer} event.\n */\n function _mint(address to, uint256 tokenId) internal virtual {\n require(to != address(0), \"ERC721: mint to the zero address\");\n require(!_exists(tokenId), \"ERC721: token already minted\");\n\n _beforeTokenTransfer(address(0), to, tokenId);\n\n _balances[to] += 1;\n _owners[tokenId] = to;\n\n emit Transfer(address(0), to, tokenId);\n\n _afterTokenTransfer(address(0), to, tokenId);\n }\n\n /**\n * @dev Destroys `tokenId`.\n * The approval is cleared when the token is burned.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n *\n * Emits a {Transfer} event.\n */\n function _burn(uint256 tokenId) internal virtual {\n address owner = ERC721.ownerOf(tokenId);\n\n _beforeTokenTransfer(owner, address(0), tokenId);\n\n // Clear approvals\n _approve(address(0), tokenId);\n\n _balances[owner] -= 1;\n delete _owners[tokenId];\n\n emit Transfer(owner, address(0), tokenId);\n\n _afterTokenTransfer(owner, address(0), tokenId);\n }\n\n /**\n * @dev Transfers `tokenId` from `from` to `to`.\n * As opposed to {transferFrom}, this imposes no restrictions on msg.sender.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n *\n * Emits a {Transfer} event.\n */\n function _transfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual {\n require(ERC721.ownerOf(tokenId) == from, \"ERC721: transfer from incorrect owner\");\n require(to != address(0), \"ERC721: transfer to the zero address\");\n\n _beforeTokenTransfer(from, to, tokenId);\n\n // Clear approvals from the previous owner\n _approve(address(0), tokenId);\n\n _balances[from] -= 1;\n _balances[to] += 1;\n _owners[tokenId] = to;\n\n emit Transfer(from, to, tokenId);\n\n _afterTokenTransfer(from, to, tokenId);\n }\n\n /**\n * @dev Approve `to` to operate on `tokenId`\n *\n * Emits an {Approval} event.\n */\n function _approve(address to, uint256 tokenId) internal virtual {\n _tokenApprovals[tokenId] = to;\n emit Approval(ERC721.ownerOf(tokenId), to, tokenId);\n }\n\n /**\n * @dev Approve `operator` to operate on all of `owner` tokens\n *\n * Emits an {ApprovalForAll} event.\n */\n function _setApprovalForAll(\n address owner,\n address operator,\n bool approved\n ) internal virtual {\n require(owner != operator, \"ERC721: approve to caller\");\n _operatorApprovals[owner][operator] = approved;\n emit ApprovalForAll(owner, operator, approved);\n }\n\n /**\n * @dev Reverts if the `tokenId` has not been minted yet.\n */\n function _requireMinted(uint256 tokenId) internal view virtual {\n require(_exists(tokenId), \"ERC721: invalid token ID\");\n }\n\n /**\n * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.\n * The call is not executed if the target address is not a contract.\n *\n * @param from address representing the previous owner of the given token ID\n * @param to target address that will receive the tokens\n * @param tokenId uint256 ID of the token to be transferred\n * @param data bytes optional data to send along with the call\n * @return bool whether the call correctly returned the expected magic value\n */\n function _checkOnERC721Received(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) private returns (bool) {\n if (to.isContract()) {\n try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) {\n return retval == IERC721Receiver.onERC721Received.selector;\n } catch (bytes memory reason) {\n if (reason.length == 0) {\n revert(\"ERC721: transfer to non ERC721Receiver implementer\");\n } else {\n /// @solidity memory-safe-assembly\n assembly {\n revert(add(32, reason), mload(reason))\n }\n }\n }\n } else {\n return true;\n }\n }\n\n /**\n * @dev Hook that is called before any token transfer. This includes minting\n * and burning.\n *\n * Calling conditions:\n *\n * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be\n * transferred to `to`.\n * - When `from` is zero, `tokenId` will be minted for `to`.\n * - When `to` is zero, ``from``'s `tokenId` will be burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual {}\n\n /**\n * @dev Hook that is called after any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _afterTokenTransfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual {}\n}\n" }, "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol": { "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n *\n * _Available since v4.1._\n */\ninterface IERC20Metadata is IERC20 {\n /**\n * @dev Returns the name of the token.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the symbol of the token.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the decimals places of the token.\n */\n function decimals() external view returns (uint8);\n}\n" }, "@openzeppelin/contracts/token/ERC20/IERC20.sol": { "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n\n /**\n * @dev Returns the amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` tokens from the caller's account to `to`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address to, uint256 amount) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `from` to `to` using the\n * allowance mechanism. `amount` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) external returns (bool);\n}\n" }, "@openzeppelin/contracts/token/ERC20/ERC20.sol": { "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/ERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC20.sol\";\nimport \"./extensions/IERC20Metadata.sol\";\nimport \"../../utils/Context.sol\";\n\n/**\n * @dev Implementation of the {IERC20} interface.\n *\n * This implementation is agnostic to the way tokens are created. This means\n * that a supply mechanism has to be added in a derived contract using {_mint}.\n * For a generic mechanism see {ERC20PresetMinterPauser}.\n *\n * TIP: For a detailed writeup see our guide\n * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How\n * to implement supply mechanisms].\n *\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\n * instead returning `false` on failure. This behavior is nonetheless\n * conventional and does not conflict with the expectations of ERC20\n * applications.\n *\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\n * This allows applications to reconstruct the allowance for all accounts just\n * by listening to said events. Other implementations of the EIP may not emit\n * these events, as it isn't required by the specification.\n *\n * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}\n * functions have been added to mitigate the well-known issues around setting\n * allowances. See {IERC20-approve}.\n */\ncontract ERC20 is Context, IERC20, IERC20Metadata {\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n uint256 private _totalSupply;\n\n string private _name;\n string private _symbol;\n\n /**\n * @dev Sets the values for {name} and {symbol}.\n *\n * The default value of {decimals} is 18. To select a different value for\n * {decimals} you should overload it.\n *\n * All two of these values are immutable: they can only be set once during\n * construction.\n */\n constructor(string memory name_, string memory symbol_) {\n _name = name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev Returns the name of the token.\n */\n function name() public view virtual override returns (string memory) {\n return _name;\n }\n\n /**\n * @dev Returns the symbol of the token, usually a shorter version of the\n * name.\n */\n function symbol() public view virtual override returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev Returns the number of decimals used to get its user representation.\n * For example, if `decimals` equals `2`, a balance of `505` tokens should\n * be displayed to a user as `5.05` (`505 / 10 ** 2`).\n *\n * Tokens usually opt for a value of 18, imitating the relationship between\n * Ether and Wei. This is the value {ERC20} uses, unless this function is\n * overridden;\n *\n * NOTE: This information is only used for _display_ purposes: it in\n * no way affects any of the arithmetic of the contract, including\n * {IERC20-balanceOf} and {IERC20-transfer}.\n */\n function decimals() public view virtual override returns (uint8) {\n return 18;\n }\n\n /**\n * @dev See {IERC20-totalSupply}.\n */\n function totalSupply() public view virtual override returns (uint256) {\n return _totalSupply;\n }\n\n /**\n * @dev See {IERC20-balanceOf}.\n */\n function balanceOf(address account) public view virtual override returns (uint256) {\n return _balances[account];\n }\n\n /**\n * @dev See {IERC20-transfer}.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - the caller must have a balance of at least `amount`.\n */\n function transfer(address to, uint256 amount) public virtual override returns (bool) {\n address owner = _msgSender();\n _transfer(owner, to, amount);\n return true;\n }\n\n /**\n * @dev See {IERC20-allowance}.\n */\n function allowance(address owner, address spender) public view virtual override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n /**\n * @dev See {IERC20-approve}.\n *\n * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on\n * `transferFrom`. This is semantically equivalent to an infinite approval.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function approve(address spender, uint256 amount) public virtual override returns (bool) {\n address owner = _msgSender();\n _approve(owner, spender, amount);\n return true;\n }\n\n /**\n * @dev See {IERC20-transferFrom}.\n *\n * Emits an {Approval} event indicating the updated allowance. This is not\n * required by the EIP. See the note at the beginning of {ERC20}.\n *\n * NOTE: Does not update the allowance if the current allowance\n * is the maximum `uint256`.\n *\n * Requirements:\n *\n * - `from` and `to` cannot be the zero address.\n * - `from` must have a balance of at least `amount`.\n * - the caller must have allowance for ``from``'s tokens of at least\n * `amount`.\n */\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) public virtual override returns (bool) {\n address spender = _msgSender();\n _spendAllowance(from, spender, amount);\n _transfer(from, to, amount);\n return true;\n }\n\n /**\n * @dev Atomically increases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {\n address owner = _msgSender();\n _approve(owner, spender, allowance(owner, spender) + addedValue);\n return true;\n }\n\n /**\n * @dev Atomically decreases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `spender` must have allowance for the caller of at least\n * `subtractedValue`.\n */\n function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {\n address owner = _msgSender();\n uint256 currentAllowance = allowance(owner, spender);\n require(currentAllowance >= subtractedValue, \"ERC20: decreased allowance below zero\");\n unchecked {\n _approve(owner, spender, currentAllowance - subtractedValue);\n }\n\n return true;\n }\n\n /**\n * @dev Moves `amount` of tokens from `from` to `to`.\n *\n * This internal function is equivalent to {transfer}, and can be used to\n * e.g. implement automatic token fees, slashing mechanisms, etc.\n *\n * Emits a {Transfer} event.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `from` must have a balance of at least `amount`.\n */\n function _transfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n _beforeTokenTransfer(from, to, amount);\n\n uint256 fromBalance = _balances[from];\n require(fromBalance >= amount, \"ERC20: transfer amount exceeds balance\");\n unchecked {\n _balances[from] = fromBalance - amount;\n }\n _balances[to] += amount;\n\n emit Transfer(from, to, amount);\n\n _afterTokenTransfer(from, to, amount);\n }\n\n /** @dev Creates `amount` tokens and assigns them to `account`, increasing\n * the total supply.\n *\n * Emits a {Transfer} event with `from` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n */\n function _mint(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: mint to the zero address\");\n\n _beforeTokenTransfer(address(0), account, amount);\n\n _totalSupply += amount;\n _balances[account] += amount;\n emit Transfer(address(0), account, amount);\n\n _afterTokenTransfer(address(0), account, amount);\n }\n\n /**\n * @dev Destroys `amount` tokens from `account`, reducing the\n * total supply.\n *\n * Emits a {Transfer} event with `to` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n * - `account` must have at least `amount` tokens.\n */\n function _burn(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: burn from the zero address\");\n\n _beforeTokenTransfer(account, address(0), amount);\n\n uint256 accountBalance = _balances[account];\n require(accountBalance >= amount, \"ERC20: burn amount exceeds balance\");\n unchecked {\n _balances[account] = accountBalance - amount;\n }\n _totalSupply -= amount;\n\n emit Transfer(account, address(0), amount);\n\n _afterTokenTransfer(account, address(0), amount);\n }\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.\n *\n * This internal function is equivalent to `approve`, and can be used to\n * e.g. set automatic allowances for certain subsystems, etc.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `owner` cannot be the zero address.\n * - `spender` cannot be the zero address.\n */\n function _approve(\n address owner,\n address spender,\n uint256 amount\n ) internal virtual {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n _allowances[owner][spender] = amount;\n emit Approval(owner, spender, amount);\n }\n\n /**\n * @dev Updates `owner` s allowance for `spender` based on spent `amount`.\n *\n * Does not update the allowance amount in case of infinite allowance.\n * Revert if not enough allowance is available.\n *\n * Might emit an {Approval} event.\n */\n function _spendAllowance(\n address owner,\n address spender,\n uint256 amount\n ) internal virtual {\n uint256 currentAllowance = allowance(owner, spender);\n if (currentAllowance != type(uint256).max) {\n require(currentAllowance >= amount, \"ERC20: insufficient allowance\");\n unchecked {\n _approve(owner, spender, currentAllowance - amount);\n }\n }\n }\n\n /**\n * @dev Hook that is called before any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * will be transferred to `to`.\n * - when `from` is zero, `amount` tokens will be minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens will be burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n\n /**\n * @dev Hook that is called after any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * has been transferred to `to`.\n * - when `from` is zero, `amount` tokens have been minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens have been burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _afterTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n}\n" }, "@openzeppelin/contracts/security/ReentrancyGuard.sol": { "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (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 // On the first call to nonReentrant, _notEntered will be true\n require(_status != _ENTERED, \"ReentrancyGuard: reentrant call\");\n\n // Any calls to nonReentrant after this point will fail\n _status = _ENTERED;\n\n _;\n\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" }, "@openzeppelin/contracts/security/Pausable.sol": { "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which allows children to implement an emergency stop\n * mechanism that can be triggered by an authorized account.\n *\n * This module is used through inheritance. It will make available the\n * modifiers `whenNotPaused` and `whenPaused`, which can be applied to\n * the functions of your contract. Note that they will not be pausable by\n * simply including this module, only once the modifiers are put in place.\n */\nabstract contract Pausable is Context {\n /**\n * @dev Emitted when the pause is triggered by `account`.\n */\n event Paused(address account);\n\n /**\n * @dev Emitted when the pause is lifted by `account`.\n */\n event Unpaused(address account);\n\n bool private _paused;\n\n /**\n * @dev Initializes the contract in unpaused state.\n */\n constructor() {\n _paused = false;\n }\n\n /**\n * @dev Modifier to make a function callable only when the contract is not paused.\n *\n * Requirements:\n *\n * - The contract must not be paused.\n */\n modifier whenNotPaused() {\n _requireNotPaused();\n _;\n }\n\n /**\n * @dev Modifier to make a function callable only when the contract is paused.\n *\n * Requirements:\n *\n * - The contract must be paused.\n */\n modifier whenPaused() {\n _requirePaused();\n _;\n }\n\n /**\n * @dev Returns true if the contract is paused, and false otherwise.\n */\n function paused() public view virtual returns (bool) {\n return _paused;\n }\n\n /**\n * @dev Throws if the contract is paused.\n */\n function _requireNotPaused() internal view virtual {\n require(!paused(), \"Pausable: paused\");\n }\n\n /**\n * @dev Throws if the contract is not paused.\n */\n function _requirePaused() internal view virtual {\n require(paused(), \"Pausable: not paused\");\n }\n\n /**\n * @dev Triggers stopped state.\n *\n * Requirements:\n *\n * - The contract must not be paused.\n */\n function _pause() internal virtual whenNotPaused {\n _paused = true;\n emit Paused(_msgSender());\n }\n\n /**\n * @dev Returns to normal state.\n *\n * Requirements:\n *\n * - The contract must be paused.\n */\n function _unpause() internal virtual whenPaused {\n _paused = false;\n emit Unpaused(_msgSender());\n }\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" } }, "settings": { "remappings": [], "optimizer": { "enabled": true, "runs": 200 }, "evmVersion": "london", "libraries": {}, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } } } }