ERC-721
Overview
Max Total Supply
1,896 MF
Holders
161
Total Transfers
-
Market
Volume (24H)
N/A
Min Price (24H)
N/A
Max Price (24H)
N/A
Other Info
Token Contract
Loading...
Loading
Loading...
Loading
Loading...
Loading
# | Exchange | Pair | Price | 24H Volume | % Volume |
---|
Contract Name:
MagicFolk
Compiler Version
v0.8.4+commit.c7e474f2
Optimization Enabled:
Yes with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import '../utils/Common.sol'; import '../utils/SigVer.sol'; import './MagicFolkGems.sol'; import './MagicFolkItems.sol'; // import "@erc721a/contracts/extensions/ERC721AQueryable.sol"; import '../ERC721ACustom/ERC721AQueryableStakable.sol'; import '@openzeppelin/contracts/access/Ownable.sol'; import '@openzeppelin/contracts/interfaces/IERC721.sol'; import '@openzeppelin/contracts/interfaces/IERC1155.sol'; import '@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol'; import '@openzeppelin/contracts/token/ERC721/utils/ERC721Holder.sol'; import '@openzeppelin/contracts/security/ReentrancyGuard.sol'; import '@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol'; import '@openzeppelin/contracts/utils/Counters.sol'; import '@openzeppelin/contracts/utils/introspection/ERC165.sol'; import '@openzeppelin/contracts/access/AccessControl.sol'; contract MagicFolk is ERC165, // ERC721, // ERC721Enumerable, ERC721A, ERC721AQueryable, ERC721Holder, CommonConstants, IERC1155Receiver, ReentrancyGuard, SigVer, AccessControl, Ownable { bytes32 public constant MINTER_ROLE = keccak256('MINTER_ROLE'); using Counters for Counters.Counter; struct Stats { uint8 powerLevel; Item mainHand; Item offHand; Item pet; } struct Payee { address wallet; uint16 percentagePoints; bytes24 payeeId; } // Setup payees // Hardcoded here instead of being added by an external function // for the sake of immutability and transparency. Payee[11] public _payees; event Equipped( uint256 indexed _tokenId, uint256 indexed _itemId, ItemType _itemType ); event Unequipped( uint256 indexed _tokenId, uint256 indexed _itemId, ItemType _itemType ); event Staked(uint256 indexed _tokenId, address owner); event Unstaked(uint256 indexed _tokenId, address owner); event publicSaleToggled(bool state); event privateSaleToggled(bool state); event stakingToggled(bool state); // token id => stats mapping(uint256 => Stats) private _tokenStats; // Private sale mapping(address => uint256) private _totalMintsPerAddress; // Public sale mapping(address => uint256) public _mintNonce; // Staking mapping(uint256 => uint256) private _lastClaims; mapping(address => uint256[]) public _stakedTokens; Counters.Counter private _tokenIdCounter; MagicFolkItems MAGIC_FOLK_MAINHAND; MagicFolkItems MAGIC_FOLK_OFFHAND; MagicFolkItems MAGIC_FOLK_PET; MagicFolkGems MAGIC_FOLK_GEMS; // MINT CONSTANTS uint256 public constant PUBLIC_ALLOWANCE = 10; uint256 public constant TEAM_MINT = 49; uint256 public constant MINTS_PER_MIGRATION = 2; uint256 public constant MIGRATION_MINTS = 594 * MINTS_PER_MIGRATION; uint256 public constant MAX_MINT = 5555 - TEAM_MINT - MIGRATION_MINTS; uint256 public PRIVATE_PRICE = 0.05 ether; uint256 public PUBLIC_PRICE = 0.05 ether; address public constant FEE_ADDRESS = 0x670326f4470d4D2F5347377Ff187717a81aB1318; uint256 public _fees = 30.0 ether; uint256 public _teamMinted = 0; uint256 public _migrationMints = 0; address public _signer; // Gems per day per power level uint256 _gemRate = 10; uint256 constant SECONDS_PER_DAY = 86400; string public _URI = 'https://cdn-stg.magicfolk.io/api/genesis/'; uint8[MAX_MINT + TEAM_MINT + MIGRATION_MINTS] private _basePowerLevels; // token id => base power level bool private _publicSale = false; bool private _privateSale = false; bool private _powerLevelsSet = false; bool public _publicSaleSignatureRequired = true; bool public _stakingEnabled = false; bool public _listable = false; bool public _initialFeesWithdrawn = false; uint8 private constant DEFAULT_POWER_LEVEL = 5; constructor( address signer, address magicFolkMainhand, address magicFolkOffhand, address magicFolkPet ) ERC721A('Magic Folk', 'MF') { _grantRole(DEFAULT_ADMIN_ROLE, msg.sender); _signer = signer; MAGIC_FOLK_MAINHAND = MagicFolkItems(magicFolkMainhand); MAGIC_FOLK_OFFHAND = MagicFolkItems(magicFolkOffhand); MAGIC_FOLK_PET = MagicFolkItems(magicFolkPet); _grantRole(DEFAULT_ADMIN_ROLE, msg.sender); // Setup payees _payees[0] = Payee( 0x586a6c03DA4959C6341845C210b4CdBec930Af37, 265, 'ELON_MUSK' ); _payees[1] = Payee( 0xa8fD19cb5F949677504DD90f8B6efe044286e6B2, 80, 'DONALD_TRUMP' ); _payees[2] = Payee( 0xD85aA7341a63B413972c8e8D63Ae7a7bC08A5aFD, 25, 'WARREN_BUFFET' ); _payees[3] = Payee( 0x4fB91f8b17702aFf47BE977A226dDdabf5475661, 25, 'JEFF_BEZOS' ); _payees[4] = Payee( 0x7913FEDA30503465EDAdc674a66fbDcB581f6840, 120, 'BILL_GATES' ); _payees[5] = Payee( 0x2E8a3F14feDA7FA7690260a06A1656BFe20bE1aC, 60, 'LEBRON_JAMES' ); _payees[6] = Payee( 0x60d1082D0fdaB22990f56A70B68AdDC049F75EC8, 100, 'NICOLAS_CAGE' ); _payees[7] = Payee( 0x71dcB19A6D322C9D826aA6b61442828436Aa6fb2, 50, 'KENDRICK_LAMAR' ); _payees[8] = Payee( 0x996107A817f0fbaF389F1DCC1A48Dfb2eDb78D33, 25, 'R_KELLY' ); _payees[9] = Payee( 0xAB1ca28b50EdC107023d81e71640da3ee26F93A0, 150, 'LIL_DICKY' ); _payees[10] = Payee( 0x3750737d7fbF284705a329AB674D9309485B5bE2, 100, 'JIMMY_CARR' ); uint256 percentagePointSum = 0; for (uint256 i = 0; i < _payees.length; i++) { percentagePointSum += _payees[i].percentagePoints; } require(percentagePointSum == 1000, 'INVALID_PERCENTAGES'); } function setMagicFolkGemsContract(address magicFolkGems) public onlyRole(DEFAULT_ADMIN_ROLE) { MAGIC_FOLK_GEMS = MagicFolkGems(magicFolkGems); } function setMigrationProxy(address migrationProxy) public onlyRole(DEFAULT_ADMIN_ROLE) { grantRole(MINTER_ROLE, migrationProxy); } function setMagicFolkItemsContract(address magicFolkItems, ItemType itemType) public onlyRole(DEFAULT_ADMIN_ROLE) { if (itemType == ItemType.Mainhand) { MAGIC_FOLK_MAINHAND = MagicFolkItems(magicFolkItems); } else if (itemType == ItemType.Offhand) { MAGIC_FOLK_OFFHAND = MagicFolkItems(magicFolkItems); } else if (itemType == ItemType.Pet) { MAGIC_FOLK_PET = MagicFolkItems(magicFolkItems); } else { revert(); } } function setSignerAddress(address signer) external onlyRole(DEFAULT_ADMIN_ROLE) { _signer = signer; } function setBaseURI(string calldata URI) external onlyRole(DEFAULT_ADMIN_ROLE) { _URI = URI; } function _baseURI() internal view override returns (string memory) { return _URI; } function publicSaleActive() public view returns (bool) { return _publicSaleActive(); } function togglePublicSale() public onlyRole(DEFAULT_ADMIN_ROLE) { require(!_privateSaleActive()); _publicSale = !_publicSale; emit publicSaleToggled(_publicSale); } function setPublicPrice(uint256 newPrice) public onlyRole(DEFAULT_ADMIN_ROLE) { PUBLIC_PRICE = newPrice; } function setPrivatePrice(uint256 newPrice) public onlyRole(DEFAULT_ADMIN_ROLE) { PRIVATE_PRICE = newPrice; } function toggleStaking() external onlyRole(DEFAULT_ADMIN_ROLE) { _stakingEnabled = !_stakingEnabled; emit stakingToggled(_stakingEnabled); } function togglePublicSaleSigRequired() public onlyRole(DEFAULT_ADMIN_ROLE) { _publicSaleSignatureRequired = !_publicSaleSignatureRequired; } function privateSaleActive() public view returns (bool) { return _privateSaleActive(); } function togglePrivateSale() public onlyRole(DEFAULT_ADMIN_ROLE) { require(!_publicSaleActive()); _privateSale = !_privateSale; emit privateSaleToggled(_privateSale); } // Power levels for legendary NFTs will be set after reveal function setPowerLevels( uint8[] calldata powerLevels, uint256[] calldata tokenIds ) external onlyRole(DEFAULT_ADMIN_ROLE) { require(!_powerLevelsSet); require(powerLevels.length == tokenIds.length); for (uint256 i = 0; i < powerLevels.length; i++) { _basePowerLevels[tokenIds[i]] = powerLevels[i]; } } function lockPowerLevels() external onlyRole(DEFAULT_ADMIN_ROLE) { require(!_powerLevelsSet); _powerLevelsSet = true; } /** @dev Mints an NFT for the public sale. Uses a nonce, msgHash and signature to ensure minting is only possible through our website. @param qty Amount to be minted @param mintNonce Nonce value that's incremented after each mint, used to ensure signature + msgHash are unique. Can be retrieved via ._mintNonce(address) before being hashed + signed and passed into function. @param msgHash hashed message, should match the message that's been signed by our keypair on frontend. (['address', 'uint256'], [buyerAddress, mintNonce]) @param signature signed version of msgHash */ function safeMintPublic( uint256 qty, uint256 mintNonce, bytes32 msgHash, bytes calldata signature ) external payable { address to = _msgSender(); require(_publicSaleActive(), 'Public sale not active'); require(msg.value >= qty * PUBLIC_PRICE, 'Insufficient funds'); require(qty <= PUBLIC_ALLOWANCE, 'EXCEED_ALLOWANCE'); require(!_soldOut(qty), 'SOLD_OUT'); require(mintNonce == _mintNonce[to], 'INVALID_NONCE'); require( _verifyMsg(to, mintNonce, msgHash, signature, _signer) || !_publicSaleSignatureRequired, 'INVALID_SIG' ); // for (uint256 i = 0; i < qty; i++) { // _safeMint(to); // } _safeMint(to, qty, ''); _mintNonce[to]++; } /** @dev Mints an NFT for the private sale. Eligibility and allowance for private sale are verified, hashed, and signed to ensure only those eligible can mint. @param qty Amount to be minted @param privateSaleAllowance Total number of NFTs this account can mint in the private sale. @param msgHash hashed message, should match the message that's been signed by our keypair on frontend. (['address', 'uint256'], [buyerAddress, privateSaleAllowance]) @param signature signed version of msgHash */ function safeMintPrivate( uint256 qty, uint256 privateSaleAllowance, bytes32 msgHash, bytes calldata signature ) external payable { address to = _msgSender(); require(_privateSaleActive(), 'Private sale not active'); require(msg.value >= qty * PRIVATE_PRICE, 'Insufficient funds'); require( qty + _totalMintsPerAddress[to] <= privateSaleAllowance, 'Exceeded allowance' ); require( _verifyMsg(to, privateSaleAllowance, msgHash, signature, _signer), 'INVALID_SIG' ); require(!_soldOut(qty), 'SOLD_OUT'); // for (uint256 i = 0; i < qty; i++) { // _safeMint(to); // } _safeMint(to, qty, ''); _totalMintsPerAddress[to] += qty; } function teamMint(uint256 qty) external onlyRole(DEFAULT_ADMIN_ROLE) { require(_publicSaleActive() || _privateSaleActive()); address to = msg.sender; require(qty + _teamMinted <= TEAM_MINT, 'TEAM_MINT_LIMIT_REACHED'); // for (uint256 i = 0; i < qty; i++) { // _safeMint(to); // } _safeMint(to, qty, ''); _teamMinted += qty; } function migrationMint(address to, uint256 qty) external onlyRole(MINTER_ROLE) { _safeMint(to, qty * MINTS_PER_MIGRATION, ''); _migrationMints += qty; } function isTokenStaked(uint256 tokenId) public view returns (bool) { return _isTokenStaked(tokenId); } function stakeToken(uint256 tokenId) external nonReentrant { _stakeToken(msg.sender, tokenId); } function stakeTokens(uint256[] calldata tokenIds) external nonReentrant { for (uint256 i = 0; i < tokenIds.length; i++) { _stakeToken(msg.sender, tokenIds[i]); } } function getQuantityStaked(address owner) public view returns (uint256) { return _stakedTokens[owner].length; } function getStakedTokens(address owner) public view returns (uint256[] memory) { return _stakedTokens[owner]; } // function tokensOfOwner(address owner) // public // view // returns (uint256[] memory) // { // uint256 totalOwned = balanceOf(owner); // uint256[] memory ret = new uint256[](totalOwned); // for (uint256 i = 0; i < totalOwned; i++) { // ret[i] = ERC721Enumerable.tokenOfOwnerByIndex(owner, i); // } // return ret; // } function setGemRate(uint256 newGemRate) public onlyRole(DEFAULT_ADMIN_ROLE) { _setGemRate(newGemRate); } function _soldOut(uint256 qty) internal view returns (bool) { return !(_totalMinted() - _teamMinted - _migrationMints + qty <= MAX_MINT); } function _stakeToken(address user, uint256 tokenId) internal { require(_ownsToken(user, tokenId), 'NOT_AUTHORISED'); require(!_isTokenStaked(tokenId), 'ALREADY_STAKED'); _setLastClaim(tokenId); _tokenOwners[tokenId] = user; _stakedTokens[user].push(tokenId); safeTransferFrom(user, address(this), tokenId); } function _ownsToken(address user, uint256 tokenId) internal view returns (bool) { TokenOwnership memory ownership = _ownershipOf(tokenId); return (ownership.addr == user && !ownership.burned); } function unstakeToken(uint256 tokenId) external nonReentrant { _unstakeToken(msg.sender, tokenId); } function unstakeTokens(uint256[] calldata tokenIds) external nonReentrant { for (uint256 i = 0; i < tokenIds.length; i++) { _unstakeToken(msg.sender, tokenIds[i]); } } function claimGems(uint256 tokenId) public nonReentrant { require(_isTokenStaked(tokenId), 'NOT_STAKED'); require(_tokenOwners[tokenId] == _msgSender(), 'NOT_AUTHORISED'); uint256 allocation = _calcAllocation(tokenId); require(allocation > 0, 'NO_GEMS'); MAGIC_FOLK_GEMS.mint(_msgSender(), allocation); _setLastClaim(tokenId); } function claimAllGems() external { uint256[] memory stakedTokens = _stakedTokens[_msgSender()]; for (uint256 i = 0; i < stakedTokens.length; i++) { if (_calcAllocation(stakedTokens[i]) > 0) { claimGems(stakedTokens[i]); } } } function getAllocation(uint256 tokenId) public view returns (uint256) { return _calcAllocation(tokenId); } function getTotalUnclaimed(address owner) public view returns (uint256) { uint256 sum = 0; uint256[] memory stakedTokens = _stakedTokens[owner]; for (uint256 i = 0; i < stakedTokens.length; i++) { sum += _calcAllocation(stakedTokens[i]); } return sum; } // function _safeMint(address to, uint256 qty) internal override { // _safeMint(to, qty, ""); // } // // Was originally going to use Chainlink VRF, but we decided to base // // power levels on rarity so they'll be written after reveal. // // Defaults to 5, legendary NFTs will have a higher power level. // function _rollStats(uint256 tokenId) internal { // _setBasePowerLevel(tokenId, 5); // } modifier tokenExists(uint256 tokenId) { require(_exists(tokenId), 'Token does not exist.'); _; } function getStats(uint256 tokenId) public view tokenExists(tokenId) returns (Stats memory) { Stats memory stats = _getStats(tokenId); return stats; } function getGemRate() public view returns (uint256) { return _getGemRate(); } function getBasePowerLevel(uint256 tokenId) public view tokenExists(tokenId) returns (uint8) { return _getBasePowerLevel(tokenId); } function onERC1155Received( address _operator, address _from, uint256 _id, uint256 _value, bytes calldata _data ) external override returns (bytes4) { require(_operator == _from, 'NOT_AUTHORISED'); require( msg.sender == address(MAGIC_FOLK_MAINHAND) || msg.sender == address(MAGIC_FOLK_OFFHAND) || msg.sender == address(MAGIC_FOLK_PET), 'INVALID_TOKEN_TYPE' ); (uint256 _nftTokenId, Item memory _item) = decodeOwnerIdAndItem(_data); require( ownerOf(_nftTokenId) == _from || _tokenOwners[_nftTokenId] == _from, 'NOT_YOUR_NFT' ); require(_item.itemId == _id, 'INVALID_DECODED_ID'); require(_value == 1, 'CAN_ONLY_EQUIP_ONE'); require( _item.itemType == MagicFolkItems(msg.sender)._itemType(), 'INVALID_ITEMTYPE' ); _equip(_item, _nftTokenId); return ERC1155_RECEIVED_VALUE; } function unequip(address from, bytes calldata data) external { require( msg.sender == address(MAGIC_FOLK_MAINHAND) || msg.sender == address(MAGIC_FOLK_OFFHAND) || msg.sender == address(MAGIC_FOLK_PET), 'Invalid caller' ); (uint256 nftTokenId, Item memory item) = decodeOwnerIdAndItem(data); require( ownerOf(nftTokenId) == from || _tokenOwners[nftTokenId] == from, 'NOT_YOUR_NFT' ); _unequip(item, nftTokenId); IERC1155(msg.sender).safeTransferFrom( address(this), from, item.itemId, 1, '' ); emit Unequipped(nftTokenId, item.itemId, item.itemType); } function onERC1155BatchReceived( address, address, uint256[] memory, uint256[] memory, bytes calldata ) external pure override returns (bytes4) { revert(); } function withdraw() public onlyRole(DEFAULT_ADMIN_ROLE) { uint256 amount; uint256 balance = address(this).balance; bool success = false; if (!_initialFeesWithdrawn) { if (balance <= _fees) { amount = balance; } else { amount = _fees; } (success, ) = payable(FEE_ADDRESS).call{value: amount}(''); require(success, 'NOPE'); _initialFeesWithdrawn = true; } else { for (uint256 i = 0; i < _payees.length; i++) { (success, ) = payable(_payees[i].wallet).call{ value: (balance * _payees[i].percentagePoints) / 1000 }(''); require(success); } } } function setFees(uint256 newFees) public onlyRole(DEFAULT_ADMIN_ROLE) { _fees = newFees; } // function _beforeTokenTransfer( // address from, // address to, // uint256 tokenId // ) internal override(ERC721A) { // super._beforeTokenTransfer(from, to, tokenId); // } function supportsInterface(bytes4 interfaceID) public view virtual override(ERC721A, IERC165, ERC165, AccessControl) returns (bool) { return super.supportsInterface(interfaceID) || interfaceID == type(IERC1155Receiver).interfaceId || interfaceID == 0x01ffc9a7 || // ERC165 interfaceID == 0x4e2312e0; // ERC1155_ACCEPTED ^ ERC1155_BATCH_ACCEPTED;; } function _isTokenStaked(uint256 tokenId) internal view returns (bool) { return ownerOf(tokenId) == address(this); } function _unstakeToken(address user, uint256 tokenId) internal { require(_isTokenStaked(tokenId), 'NOT_STAKED'); // require(_tokenOwners[tokenId] == user, "NOT_AUTHORISED"); _approveUnstake(tokenId); uint256 allocation = _calcAllocation(tokenId); // require(allocation > 0, "CANT_UNSTAKE_YET"); if (allocation > 0) { MAGIC_FOLK_GEMS.mint(_msgSender(), allocation); } uint256 i = 0; uint256 lastTokenIndex = _stakedTokens[user].length - 1; while (_stakedTokens[user][i] != tokenId) { i++; } _stakedTokens[user][i] = _stakedTokens[user][lastTokenIndex]; _stakedTokens[user].pop(); _lastClaims[tokenId] = 0; delete _tokenOwners[tokenId]; transferFrom(address(this), user, tokenId); } function _publicSaleActive() internal view returns (bool) { return _publicSale; } function _privateSaleActive() internal view returns (bool) { return _privateSale; } function _equip(Item memory _item, uint256 _nftTokenId) internal { require(!(_isEquipped(_nftTokenId, _item.itemType)), 'Slot is not empty'); Stats memory stats = _getItemStats(_nftTokenId); if (_item.itemType == ItemType.Mainhand) { stats.mainHand = _item; } else if (_item.itemType == ItemType.Offhand) { stats.offHand = _item; } else if (_item.itemType == ItemType.Pet) { stats.pet = _item; } else { revert(); } stats.powerLevel += _item.powerLevel; _setStats(_nftTokenId, stats); emit Equipped(_nftTokenId, _item.itemId, _item.itemType); } function _unequip(Item memory _item, uint256 _nftTokenId) internal { require(_isEquipped(_nftTokenId, _item.itemType), 'Slot is empty'); Stats memory stats = _getItemStats(_nftTokenId); if (_item.itemType == ItemType.Mainhand) { require(stats.mainHand.itemId == _item.itemId, 'Incorrect item'); stats.mainHand = _emptyItem(); } else if (_item.itemType == ItemType.Offhand) { require(stats.offHand.itemId == _item.itemId, 'Incorrect item'); stats.offHand = _emptyItem(); } else if (_item.itemType == ItemType.Pet) { require(stats.pet.itemId == _item.itemId, 'Incorrect item'); stats.pet = _emptyItem(); } else { revert(); } stats.powerLevel -= _item.powerLevel; _setStats(_nftTokenId, stats); } function _isEquipped(uint256 nftTokenId, ItemType slot) internal view tokenExists(nftTokenId) returns (bool) { Stats memory stats = _getItemStats(nftTokenId); if (slot == ItemType.Mainhand) { return stats.mainHand.itemType == ItemType.Mainhand; } else if (slot == ItemType.Offhand) { return stats.offHand.itemType == ItemType.Offhand; } else { return stats.pet.itemType == ItemType.Pet; } } function _getItemStats(uint256 tokenId) internal view tokenExists(tokenId) returns (Stats memory) { Stats memory stats = _tokenStats[tokenId]; return stats; } function _getStats(uint256 tokenId) internal view tokenExists(tokenId) returns (Stats memory) { Stats memory stats = _getItemStats(tokenId); stats.powerLevel = stats.powerLevel + _getBasePowerLevel(tokenId); return stats; } function _setStats(uint256 tokenId, Stats memory stats) internal tokenExists(tokenId) { _tokenStats[tokenId] = stats; } function _setBasePowerLevel(uint256 tokenId, uint8 _powerLevel) internal tokenExists(tokenId) { _basePowerLevels[tokenId] = _powerLevel; } function _getBasePowerLevel(uint256 tokenId) internal view tokenExists(tokenId) returns (uint8) { uint8 basePowerLevel = _basePowerLevels[tokenId]; if (basePowerLevel == 0) { return DEFAULT_POWER_LEVEL; } else { return basePowerLevel; } } function _calcAllocation(uint256 tokenId) internal view returns (uint256) { Stats memory stats = _getStats(tokenId); uint256 timeDeltaDays = (block.timestamp - _getLastClaim(tokenId)) / SECONDS_PER_DAY; return timeDeltaDays * stats.powerLevel * _gemRate; } function _getLastClaim(uint256 tokenId) internal view tokenExists(tokenId) returns (uint256) { return _lastClaims[tokenId]; } function _setLastClaim(uint256 tokenId) internal tokenExists(tokenId) { _lastClaims[tokenId] = block.timestamp; } function _setGemRate(uint256 newGemRate) internal { _gemRate = newGemRate; } function _getGemRate() internal view returns (uint256) { return _gemRate; } function _emptyItem() internal pure returns (Item memory) { return Item(0, 0, ItemType.Empty); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; enum ItemType { Empty, // 0 Mainhand, // 1 Offhand, // 2 Pet // 3 } /// 288 bytes struct Item { uint256 itemId; uint8 powerLevel; ItemType itemType; } /// ownerId is the tokenId of the nft that the item is being equipped to, this /// nft essentially "owns" the item while it's held in the MagicFolk contract function encodeOwnerIdAndItem( uint256 ownerId, Item memory item ) pure returns (bytes memory) { // bytes memory _ownerId = abi.encodePacked(ownerId); // bytes memory _item = abi.encode(item); // return bytes.concat(_ownerId, _item); return abi.encode(ownerId, item); } function decodeOwnerIdAndItem( bytes calldata _data ) pure returns (uint256, Item memory) { uint256 ownerId = abi.decode(_data[:32], (uint256)); // Item memory item = abi.decode(_data[32:], (Item)); // Life is pain... Item memory item; item.itemId = abi.decode(_data[32:64], (uint256)); item.powerLevel = abi.decode(_data[64:96], (uint8)); item.itemType = abi.decode(_data[96:], (ItemType)); return (ownerId, item); } contract CommonConstants { bytes4 constant internal ERC1155_RECEIVED_VALUE = 0xf23a6e61; bytes4 constant internal ERC1155_BATCH_RECEIVED_VALUE = 0xbc197c81; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; contract SigVer { using ECDSA for bytes32; function verifyMsg( address sender, uint256 value, bytes32 msgHash, bytes memory signature, address _signer ) public pure returns (bool) { return _verifyMsg(sender, value, msgHash, signature, _signer); } function hashMsg( address sender, uint256 value ) public pure returns (bytes32) { return _hashMsg(sender, value); } function verifySigner( bytes32 msgHash, bytes memory signature, address _signer ) public pure returns (bool) { return _verifySigner(msgHash, signature, _signer); } function _verifyMsg( address sender, uint256 value, bytes32 msgHash, bytes memory signature, address _signer ) internal pure returns (bool) { return ( _verifySigner(msgHash, signature, _signer) && _hashMsg(sender, value) == msgHash ); } function _hashMsg( address sender, uint256 value ) internal pure returns (bytes32) { return keccak256(abi.encodePacked(sender, value)); } function _verifySigner( bytes32 msgHash, bytes memory signature, address _signer ) internal pure returns (bool) { return msgHash.toEthSignedMessageHash().recover(signature) == _signer; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** @notice By default this ERC20 token cannot be transferred between regular accounts. The Magic Council DAO must vote to enable this feature. */ import "../utils/Common.sol"; import "../utils/SigVer.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/access/AccessControl.sol"; import "@openzeppelin/contracts/security/Pausable.sol"; import "@openzeppelin/contracts/interfaces/IERC721.sol"; import "@openzeppelin/contracts/interfaces/IERC1155.sol"; import "@openzeppelin/contracts/governance/IGovernor.sol"; contract MagicFolkGems is ERC20, AccessControl, Ownable, SigVer { bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE"); bytes32 public constant BURNER_ROLE = keccak256("BURNER_ROLE"); bytes32 public constant DAO_ROLE = keccak256("DAO_ROLE"); IERC721 MAGIC_FOLK_CONTRACT; IERC1155 MAGIC_FOLK_MAINHAND; IERC1155 MAGIC_FOLK_OFFHAND; IERC1155 MAGIC_FOLK_PET; IGovernor DAO; address public _signer; mapping(address => bool) public _freeGemsClaimed; bool public _transferLock; bool public _devMintLock; bool public _freeGemClaim = true; constructor( address magicFolkContract, address magicFolkMainhand, address magicFolkOffhand, address magicFolkPet ) ERC20("MagicFolkGems", "MFGEM") { _grantRole(DEFAULT_ADMIN_ROLE, msg.sender); _grantRole(MINTER_ROLE, magicFolkContract); MAGIC_FOLK_CONTRACT = IERC721(magicFolkContract); _grantRole(BURNER_ROLE, magicFolkMainhand); MAGIC_FOLK_MAINHAND = IERC1155(magicFolkMainhand); _grantRole(BURNER_ROLE, magicFolkOffhand); MAGIC_FOLK_OFFHAND = IERC1155(magicFolkOffhand); _grantRole(BURNER_ROLE, magicFolkPet); MAGIC_FOLK_PET = IERC1155(magicFolkPet); _transferLock = true; } modifier onlyAdminOrDAO() { if ( !(hasRole(DEFAULT_ADMIN_ROLE, _msgSender()) || hasRole(DAO_ROLE, _msgSender())) ) { revert("NOT_AUTHORISED"); } _; } function setMagicFolkAddress(address newAddress) external onlyRole(DEFAULT_ADMIN_ROLE) { _revokeRole(MINTER_ROLE, address(MAGIC_FOLK_CONTRACT)); MAGIC_FOLK_CONTRACT = IERC721(newAddress); _grantRole(MINTER_ROLE, newAddress); } function setMagicFolkItemAddress(address newAddress, ItemType itemType) external onlyRole(DEFAULT_ADMIN_ROLE) { address oldAddress; if (itemType == ItemType.Mainhand) { oldAddress = address(MAGIC_FOLK_MAINHAND); MAGIC_FOLK_MAINHAND = IERC1155(newAddress); } else if (itemType == ItemType.Offhand) { oldAddress = address(MAGIC_FOLK_OFFHAND); MAGIC_FOLK_OFFHAND = IERC1155(newAddress); } else if (itemType == ItemType.Pet) { oldAddress = address(MAGIC_FOLK_PET); MAGIC_FOLK_PET = IERC1155(newAddress); } else { revert(); } _revokeRole(MINTER_ROLE, oldAddress); _revokeRole(BURNER_ROLE, oldAddress); _grantRole(MINTER_ROLE, newAddress); _grantRole(BURNER_ROLE, newAddress); } function setDAO(address _DAO) public onlyRole(DEFAULT_ADMIN_ROLE) { require(address(DAO) == address(0), "DAO_ALREADY_SET"); DAO = IGovernor(_DAO); _grantRole(DAO_ROLE, _DAO); } function claimFreeGems( uint256 qty, bytes32 msgHash, bytes calldata signature ) external { address to = _msgSender(); require(_freeGemClaim, "FREE_GEMZ_DISABLED"); require( _verifyMsg(to, qty, msgHash, signature, _signer), "INVALID_SIG" ); require(!_freeGemsClaimed[to], "GEMZ_ALREADY_CLAIMED"); _mint(to, qty); _freeGemsClaimed[to] = true; } function toggleFreeGems() public onlyRole(DEFAULT_ADMIN_ROLE) { _freeGemClaim = !_freeGemClaim; } function enableTransfers() public onlyRole(DAO_ROLE) { require(_transferLock, "ALREADY_ENABLED"); _transferLock = false; } function disableTransfers() public onlyRole(DAO_ROLE) { require(!_transferLock, "ALREADY_DISABLED"); _transferLock = true; } function mint(address to, uint256 amount) public onlyRole(MINTER_ROLE) { _mint(to, amount); } function decimals() public pure override returns (uint8) { return 0; } function transfer(address to, uint256 amount) public override returns (bool) { require(!_transferLock, "TRANSFERS_LOCKED"); return super.transfer(to, amount); } function transferFrom( address from, address to, uint256 amount ) public override returns (bool) { require(!_transferLock, "TRANSFERS_LOCKED"); return super.transferFrom(from, to, amount); } function addBurner(address newBurner) external onlyAdminOrDAO { _grantRole(BURNER_ROLE, newBurner); } function removeBurner(address oldBurner) external onlyAdminOrDAO { _revokeRole(BURNER_ROLE, oldBurner); } function burn(address from, uint256 amount) public onlyRole(BURNER_ROLE) { _burn(from, amount); } function setSignerAddress(address signer) external onlyRole(DEFAULT_ADMIN_ROLE) { _signer = signer; } function lockDevMint() public onlyRole(DEFAULT_ADMIN_ROLE) { require(!_devMintLock, "DEVMINT_LOCKED"); _devMintLock = true; } function devMint(address to, uint256 amount) public onlyRole(DEFAULT_ADMIN_ROLE) { require(!_devMintLock, "DEVMINT_LOCKED"); _mint(to, amount); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../utils/Common.sol"; import "../utils/SigVer.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol"; import "@openzeppelin/contracts/access/AccessControl.sol"; import "@openzeppelin/contracts/security/Pausable.sol"; import "@openzeppelin/contracts/token/ERC1155/extensions/ERC1155Supply.sol"; import "@openzeppelin/contracts/token/ERC1155/utils/ERC1155Holder.sol"; import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; import "@openzeppelin/contracts/utils/Counters.sol"; import "./MagicFolk.sol"; import "./MagicFolkGems.sol"; contract MagicFolkItems is ERC1155, ERC1155Holder, SigVer, Ownable, AccessControl, Pausable, ERC1155Supply, ReentrancyGuard { using ECDSA for bytes32; using Counters for Counters.Counter; MagicFolk _magicFolk; MagicFolkGems _magicFolkGems; address _signer; Counters.Counter private _itemCount; ItemType public immutable _itemType; string public _contractURI; mapping(uint256 => Item) public _items; mapping(uint256 => uint256) public _prices; mapping(uint256 => address) public _collabs; mapping(uint256 => uint256) public _collabAllowancePerNFT; // NFT Address => (tokenID => Amount Redeemed) mapping(address => mapping(uint256 => uint256)) public _collabItemsRedeemed; constructor(address signer, ItemType itemType) ERC1155("https://api.magicfolk.com/") { _grantRole(DEFAULT_ADMIN_ROLE, _msgSender()); _itemType = itemType; _pause(); _signer = signer; } function setMagicFolkGemsAddress(address magicFolkGems) public onlyRole(DEFAULT_ADMIN_ROLE) { _magicFolkGems = MagicFolkGems(magicFolkGems); } function setMagicFolkContractAddress(address magicFolk) public onlyRole(DEFAULT_ADMIN_ROLE) { _magicFolk = MagicFolk(magicFolk); } function setSignerAddress(address newSigner) external onlyRole(DEFAULT_ADMIN_ROLE) { _signer = newSigner; } function setURI(string memory newuri) public onlyRole(DEFAULT_ADMIN_ROLE) { _setURI(newuri); } function setContractURI(string memory newuri) public onlyRole(DEFAULT_ADMIN_ROLE) { _contractURI = newuri; } function contractURI() public view returns (string memory) { return _contractURI; } function pause() public onlyRole(DEFAULT_ADMIN_ROLE) { _pause(); } function unpause() public onlyRole(DEFAULT_ADMIN_ROLE) { _unpause(); } /** @dev function for equipping items to ERC721 NFT @param from address of NFT holder (must be sender also) @param itemId id of item they wish to equip @param magicFolkId tokenId of NFT they wish to equip the item to */ function equip( address from, uint256 itemId, uint256 magicFolkId ) public whenNotPaused { require( from == _msgSender() || isApprovedForAll(from, _msgSender()), "ERC1155: caller is not owner nor approved" ); Item memory item = _getItem(itemId); bytes memory ownerIdAndItem = encodeOwnerIdAndItem(magicFolkId, item); _safeTransferFrom(from, address(_magicFolk), itemId, 1, ownerIdAndItem); } /** @dev function for unequipping items from ERC721 NFT @param from address of holder (must be sender) @param itemId id of item they wish to unequip @param magicFolkId tokenId of NFT they wish to unequip the item from */ function unequip( address from, uint256 itemId, uint256 magicFolkId ) public whenNotPaused { require( from == _msgSender() || isApprovedForAll(from, _msgSender()), "ERC1155: caller is not owner nor approved" ); Item memory item = _getItem(itemId); bytes memory ownerIdAndItem = encodeOwnerIdAndItem(magicFolkId, item); _magicFolk.unequip(from, ownerIdAndItem); } /** @return total number of items in this contract */ function itemCount() public view returns (uint256) { return _itemCount.current(); } function getItem(uint256 itemId) public view returns (Item memory) { require(_isInitialised(itemId), "Item not initalised"); return _getItem(itemId); } function _getItem(uint256 itemId) internal view returns (Item memory) { return _items[itemId]; } function _setPrice(uint256 itemId, uint256 price) internal { _prices[itemId] = price; } function setPrice(uint256 itemId, uint256 price) public onlyRole(DEFAULT_ADMIN_ROLE) { _setPrice(itemId, price); } function _getPrice(uint256 itemId) internal view returns (uint256) { return _prices[itemId]; } function getPrice(uint256 itemId) public view returns (uint256) { return _getPrice(itemId); } function getStockLeft(uint256 itemId) public view returns (uint256) { return balanceOf(address(this), itemId); } /** @dev Returns an array, A, in which A[id] is the balance of item with itemId of id. e.g. If there are 10 items that have been created, and I own 2 of the item with an itemId of 4, but zero of all other items, the array would look like: [0, 0, 0, 0, 1, 0, 0, 0, 0, 0] */ function getOwnedItems(address owner) public view returns (uint256[] memory) { uint256[] memory tokens = new uint256[](_itemCount.current()); for (uint256 i = 0; i < tokens.length; i++) { tokens[i] = balanceOf(owner, i); } return tokens; } /** @dev a bit like the mint function on our ERC721 contract, this is when the buyer actually pays for and receives an item that we've already minted a supply of in our store. @param to buyer's address @param itemId id of item they wish to buy @param amount amount they wish to buy */ function buyItem( address to, uint256 itemId, uint256 amount ) external nonReentrant { require(!_isCollabItem(itemId), "COLLAB_ITEM"); uint256 totalPrice = amount * _getPrice(itemId); uint256 gemBalance = _magicFolkGems.balanceOf(to); require(gemBalance >= totalPrice, "Insufficient funds"); require(_isInitialised(itemId), "Item not initialised"); _safeTransferFrom(address(this), to, itemId, amount, ""); _magicFolkGems.burn(to, totalPrice); } /** @dev A "whitelist" version of buyItem() for collab items @param itemId id of the collab item @param amount qty they wish to buy @param tokenId tokenId of collab NFT they're using to "redeem" this item, this is so we can check ownership and track how many items have been "redeemed" for each token in a collection we've collab'd with @param msgHash hashed message, should match the message that's been signed by our keypair on frontend. (['address', 'uint256'], [buyerAddress, tokenId]) @param signature signed version of msgHash */ function buyCollabItem( uint256 itemId, uint256 amount, uint256 tokenId, bytes32 msgHash, bytes calldata signature ) external nonReentrant { address to = msg.sender; require(_isCollabItem(itemId), "NOT_COLLAB_ITEM"); require(_ownsToken(to, _collabs[itemId], tokenId), "NOT_YOUR_TOKEN"); uint256 totalPrice = amount * _getPrice(itemId); uint256 gemBalance = _magicFolkGems.balanceOf(to); require(gemBalance >= totalPrice, "INSUFFICIENT_FUNDS"); require(_isInitialised(itemId), "Item not initialised"); require( amount + _getRedeemed(itemId, tokenId) <= _collabAllowancePerNFT[itemId], "TX_WILL_EXCEED_ALLOWANCE" ); require( _verifyMsg(to, tokenId, msgHash, signature, _signer), "INVALID_SIG" ); _safeTransferFrom(address(this), to, itemId, amount, ""); _magicFolkGems.burn(to, totalPrice); _redeemCollabItem(itemId, tokenId, amount); } /** @dev Once an item has been 'created' with the mint function, this function can be used to change the stats for the item. @param itemId the id assigned to this item in the mint function @param powerLevel the power level to be assigned to this item @param itemType ItemType.Mainhand || ItemType.offhand || ItemType.pet, should be the same as the contracts _itemType value @param price price in gems that buyers will have to pay, can be altered later with setPrice() also. */ function setItem( uint256 itemId, uint8 powerLevel, ItemType itemType, uint256 price ) public onlyRole(DEFAULT_ADMIN_ROLE) { _setItem(itemId, powerLevel, itemType, price); } function _setItem( uint256 itemId, uint8 powerLevel, ItemType itemType, uint256 price ) internal { require(itemType == _itemType); Item memory item; item.itemId = itemId; item.powerLevel = powerLevel; item.itemType = itemType; _items[itemId] = item; _setPrice(itemId, price); } /** @dev Mint more tokens for an item that has been created @param itemId The id for the item you're minting @param amount The quantity to be minted */ function mint(uint256 itemId, uint256 amount) public whenNotPaused onlyRole(DEFAULT_ADMIN_ROLE) { require(itemId < _itemCount.current(), "ITEM_NOT_EXIST"); _mint(address(this), itemId, amount, ""); } /** @dev Create a new *non*-collab item with stats provided. Stats can be updated later with setItem() if a mistake has been made. @param initialSupply The initial token supply for this item. More can be minted in future if needed. But in most situations this will be the only stock we create for an item. @param powerLevel Power level stat for item. @param itemType ItemType enum for this item, simply ensures the correct contract is being used. Tx will revert if incorrect itemType is provided. @param price Initial price for item in $GEMZ */ function createItem( uint256 initialSupply, uint8 powerLevel, ItemType itemType, uint256 price ) public onlyRole(DEFAULT_ADMIN_ROLE) { uint256 itemId = _itemCount.current(); _setItem(itemId, powerLevel, itemType, price); _mint(address(this), itemId, initialSupply, ""); _itemCount.increment(); } /** @dev Overload of standard createItem function with 2 extra parameters, creates a collab item. Apart from this, it's exactly the same. First 4 params are the same. @param initialSupply The initial token supply for this item. More can be minted in future if needed. But in most situations this will be the only stock we create for an item. @param powerLevel Power level stat for item. @param itemType ItemType enum for this item, simply ensures the correct contract is being used. Tx will revert if incorrect itemType is provided. @param price Initial price for item in $GEMZ. For collab items this will sometimes be zero. @param nftContract Address of contract for the Collab NFT. For example, if the collab is with BAYC the address would be: 0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D (mainnet) @param allowancePerNFT The amount of items someone can mint for every eligible NFT they hold. In 99% of cases, this will be 1, but there may be some situations where we want a higher number. */ function createItem( uint256 initialSupply, uint8 powerLevel, ItemType itemType, uint256 price, address nftContract, uint256 allowancePerNFT ) public onlyRole(DEFAULT_ADMIN_ROLE) { uint256 itemId = _itemCount.current(); _addCollabItem(itemId, nftContract, allowancePerNFT); _setItem(itemId, powerLevel, itemType, price); _mint(address(this), itemId, initialSupply, ""); _itemCount.increment(); } function mintBatch( address, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) public onlyRole(DEFAULT_ADMIN_ROLE) { _mintBatch(address(this), ids, amounts, data); } function _ownsToken( address to, address nftContract, uint256 tokenId ) internal view returns (bool) { return IERC721(nftContract).ownerOf(tokenId) == to; } function _addCollabItem( uint256 itemId, address nftContract, uint256 allowance ) internal { _collabs[itemId] = nftContract; _collabAllowancePerNFT[itemId] = allowance; } function _redeemCollabItem( uint256 itemId, uint256 tokenId, uint256 qty ) internal { _collabItemsRedeemed[_collabs[itemId]][tokenId] += qty; } function _getRedeemed(uint256 itemId, uint256 tokenId) internal view returns (uint256) { return _collabItemsRedeemed[_collabs[itemId]][tokenId]; } function isCollabItem(uint256 itemId) external view returns (bool) { return _isCollabItem(itemId); } function _isCollabItem(uint256 itemId) internal view returns (bool) { return _collabs[itemId] != address(0); } function _isInitialised(uint256 itemId) internal view returns (bool) { Item memory item = _getItem(itemId); return (item.itemType != ItemType.Empty); } function _beforeTokenTransfer( address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal override(ERC1155, ERC1155Supply) whenNotPaused { super._beforeTokenTransfer(operator, from, to, ids, amounts, data); } function supportsInterface(bytes4 interfaceID) public view virtual override(ERC1155, ERC1155Receiver, AccessControl) returns (bool) { return super.supportsInterface(interfaceID) || interfaceID == type(IERC1155Receiver).interfaceId || // ERC165 interfaceID == 0x01ffc9a7 || // ERC1155_ACCEPTED ^ ERC1155_BATCH_ACCEPTED; interfaceID == 0x4e2312e0; } /// TEST FUNCTIONS /// TODO: remove before mainnet function encodeItem(uint256 itemId) public view returns (bytes memory) { return encodeOwnerIdAndItem(0, _items[itemId]); } function decodeItem(bytes calldata encodedOwnerIdAndItem) public pure returns (uint256, Item memory) { require(encodedOwnerIdAndItem.length == 128, "wronglen"); return decodeOwnerIdAndItem(encodedOwnerIdAndItem); } }
// SPDX-License-Identifier: MIT // ERC721A Contracts v4.2.0 // Creator: Chiru Labs pragma solidity ^0.8.4; import './IERC721AQueryable.sol'; import './ERC721AStakable.sol'; /** * @title ERC721AQueryable. * * @dev ERC721A subclass with convenience query functions. */ abstract contract ERC721AQueryable is ERC721A, IERC721AQueryable { /** * @dev Returns the `TokenOwnership` struct at `tokenId` without reverting. * * If the `tokenId` is out of bounds: * * - `addr = address(0)` * - `startTimestamp = 0` * - `burned = false` * - `extraData = 0` * * If the `tokenId` is burned: * * - `addr = <Address of owner before token was burned>` * - `startTimestamp = <Timestamp when token was burned>` * - `burned = true` * - `extraData = <Extra data when token was burned>` * * Otherwise: * * - `addr = <Address of owner>` * - `startTimestamp = <Timestamp of start of ownership>` * - `burned = false` * - `extraData = <Extra data at start of ownership>` */ function explicitOwnershipOf(uint256 tokenId) public view virtual override returns (TokenOwnership memory) { TokenOwnership memory ownership; if (tokenId < _startTokenId() || tokenId >= _nextTokenId()) { return ownership; } ownership = _ownershipAt(tokenId); if (ownership.burned) { return ownership; } return _ownershipOf(tokenId); } /** * @dev Returns an array of `TokenOwnership` structs at `tokenIds` in order. * See {ERC721AQueryable-explicitOwnershipOf} */ function explicitOwnershipsOf(uint256[] calldata tokenIds) external view virtual override returns (TokenOwnership[] memory) { unchecked { uint256 tokenIdsLength = tokenIds.length; TokenOwnership[] memory ownerships = new TokenOwnership[](tokenIdsLength); for (uint256 i; i != tokenIdsLength; ++i) { ownerships[i] = explicitOwnershipOf(tokenIds[i]); } return ownerships; } } /** * @dev Returns an array of token IDs owned by `owner`, * in the range [`start`, `stop`) * (i.e. `start <= tokenId < stop`). * * This function allows for tokens to be queried if the collection * grows too big for a single call of {ERC721AQueryable-tokensOfOwner}. * * Requirements: * * - `start < stop` */ function tokensOfOwnerIn( address owner, uint256 start, uint256 stop ) external view virtual override returns (uint256[] memory) { unchecked { if (start >= stop) revert InvalidQueryRange(); uint256 tokenIdsIdx; uint256 stopLimit = _nextTokenId(); // Set `start = max(start, _startTokenId())`. if (start < _startTokenId()) { start = _startTokenId(); } // Set `stop = min(stop, stopLimit)`. if (stop > stopLimit) { stop = stopLimit; } uint256 tokenIdsMaxLength = balanceOf(owner); // Set `tokenIdsMaxLength = min(balanceOf(owner), stop - start)`, // to cater for cases where `balanceOf(owner)` is too big. if (start < stop) { uint256 rangeLength = stop - start; if (rangeLength < tokenIdsMaxLength) { tokenIdsMaxLength = rangeLength; } } else { tokenIdsMaxLength = 0; } uint256[] memory tokenIds = new uint256[](tokenIdsMaxLength); if (tokenIdsMaxLength == 0) { return tokenIds; } // We need to call `explicitOwnershipOf(start)`, // because the slot at `start` may not be initialized. TokenOwnership memory ownership = explicitOwnershipOf(start); address currOwnershipAddr; // If the starting slot exists (i.e. not burned), initialize `currOwnershipAddr`. // `ownership.address` will not be zero, as `start` is clamped to the valid token ID range. if (!ownership.burned) { currOwnershipAddr = ownership.addr; } for (uint256 i = start; i != stop && tokenIdsIdx != tokenIdsMaxLength; ++i) { ownership = _ownershipAt(i); if (ownership.burned) { continue; } if (ownership.addr != address(0)) { currOwnershipAddr = ownership.addr; } if (currOwnershipAddr == owner) { tokenIds[tokenIdsIdx++] = i; } } // Downsize the array to fit. assembly { mstore(tokenIds, tokenIdsIdx) } return tokenIds; } } /** * @dev Returns an array of token IDs owned by `owner`. * * This function scans the ownership mapping and is O(`totalSupply`) in complexity. * It is meant to be called off-chain. * * See {ERC721AQueryable-tokensOfOwnerIn} for splitting the scan into * multiple smaller scans if the collection is large enough to cause * an out-of-gas error (10K collections should be fine). */ function tokensOfOwner(address owner) external view virtual override returns (uint256[] memory) { unchecked { uint256 tokenIdsIdx; address currOwnershipAddr; uint256 tokenIdsLength = balanceOf(owner); uint256[] memory tokenIds = new uint256[](tokenIdsLength); TokenOwnership memory ownership; for (uint256 i = _startTokenId(); tokenIdsIdx != tokenIdsLength; ++i) { ownership = _ownershipAt(i); if (ownership.burned) { continue; } if (ownership.addr != address(0)) { currOwnershipAddr = ownership.addr; } if (currOwnershipAddr == owner) { tokenIds[tokenIdsIdx++] = i; } } return tokenIds; } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { _checkOwner(); _; } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if the sender is not the owner. */ function _checkOwner() internal view virtual { require(owner() == _msgSender(), "Ownable: caller is not the owner"); } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (interfaces/IERC721.sol) pragma solidity ^0.8.0; import "../token/ERC721/IERC721.sol";
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (interfaces/IERC1155.sol) pragma solidity ^0.8.0; import "../token/ERC1155/IERC1155.sol";
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/ERC721Enumerable.sol) pragma solidity ^0.8.0; import "../ERC721.sol"; import "./IERC721Enumerable.sol"; /** * @dev This implements an optional extension of {ERC721} defined in the EIP that adds * enumerability of all the token ids in the contract as well as all token ids owned by each * account. */ abstract contract ERC721Enumerable is ERC721, IERC721Enumerable { // Mapping from owner to list of owned token IDs mapping(address => mapping(uint256 => uint256)) private _ownedTokens; // Mapping from token ID to index of the owner tokens list mapping(uint256 => uint256) private _ownedTokensIndex; // Array with all token ids, used for enumeration uint256[] private _allTokens; // Mapping from token id to position in the allTokens array mapping(uint256 => uint256) private _allTokensIndex; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) { return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) { require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds"); return _ownedTokens[owner][index]; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _allTokens.length; } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view virtual override returns (uint256) { require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds"); return _allTokens[index]; } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` cannot be the zero address. * - `to` cannot be the zero address. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual override { super._beforeTokenTransfer(from, to, tokenId); if (from == address(0)) { _addTokenToAllTokensEnumeration(tokenId); } else if (from != to) { _removeTokenFromOwnerEnumeration(from, tokenId); } if (to == address(0)) { _removeTokenFromAllTokensEnumeration(tokenId); } else if (to != from) { _addTokenToOwnerEnumeration(to, tokenId); } } /** * @dev Private function to add a token to this extension's ownership-tracking data structures. * @param to address representing the new owner of the given token ID * @param tokenId uint256 ID of the token to be added to the tokens list of the given address */ function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private { uint256 length = ERC721.balanceOf(to); _ownedTokens[to][length] = tokenId; _ownedTokensIndex[tokenId] = length; } /** * @dev Private function to add a token to this extension's token tracking data structures. * @param tokenId uint256 ID of the token to be added to the tokens list */ function _addTokenToAllTokensEnumeration(uint256 tokenId) private { _allTokensIndex[tokenId] = _allTokens.length; _allTokens.push(tokenId); } /** * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for * gas optimizations e.g. when performing a transfer operation (avoiding double writes). * This has O(1) time complexity, but alters the order of the _ownedTokens array. * @param from address representing the previous owner of the given token ID * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address */ function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private { // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = ERC721.balanceOf(from) - 1; uint256 tokenIndex = _ownedTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary if (tokenIndex != lastTokenIndex) { uint256 lastTokenId = _ownedTokens[from][lastTokenIndex]; _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index } // This also deletes the contents at the last position of the array delete _ownedTokensIndex[tokenId]; delete _ownedTokens[from][lastTokenIndex]; } /** * @dev Private function to remove a token from this extension's token tracking data structures. * This has O(1) time complexity, but alters the order of the _allTokens array. * @param tokenId uint256 ID of the token to be removed from the tokens list */ function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private { // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = _allTokens.length - 1; uint256 tokenIndex = _allTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding // an 'if' statement (like in _removeTokenFromOwnerEnumeration) uint256 lastTokenId = _allTokens[lastTokenIndex]; _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index // This also deletes the contents at the last position of the array delete _allTokensIndex[tokenId]; _allTokens.pop(); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/utils/ERC721Holder.sol) pragma solidity ^0.8.0; import "../IERC721Receiver.sol"; /** * @dev Implementation of the {IERC721Receiver} interface. * * Accepts all token transfers. * Make sure the contract is able to use its token with {IERC721-safeTransferFrom}, {IERC721-approve} or {IERC721-setApprovalForAll}. */ contract ERC721Holder is IERC721Receiver { /** * @dev See {IERC721Receiver-onERC721Received}. * * Always returns `IERC721Receiver.onERC721Received.selector`. */ function onERC721Received( address, address, uint256, bytes memory ) public virtual override returns (bytes4) { return this.onERC721Received.selector; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol) pragma solidity ^0.8.0; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuard { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; constructor() { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and making it call a * `private` function that does the actual work. */ modifier nonReentrant() { // On the first call to nonReentrant, _notEntered will be true require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC1155/IERC1155Receiver.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev _Available since v3.1._ */ interface IERC1155Receiver is IERC165 { /** * @dev Handles the receipt of a single ERC1155 token type. This function is * called at the end of a `safeTransferFrom` after the balance has been updated. * * NOTE: To accept the transfer, this must return * `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` * (i.e. 0xf23a6e61, or its own function selector). * * @param operator The address which initiated the transfer (i.e. msg.sender) * @param from The address which previously owned the token * @param id The ID of the token being transferred * @param value The amount of tokens being transferred * @param data Additional data with no specified format * @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed */ function onERC1155Received( address operator, address from, uint256 id, uint256 value, bytes calldata data ) external returns (bytes4); /** * @dev Handles the receipt of a multiple ERC1155 token types. This function * is called at the end of a `safeBatchTransferFrom` after the balances have * been updated. * * NOTE: To accept the transfer(s), this must return * `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` * (i.e. 0xbc197c81, or its own function selector). * * @param operator The address which initiated the batch transfer (i.e. msg.sender) * @param from The address which previously owned the token * @param ids An array containing ids of each token being transferred (order and length must match values array) * @param values An array containing amounts of each token being transferred (order and length must match ids array) * @param data Additional data with no specified format * @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed */ function onERC1155BatchReceived( address operator, address from, uint256[] calldata ids, uint256[] calldata values, bytes calldata data ) external returns (bytes4); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Counters.sol) pragma solidity ^0.8.0; /** * @title Counters * @author Matt Condon (@shrugs) * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number * of elements in a mapping, issuing ERC721 ids, or counting request ids. * * Include with `using Counters for Counters.Counter;` */ library Counters { struct Counter { // This variable should never be directly accessed by users of the library: interactions must be restricted to // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add // this feature: see https://github.com/ethereum/solidity/issues/4637 uint256 _value; // default: 0 } function current(Counter storage counter) internal view returns (uint256) { return counter._value; } function increment(Counter storage counter) internal { unchecked { counter._value += 1; } } function decrement(Counter storage counter) internal { uint256 value = counter._value; require(value > 0, "Counter: decrement overflow"); unchecked { counter._value = value - 1; } } function reset(Counter storage counter) internal { counter._value = 0; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (access/AccessControl.sol) pragma solidity ^0.8.0; import "./IAccessControl.sol"; import "../utils/Context.sol"; import "../utils/Strings.sol"; import "../utils/introspection/ERC165.sol"; /** * @dev Contract module that allows children to implement role-based access * control mechanisms. This is a lightweight version that doesn't allow enumerating role * members except through off-chain means by accessing the contract event logs. Some * applications may benefit from on-chain enumerability, for those cases see * {AccessControlEnumerable}. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ``` * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ``` * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. */ abstract contract AccessControl is Context, IAccessControl, ERC165 { struct RoleData { mapping(address => bool) members; bytes32 adminRole; } mapping(bytes32 => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Modifier that checks that an account has a specific role. Reverts * with a standardized message including the required role. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ * * _Available since v4.1._ */ modifier onlyRole(bytes32 role) { _checkRole(role); _; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view virtual override returns (bool) { return _roles[role].members[account]; } /** * @dev Revert with a standard message if `_msgSender()` is missing `role`. * Overriding this function changes the behavior of the {onlyRole} modifier. * * Format of the revert message is described in {_checkRole}. * * _Available since v4.6._ */ function _checkRole(bytes32 role) internal view virtual { _checkRole(role, _msgSender()); } /** * @dev Revert with a standard message if `account` is missing `role`. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ */ function _checkRole(bytes32 role, address account) internal view virtual { if (!hasRole(role, account)) { revert( string( abi.encodePacked( "AccessControl: account ", Strings.toHexString(uint160(account), 20), " is missing role ", Strings.toHexString(uint256(role), 32) ) ) ); } } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) { return _roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. * * May emit a {RoleGranted} event. */ function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. * * May emit a {RoleRevoked} event. */ function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been revoked `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. * * May emit a {RoleRevoked} event. */ function renounceRole(bytes32 role, address account) public virtual override { require(account == _msgSender(), "AccessControl: can only renounce roles for self"); _revokeRole(role, account); } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. Note that unlike {grantRole}, this function doesn't perform any * checks on the calling account. * * May emit a {RoleGranted} event. * * [WARNING] * ==== * This function should only be called from the constructor when setting * up the initial roles for the system. * * Using this function in any other way is effectively circumventing the admin * system imposed by {AccessControl}. * ==== * * NOTE: This function is deprecated in favor of {_grantRole}. */ function _setupRole(bytes32 role, address account) internal virtual { _grantRole(role, account); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { bytes32 previousAdminRole = getRoleAdmin(role); _roles[role].adminRole = adminRole; emit RoleAdminChanged(role, previousAdminRole, adminRole); } /** * @dev Grants `role` to `account`. * * Internal function without access restriction. * * May emit a {RoleGranted} event. */ function _grantRole(bytes32 role, address account) internal virtual { if (!hasRole(role, account)) { _roles[role].members[account] = true; emit RoleGranted(role, account, _msgSender()); } } /** * @dev Revokes `role` from `account`. * * Internal function without access restriction. * * May emit a {RoleRevoked} event. */ function _revokeRole(bytes32 role, address account) internal virtual { if (hasRole(role, account)) { _roles[role].members[account] = false; emit RoleRevoked(role, account, _msgSender()); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (utils/cryptography/ECDSA.sol) pragma solidity ^0.8.0; import "../Strings.sol"; /** * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations. * * These functions can be used to verify that a message was signed by the holder * of the private keys of a given address. */ library ECDSA { enum RecoverError { NoError, InvalidSignature, InvalidSignatureLength, InvalidSignatureS, InvalidSignatureV } function _throwError(RecoverError error) private pure { if (error == RecoverError.NoError) { return; // no error: do nothing } else if (error == RecoverError.InvalidSignature) { revert("ECDSA: invalid signature"); } else if (error == RecoverError.InvalidSignatureLength) { revert("ECDSA: invalid signature length"); } else if (error == RecoverError.InvalidSignatureS) { revert("ECDSA: invalid signature 's' value"); } else if (error == RecoverError.InvalidSignatureV) { revert("ECDSA: invalid signature 'v' value"); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature` or error string. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. * * Documentation for signature generation: * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js] * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers] * * _Available since v4.3._ */ function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) { // Check the signature length // - case 65: r,s,v signature (standard) // - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._ if (signature.length == 65) { bytes32 r; bytes32 s; uint8 v; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. /// @solidity memory-safe-assembly assembly { r := mload(add(signature, 0x20)) s := mload(add(signature, 0x40)) v := byte(0, mload(add(signature, 0x60))) } return tryRecover(hash, v, r, s); } else if (signature.length == 64) { bytes32 r; bytes32 vs; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. /// @solidity memory-safe-assembly assembly { r := mload(add(signature, 0x20)) vs := mload(add(signature, 0x40)) } return tryRecover(hash, r, vs); } else { return (address(0), RecoverError.InvalidSignatureLength); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature`. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. */ function recover(bytes32 hash, bytes memory signature) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, signature); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately. * * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures] * * _Available since v4.3._ */ function tryRecover( bytes32 hash, bytes32 r, bytes32 vs ) internal pure returns (address, RecoverError) { bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff); uint8 v = uint8((uint256(vs) >> 255) + 27); return tryRecover(hash, v, r, s); } /** * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately. * * _Available since v4.2._ */ function recover( bytes32 hash, bytes32 r, bytes32 vs ) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, r, vs); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `v`, * `r` and `s` signature fields separately. * * _Available since v4.3._ */ function tryRecover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address, RecoverError) { // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most // signatures from current libraries generate a unique signature with an s-value in the lower half order. // // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept // these malleable signatures as well. if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) { return (address(0), RecoverError.InvalidSignatureS); } if (v != 27 && v != 28) { return (address(0), RecoverError.InvalidSignatureV); } // If the signature is valid (and not malleable), return the signer address address signer = ecrecover(hash, v, r, s); if (signer == address(0)) { return (address(0), RecoverError.InvalidSignature); } return (signer, RecoverError.NoError); } /** * @dev Overload of {ECDSA-recover} that receives the `v`, * `r` and `s` signature fields separately. */ function recover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, v, r, s); _throwError(error); return recovered; } /** * @dev Returns an Ethereum Signed Message, created from a `hash`. This * produces hash corresponding to the one signed with the * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] * JSON-RPC method as part of EIP-191. * * See {recover}. */ function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) { // 32 is the length in bytes of hash, // enforced by the type signature above return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash)); } /** * @dev Returns an Ethereum Signed Message, created from `s`. This * produces hash corresponding to the one signed with the * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] * JSON-RPC method as part of EIP-191. * * See {recover}. */ function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", Strings.toString(s.length), s)); } /** * @dev Returns an Ethereum Signed Typed Data, created from a * `domainSeparator` and a `structHash`. This produces hash corresponding * to the one signed with the * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] * JSON-RPC method as part of EIP-712. * * See {recover}. */ function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol) pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; uint8 private constant _ADDRESS_LENGTH = 20; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } /** * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation. */ function toHexString(address addr) internal pure returns (string memory) { return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/ERC20.sol) pragma solidity ^0.8.0; import "./IERC20.sol"; import "./extensions/IERC20Metadata.sol"; import "../../utils/Context.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin Contracts guidelines: functions revert * instead returning `false` on failure. This behavior is nonetheless * conventional and does not conflict with the expectations of ERC20 * applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The default value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `to` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address to, uint256 amount) public virtual override returns (bool) { address owner = _msgSender(); _transfer(owner, to, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on * `transferFrom`. This is semantically equivalent to an infinite approval. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { address owner = _msgSender(); _approve(owner, spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * NOTE: Does not update the allowance if the current allowance * is the maximum `uint256`. * * Requirements: * * - `from` and `to` cannot be the zero address. * - `from` must have a balance of at least `amount`. * - the caller must have allowance for ``from``'s tokens of at least * `amount`. */ function transferFrom( address from, address to, uint256 amount ) public virtual override returns (bool) { address spender = _msgSender(); _spendAllowance(from, spender, amount); _transfer(from, to, amount); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { address owner = _msgSender(); _approve(owner, spender, allowance(owner, spender) + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { address owner = _msgSender(); uint256 currentAllowance = allowance(owner, spender); require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(owner, spender, currentAllowance - subtractedValue); } return true; } /** * @dev Moves `amount` of tokens from `from` to `to`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `from` must have a balance of at least `amount`. */ function _transfer( address from, address to, uint256 amount ) internal virtual { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(from, to, amount); uint256 fromBalance = _balances[from]; require(fromBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[from] = fromBalance - amount; } _balances[to] += amount; emit Transfer(from, to, amount); _afterTokenTransfer(from, to, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); _afterTokenTransfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balances[account] = accountBalance - amount; } _totalSupply -= amount; emit Transfer(account, address(0), amount); _afterTokenTransfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Updates `owner` s allowance for `spender` based on spent `amount`. * * Does not update the allowance amount in case of infinite allowance. * Revert if not enough allowance is available. * * Might emit an {Approval} event. */ function _spendAllowance( address owner, address spender, uint256 amount ) internal virtual { uint256 currentAllowance = allowance(owner, spender); if (currentAllowance != type(uint256).max) { require(currentAllowance >= amount, "ERC20: insufficient allowance"); unchecked { _approve(owner, spender, currentAllowance - amount); } } } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * has been transferred to `to`. * - when `from` is zero, `amount` tokens have been minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens have been burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 amount ) internal virtual {} }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract Pausable is Context { /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. */ constructor() { _paused = false; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { _requireNotPaused(); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { _requirePaused(); _; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { return _paused; } /** * @dev Throws if the contract is paused. */ function _requireNotPaused() internal view virtual { require(!paused(), "Pausable: paused"); } /** * @dev Throws if the contract is not paused. */ function _requirePaused() internal view virtual { require(paused(), "Pausable: not paused"); } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (governance/IGovernor.sol) pragma solidity ^0.8.0; import "../utils/introspection/ERC165.sol"; /** * @dev Interface of the {Governor} core. * * _Available since v4.3._ */ abstract contract IGovernor is IERC165 { enum ProposalState { Pending, Active, Canceled, Defeated, Succeeded, Queued, Expired, Executed } /** * @dev Emitted when a proposal is created. */ event ProposalCreated( uint256 proposalId, address proposer, address[] targets, uint256[] values, string[] signatures, bytes[] calldatas, uint256 startBlock, uint256 endBlock, string description ); /** * @dev Emitted when a proposal is canceled. */ event ProposalCanceled(uint256 proposalId); /** * @dev Emitted when a proposal is executed. */ event ProposalExecuted(uint256 proposalId); /** * @dev Emitted when a vote is cast without params. * * Note: `support` values should be seen as buckets. Their interpretation depends on the voting module used. */ event VoteCast(address indexed voter, uint256 proposalId, uint8 support, uint256 weight, string reason); /** * @dev Emitted when a vote is cast with params. * * Note: `support` values should be seen as buckets. Their interpretation depends on the voting module used. * `params` are additional encoded parameters. Their intepepretation also depends on the voting module used. */ event VoteCastWithParams( address indexed voter, uint256 proposalId, uint8 support, uint256 weight, string reason, bytes params ); /** * @notice module:core * @dev Name of the governor instance (used in building the ERC712 domain separator). */ function name() public view virtual returns (string memory); /** * @notice module:core * @dev Version of the governor instance (used in building the ERC712 domain separator). Default: "1" */ function version() public view virtual returns (string memory); /** * @notice module:voting * @dev A description of the possible `support` values for {castVote} and the way these votes are counted, meant to * be consumed by UIs to show correct vote options and interpret the results. The string is a URL-encoded sequence of * key-value pairs that each describe one aspect, for example `support=bravo&quorum=for,abstain`. * * There are 2 standard keys: `support` and `quorum`. * * - `support=bravo` refers to the vote options 0 = Against, 1 = For, 2 = Abstain, as in `GovernorBravo`. * - `quorum=bravo` means that only For votes are counted towards quorum. * - `quorum=for,abstain` means that both For and Abstain votes are counted towards quorum. * * If a counting module makes use of encoded `params`, it should include this under a `params` key with a unique * name that describes the behavior. For example: * * - `params=fractional` might refer to a scheme where votes are divided fractionally between for/against/abstain. * - `params=erc721` might refer to a scheme where specific NFTs are delegated to vote. * * NOTE: The string can be decoded by the standard * https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams[`URLSearchParams`] * JavaScript class. */ // solhint-disable-next-line func-name-mixedcase function COUNTING_MODE() public pure virtual returns (string memory); /** * @notice module:core * @dev Hashing function used to (re)build the proposal id from the proposal details.. */ function hashProposal( address[] memory targets, uint256[] memory values, bytes[] memory calldatas, bytes32 descriptionHash ) public pure virtual returns (uint256); /** * @notice module:core * @dev Current state of a proposal, following Compound's convention */ function state(uint256 proposalId) public view virtual returns (ProposalState); /** * @notice module:core * @dev Block number used to retrieve user's votes and quorum. As per Compound's Comp and OpenZeppelin's * ERC20Votes, the snapshot is performed at the end of this block. Hence, voting for this proposal starts at the * beginning of the following block. */ function proposalSnapshot(uint256 proposalId) public view virtual returns (uint256); /** * @notice module:core * @dev Block number at which votes close. Votes close at the end of this block, so it is possible to cast a vote * during this block. */ function proposalDeadline(uint256 proposalId) public view virtual returns (uint256); /** * @notice module:user-config * @dev Delay, in number of block, between the proposal is created and the vote starts. This can be increassed to * leave time for users to buy voting power, of delegate it, before the voting of a proposal starts. */ function votingDelay() public view virtual returns (uint256); /** * @notice module:user-config * @dev Delay, in number of blocks, between the vote start and vote ends. * * NOTE: The {votingDelay} can delay the start of the vote. This must be considered when setting the voting * duration compared to the voting delay. */ function votingPeriod() public view virtual returns (uint256); /** * @notice module:user-config * @dev Minimum number of cast voted required for a proposal to be successful. * * Note: The `blockNumber` parameter corresponds to the snapshot used for counting vote. This allows to scale the * quorum depending on values such as the totalSupply of a token at this block (see {ERC20Votes}). */ function quorum(uint256 blockNumber) public view virtual returns (uint256); /** * @notice module:reputation * @dev Voting power of an `account` at a specific `blockNumber`. * * Note: this can be implemented in a number of ways, for example by reading the delegated balance from one (or * multiple), {ERC20Votes} tokens. */ function getVotes(address account, uint256 blockNumber) public view virtual returns (uint256); /** * @notice module:reputation * @dev Voting power of an `account` at a specific `blockNumber` given additional encoded parameters. */ function getVotesWithParams( address account, uint256 blockNumber, bytes memory params ) public view virtual returns (uint256); /** * @notice module:voting * @dev Returns weither `account` has cast a vote on `proposalId`. */ function hasVoted(uint256 proposalId, address account) public view virtual returns (bool); /** * @dev Create a new proposal. Vote start {IGovernor-votingDelay} blocks after the proposal is created and ends * {IGovernor-votingPeriod} blocks after the voting starts. * * Emits a {ProposalCreated} event. */ function propose( address[] memory targets, uint256[] memory values, bytes[] memory calldatas, string memory description ) public virtual returns (uint256 proposalId); /** * @dev Execute a successful proposal. This requires the quorum to be reached, the vote to be successful, and the * deadline to be reached. * * Emits a {ProposalExecuted} event. * * Note: some module can modify the requirements for execution, for example by adding an additional timelock. */ function execute( address[] memory targets, uint256[] memory values, bytes[] memory calldatas, bytes32 descriptionHash ) public payable virtual returns (uint256 proposalId); /** * @dev Cast a vote * * Emits a {VoteCast} event. */ function castVote(uint256 proposalId, uint8 support) public virtual returns (uint256 balance); /** * @dev Cast a vote with a reason * * Emits a {VoteCast} event. */ function castVoteWithReason( uint256 proposalId, uint8 support, string calldata reason ) public virtual returns (uint256 balance); /** * @dev Cast a vote with a reason and additional encoded parameters * * Emits a {VoteCast} or {VoteCastWithParams} event depending on the length of params. */ function castVoteWithReasonAndParams( uint256 proposalId, uint8 support, string calldata reason, bytes memory params ) public virtual returns (uint256 balance); /** * @dev Cast a vote using the user's cryptographic signature. * * Emits a {VoteCast} event. */ function castVoteBySig( uint256 proposalId, uint8 support, uint8 v, bytes32 r, bytes32 s ) public virtual returns (uint256 balance); /** * @dev Cast a vote with a reason and additional encoded parameters using the user's cryptographic signature. * * Emits a {VoteCast} or {VoteCastWithParams} event depending on the length of params. */ function castVoteWithReasonAndParamsBySig( uint256 proposalId, uint8 support, string calldata reason, bytes memory params, uint8 v, bytes32 r, bytes32 s ) public virtual returns (uint256 balance); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 amount ) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol) pragma solidity ^0.8.0; import "../IERC20.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol) pragma solidity ^0.8.0; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControl { /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {AccessControl-_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) external view returns (bool); /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {AccessControl-_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) external view returns (bytes32); /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) external; /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) external; /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (token/ERC1155/IERC1155.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC1155 compliant contract, as defined in the * https://eips.ethereum.org/EIPS/eip-1155[EIP]. * * _Available since v3.1._ */ interface IERC1155 is IERC165 { /** * @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`. */ event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value); /** * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all * transfers. */ event TransferBatch( address indexed operator, address indexed from, address indexed to, uint256[] ids, uint256[] values ); /** * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to * `approved`. */ event ApprovalForAll(address indexed account, address indexed operator, bool approved); /** * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI. * * If an {URI} event was emitted for `id`, the standard * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value * returned by {IERC1155MetadataURI-uri}. */ event URI(string value, uint256 indexed id); /** * @dev Returns the amount of tokens of token type `id` owned by `account`. * * Requirements: * * - `account` cannot be the zero address. */ function balanceOf(address account, uint256 id) external view returns (uint256); /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}. * * Requirements: * * - `accounts` and `ids` must have the same length. */ function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids) external view returns (uint256[] memory); /** * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`, * * Emits an {ApprovalForAll} event. * * Requirements: * * - `operator` cannot be the caller. */ function setApprovalForAll(address operator, bool approved) external; /** * @dev Returns true if `operator` is approved to transfer ``account``'s tokens. * * See {setApprovalForAll}. */ function isApprovedForAll(address account, address operator) external view returns (bool); /** * @dev Transfers `amount` tokens of token type `id` from `from` to `to`. * * Emits a {TransferSingle} event. * * Requirements: * * - `to` cannot be the zero address. * - If the caller is not `from`, it must have been approved to spend ``from``'s tokens via {setApprovalForAll}. * - `from` must have a balance of tokens of type `id` of at least `amount`. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function safeTransferFrom( address from, address to, uint256 id, uint256 amount, bytes calldata data ) external; /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}. * * Emits a {TransferBatch} event. * * Requirements: * * - `ids` and `amounts` must have the same length. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. */ function safeBatchTransferFrom( address from, address to, uint256[] calldata ids, uint256[] calldata amounts, bytes calldata data ) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (token/ERC1155/ERC1155.sol) pragma solidity ^0.8.0; import "./IERC1155.sol"; import "./IERC1155Receiver.sol"; import "./extensions/IERC1155MetadataURI.sol"; import "../../utils/Address.sol"; import "../../utils/Context.sol"; import "../../utils/introspection/ERC165.sol"; /** * @dev Implementation of the basic standard multi-token. * See https://eips.ethereum.org/EIPS/eip-1155 * Originally based on code by Enjin: https://github.com/enjin/erc-1155 * * _Available since v3.1._ */ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { using Address for address; // Mapping from token ID to account balances mapping(uint256 => mapping(address => uint256)) private _balances; // Mapping from account to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; // Used as the URI for all token types by relying on ID substitution, e.g. https://token-cdn-domain/{id}.json string private _uri; /** * @dev See {_setURI}. */ constructor(string memory uri_) { _setURI(uri_); } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC1155).interfaceId || interfaceId == type(IERC1155MetadataURI).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC1155MetadataURI-uri}. * * This implementation returns the same URI for *all* token types. It relies * on the token type ID substitution mechanism * https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP]. * * Clients calling this function must replace the `\{id\}` substring with the * actual token type ID. */ function uri(uint256) public view virtual override returns (string memory) { return _uri; } /** * @dev See {IERC1155-balanceOf}. * * Requirements: * * - `account` cannot be the zero address. */ function balanceOf(address account, uint256 id) public view virtual override returns (uint256) { require(account != address(0), "ERC1155: address zero is not a valid owner"); return _balances[id][account]; } /** * @dev See {IERC1155-balanceOfBatch}. * * Requirements: * * - `accounts` and `ids` must have the same length. */ function balanceOfBatch(address[] memory accounts, uint256[] memory ids) public view virtual override returns (uint256[] memory) { require(accounts.length == ids.length, "ERC1155: accounts and ids length mismatch"); uint256[] memory batchBalances = new uint256[](accounts.length); for (uint256 i = 0; i < accounts.length; ++i) { batchBalances[i] = balanceOf(accounts[i], ids[i]); } return batchBalances; } /** * @dev See {IERC1155-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC1155-isApprovedForAll}. */ function isApprovedForAll(address account, address operator) public view virtual override returns (bool) { return _operatorApprovals[account][operator]; } /** * @dev See {IERC1155-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 id, uint256 amount, bytes memory data ) public virtual override { require( from == _msgSender() || isApprovedForAll(from, _msgSender()), "ERC1155: caller is not token owner nor approved" ); _safeTransferFrom(from, to, id, amount, data); } /** * @dev See {IERC1155-safeBatchTransferFrom}. */ function safeBatchTransferFrom( address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) public virtual override { require( from == _msgSender() || isApprovedForAll(from, _msgSender()), "ERC1155: caller is not token owner nor approved" ); _safeBatchTransferFrom(from, to, ids, amounts, data); } /** * @dev Transfers `amount` tokens of token type `id` from `from` to `to`. * * Emits a {TransferSingle} event. * * Requirements: * * - `to` cannot be the zero address. * - `from` must have a balance of tokens of type `id` of at least `amount`. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function _safeTransferFrom( address from, address to, uint256 id, uint256 amount, bytes memory data ) internal virtual { require(to != address(0), "ERC1155: transfer to the zero address"); address operator = _msgSender(); uint256[] memory ids = _asSingletonArray(id); uint256[] memory amounts = _asSingletonArray(amount); _beforeTokenTransfer(operator, from, to, ids, amounts, data); uint256 fromBalance = _balances[id][from]; require(fromBalance >= amount, "ERC1155: insufficient balance for transfer"); unchecked { _balances[id][from] = fromBalance - amount; } _balances[id][to] += amount; emit TransferSingle(operator, from, to, id, amount); _afterTokenTransfer(operator, from, to, ids, amounts, data); _doSafeTransferAcceptanceCheck(operator, from, to, id, amount, data); } /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_safeTransferFrom}. * * Emits a {TransferBatch} event. * * Requirements: * * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. */ function _safeBatchTransferFrom( address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual { require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch"); require(to != address(0), "ERC1155: transfer to the zero address"); address operator = _msgSender(); _beforeTokenTransfer(operator, from, to, ids, amounts, data); for (uint256 i = 0; i < ids.length; ++i) { uint256 id = ids[i]; uint256 amount = amounts[i]; uint256 fromBalance = _balances[id][from]; require(fromBalance >= amount, "ERC1155: insufficient balance for transfer"); unchecked { _balances[id][from] = fromBalance - amount; } _balances[id][to] += amount; } emit TransferBatch(operator, from, to, ids, amounts); _afterTokenTransfer(operator, from, to, ids, amounts, data); _doSafeBatchTransferAcceptanceCheck(operator, from, to, ids, amounts, data); } /** * @dev Sets a new URI for all token types, by relying on the token type ID * substitution mechanism * https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP]. * * By this mechanism, any occurrence of the `\{id\}` substring in either the * URI or any of the amounts in the JSON file at said URI will be replaced by * clients with the token type ID. * * For example, the `https://token-cdn-domain/\{id\}.json` URI would be * interpreted by clients as * `https://token-cdn-domain/000000000000000000000000000000000000000000000000000000000004cce0.json` * for token type ID 0x4cce0. * * See {uri}. * * Because these URIs cannot be meaningfully represented by the {URI} event, * this function emits no events. */ function _setURI(string memory newuri) internal virtual { _uri = newuri; } /** * @dev Creates `amount` tokens of token type `id`, and assigns them to `to`. * * Emits a {TransferSingle} event. * * Requirements: * * - `to` cannot be the zero address. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function _mint( address to, uint256 id, uint256 amount, bytes memory data ) internal virtual { require(to != address(0), "ERC1155: mint to the zero address"); address operator = _msgSender(); uint256[] memory ids = _asSingletonArray(id); uint256[] memory amounts = _asSingletonArray(amount); _beforeTokenTransfer(operator, address(0), to, ids, amounts, data); _balances[id][to] += amount; emit TransferSingle(operator, address(0), to, id, amount); _afterTokenTransfer(operator, address(0), to, ids, amounts, data); _doSafeTransferAcceptanceCheck(operator, address(0), to, id, amount, data); } /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_mint}. * * Emits a {TransferBatch} event. * * Requirements: * * - `ids` and `amounts` must have the same length. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. */ function _mintBatch( address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual { require(to != address(0), "ERC1155: mint to the zero address"); require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch"); address operator = _msgSender(); _beforeTokenTransfer(operator, address(0), to, ids, amounts, data); for (uint256 i = 0; i < ids.length; i++) { _balances[ids[i]][to] += amounts[i]; } emit TransferBatch(operator, address(0), to, ids, amounts); _afterTokenTransfer(operator, address(0), to, ids, amounts, data); _doSafeBatchTransferAcceptanceCheck(operator, address(0), to, ids, amounts, data); } /** * @dev Destroys `amount` tokens of token type `id` from `from` * * Emits a {TransferSingle} event. * * Requirements: * * - `from` cannot be the zero address. * - `from` must have at least `amount` tokens of token type `id`. */ function _burn( address from, uint256 id, uint256 amount ) internal virtual { require(from != address(0), "ERC1155: burn from the zero address"); address operator = _msgSender(); uint256[] memory ids = _asSingletonArray(id); uint256[] memory amounts = _asSingletonArray(amount); _beforeTokenTransfer(operator, from, address(0), ids, amounts, ""); uint256 fromBalance = _balances[id][from]; require(fromBalance >= amount, "ERC1155: burn amount exceeds balance"); unchecked { _balances[id][from] = fromBalance - amount; } emit TransferSingle(operator, from, address(0), id, amount); _afterTokenTransfer(operator, from, address(0), ids, amounts, ""); } /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_burn}. * * Emits a {TransferBatch} event. * * Requirements: * * - `ids` and `amounts` must have the same length. */ function _burnBatch( address from, uint256[] memory ids, uint256[] memory amounts ) internal virtual { require(from != address(0), "ERC1155: burn from the zero address"); require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch"); address operator = _msgSender(); _beforeTokenTransfer(operator, from, address(0), ids, amounts, ""); for (uint256 i = 0; i < ids.length; i++) { uint256 id = ids[i]; uint256 amount = amounts[i]; uint256 fromBalance = _balances[id][from]; require(fromBalance >= amount, "ERC1155: burn amount exceeds balance"); unchecked { _balances[id][from] = fromBalance - amount; } } emit TransferBatch(operator, from, address(0), ids, amounts); _afterTokenTransfer(operator, from, address(0), ids, amounts, ""); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits an {ApprovalForAll} event. */ function _setApprovalForAll( address owner, address operator, bool approved ) internal virtual { require(owner != operator, "ERC1155: setting approval status for self"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Hook that is called before any token transfer. This includes minting * and burning, as well as batched variants. * * The same hook is called on both single and batched variants. For single * transfers, the length of the `ids` and `amounts` arrays will be 1. * * Calling conditions (for each `id` and `amount` pair): * * - When `from` and `to` are both non-zero, `amount` of ``from``'s tokens * of token type `id` will be transferred to `to`. * - When `from` is zero, `amount` tokens of token type `id` will be minted * for `to`. * - when `to` is zero, `amount` of ``from``'s tokens of token type `id` * will be burned. * - `from` and `to` are never both zero. * - `ids` and `amounts` have the same, non-zero length. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual {} /** * @dev Hook that is called after any token transfer. This includes minting * and burning, as well as batched variants. * * The same hook is called on both single and batched variants. For single * transfers, the length of the `id` and `amount` arrays will be 1. * * Calling conditions (for each `id` and `amount` pair): * * - When `from` and `to` are both non-zero, `amount` of ``from``'s tokens * of token type `id` will be transferred to `to`. * - When `from` is zero, `amount` tokens of token type `id` will be minted * for `to`. * - when `to` is zero, `amount` of ``from``'s tokens of token type `id` * will be burned. * - `from` and `to` are never both zero. * - `ids` and `amounts` have the same, non-zero length. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual {} function _doSafeTransferAcceptanceCheck( address operator, address from, address to, uint256 id, uint256 amount, bytes memory data ) private { if (to.isContract()) { try IERC1155Receiver(to).onERC1155Received(operator, from, id, amount, data) returns (bytes4 response) { if (response != IERC1155Receiver.onERC1155Received.selector) { revert("ERC1155: ERC1155Receiver rejected tokens"); } } catch Error(string memory reason) { revert(reason); } catch { revert("ERC1155: transfer to non ERC1155Receiver implementer"); } } } function _doSafeBatchTransferAcceptanceCheck( address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) private { if (to.isContract()) { try IERC1155Receiver(to).onERC1155BatchReceived(operator, from, ids, amounts, data) returns ( bytes4 response ) { if (response != IERC1155Receiver.onERC1155BatchReceived.selector) { revert("ERC1155: ERC1155Receiver rejected tokens"); } } catch Error(string memory reason) { revert(reason); } catch { revert("ERC1155: transfer to non ERC1155Receiver implementer"); } } } function _asSingletonArray(uint256 element) private pure returns (uint256[] memory) { uint256[] memory array = new uint256[](1); array[0] = element; return array; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC1155/extensions/ERC1155Supply.sol) pragma solidity ^0.8.0; import "../ERC1155.sol"; /** * @dev Extension of ERC1155 that adds tracking of total supply per id. * * Useful for scenarios where Fungible and Non-fungible tokens have to be * clearly identified. Note: While a totalSupply of 1 might mean the * corresponding is an NFT, there is no guarantees that no other token with the * same id are not going to be minted. */ abstract contract ERC1155Supply is ERC1155 { mapping(uint256 => uint256) private _totalSupply; /** * @dev Total amount of tokens in with a given id. */ function totalSupply(uint256 id) public view virtual returns (uint256) { return _totalSupply[id]; } /** * @dev Indicates whether any token exist with a given id, or not. */ function exists(uint256 id) public view virtual returns (bool) { return ERC1155Supply.totalSupply(id) > 0; } /** * @dev See {ERC1155-_beforeTokenTransfer}. */ function _beforeTokenTransfer( address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual override { super._beforeTokenTransfer(operator, from, to, ids, amounts, data); if (from == address(0)) { for (uint256 i = 0; i < ids.length; ++i) { _totalSupply[ids[i]] += amounts[i]; } } if (to == address(0)) { for (uint256 i = 0; i < ids.length; ++i) { uint256 id = ids[i]; uint256 amount = amounts[i]; uint256 supply = _totalSupply[id]; require(supply >= amount, "ERC1155: burn amount exceeds totalSupply"); unchecked { _totalSupply[id] = supply - amount; } } } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC1155/utils/ERC1155Holder.sol) pragma solidity ^0.8.0; import "./ERC1155Receiver.sol"; /** * Simple implementation of `ERC1155Receiver` that will allow a contract to hold ERC1155 tokens. * * IMPORTANT: When inheriting this contract, you must include a way to use the received tokens, otherwise they will be * stuck. * * @dev _Available since v3.1._ */ contract ERC1155Holder is ERC1155Receiver { function onERC1155Received( address, address, uint256, uint256, bytes memory ) public virtual override returns (bytes4) { return this.onERC1155Received.selector; } function onERC1155BatchReceived( address, address, uint256[] memory, uint256[] memory, bytes memory ) public virtual override returns (bytes4) { return this.onERC1155BatchReceived.selector; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC1155/extensions/IERC1155MetadataURI.sol) pragma solidity ^0.8.0; import "../IERC1155.sol"; /** * @dev Interface of the optional ERC1155MetadataExtension interface, as defined * in the https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[EIP]. * * _Available since v3.1._ */ interface IERC1155MetadataURI is IERC1155 { /** * @dev Returns the URI for token type `id`. * * If the `\{id\}` substring is present in the URI, it must be replaced by * clients with the actual token type ID. */ function uri(uint256 id) external view returns (string memory); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC1155/utils/ERC1155Receiver.sol) pragma solidity ^0.8.0; import "../IERC1155Receiver.sol"; import "../../../utils/introspection/ERC165.sol"; /** * @dev _Available since v3.1._ */ abstract contract ERC1155Receiver is ERC165, IERC1155Receiver { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC1155Receiver).interfaceId || super.supportsInterface(interfaceId); } }
// SPDX-License-Identifier: MIT // ERC721A Contracts v4.2.0 // Creator: Chiru Labs pragma solidity ^0.8.4; import './IERC721A.sol'; /** * @dev Interface of ERC721AQueryable. */ interface IERC721AQueryable is IERC721A { /** * Invalid query range (`start` >= `stop`). */ error InvalidQueryRange(); /** * @dev Returns the `TokenOwnership` struct at `tokenId` without reverting. * * If the `tokenId` is out of bounds: * * - `addr = address(0)` * - `startTimestamp = 0` * - `burned = false` * - `extraData = 0` * * If the `tokenId` is burned: * * - `addr = <Address of owner before token was burned>` * - `startTimestamp = <Timestamp when token was burned>` * - `burned = true` * - `extraData = <Extra data when token was burned>` * * Otherwise: * * - `addr = <Address of owner>` * - `startTimestamp = <Timestamp of start of ownership>` * - `burned = false` * - `extraData = <Extra data at start of ownership>` */ function explicitOwnershipOf(uint256 tokenId) external view returns (TokenOwnership memory); /** * @dev Returns an array of `TokenOwnership` structs at `tokenIds` in order. * See {ERC721AQueryable-explicitOwnershipOf} */ function explicitOwnershipsOf(uint256[] memory tokenIds) external view returns (TokenOwnership[] memory); /** * @dev Returns an array of token IDs owned by `owner`, * in the range [`start`, `stop`) * (i.e. `start <= tokenId < stop`). * * This function allows for tokens to be queried if the collection * grows too big for a single call of {ERC721AQueryable-tokensOfOwner}. * * Requirements: * * - `start < stop` */ function tokensOfOwnerIn( address owner, uint256 start, uint256 stop ) external view returns (uint256[] memory); /** * @dev Returns an array of token IDs owned by `owner`. * * This function scans the ownership mapping and is O(`totalSupply`) in complexity. * It is meant to be called off-chain. * * See {ERC721AQueryable-tokensOfOwnerIn} for splitting the scan into * multiple smaller scans if the collection is large enough to cause * an out-of-gas error (10K collections should be fine). */ function tokensOfOwner(address owner) external view returns (uint256[] memory); }
// SPDX-License-Identifier: MIT // ERC721A Contracts v4.2.0 // Creator: Chiru Labs pragma solidity ^0.8.4; import './IERC721A.sol'; /** * @dev Interface of ERC721 token receiver. */ interface ERC721A__IERC721Receiver { function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } /** * @title ERC721A * * @dev Implementation of the [ERC721](https://eips.ethereum.org/EIPS/eip-721) * Non-Fungible Token Standard, including the Metadata extension. * Optimized for lower gas during batch mints. * * Token IDs are minted in sequential order (e.g. 0, 1, 2, 3, ...) * starting from `_startTokenId()`. * * Assumptions: * * - An owner cannot have more than 2**64 - 1 (max value of uint64) of supply. * - The maximum token ID cannot exceed 2**256 - 1 (max value of uint256). */ contract ERC721A is IERC721A { // Reference type for token approval. struct TokenApprovalRef { address value; } // ============================================================= // CONSTANTS // ============================================================= // Mask of an entry in packed address data. uint256 private constant _BITMASK_ADDRESS_DATA_ENTRY = (1 << 64) - 1; // The bit position of `numberMinted` in packed address data. uint256 private constant _BITPOS_NUMBER_MINTED = 64; // The bit position of `numberBurned` in packed address data. uint256 private constant _BITPOS_NUMBER_BURNED = 128; // The bit position of `aux` in packed address data. uint256 private constant _BITPOS_AUX = 192; // Mask of all 256 bits in packed address data except the 64 bits for `aux`. uint256 private constant _BITMASK_AUX_COMPLEMENT = (1 << 192) - 1; // The bit position of `startTimestamp` in packed ownership. uint256 private constant _BITPOS_START_TIMESTAMP = 160; // The bit mask of the `burned` bit in packed ownership. uint256 private constant _BITMASK_BURNED = 1 << 224; // The bit position of the `nextInitialized` bit in packed ownership. uint256 private constant _BITPOS_NEXT_INITIALIZED = 225; // The bit mask of the `nextInitialized` bit in packed ownership. uint256 private constant _BITMASK_NEXT_INITIALIZED = 1 << 225; // The bit position of `extraData` in packed ownership. uint256 private constant _BITPOS_EXTRA_DATA = 232; // Mask of all 256 bits in a packed ownership except the 24 bits for `extraData`. uint256 private constant _BITMASK_EXTRA_DATA_COMPLEMENT = (1 << 232) - 1; // The mask of the lower 160 bits for addresses. uint256 private constant _BITMASK_ADDRESS = (1 << 160) - 1; // The maximum `quantity` that can be minted with {_mintERC2309}. // This limit is to prevent overflows on the address data entries. // For a limit of 5000, a total of 3.689e15 calls to {_mintERC2309} // is required to cause an overflow, which is unrealistic. uint256 private constant _MAX_MINT_ERC2309_QUANTITY_LIMIT = 5000; // The `Transfer` event signature is given by: // `keccak256(bytes("Transfer(address,address,uint256)"))`. bytes32 private constant _TRANSFER_EVENT_SIGNATURE = 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef; // ============================================================= // STORAGE // ============================================================= // The next token ID to be minted. uint256 private _currentIndex; // The number of tokens burned. uint256 private _burnCounter; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to ownership details // An empty struct value does not necessarily mean the token is unowned. // See {_packedOwnershipOf} implementation for details. // // Bits Layout: // - [0..159] `addr` // - [160..223] `startTimestamp` // - [224] `burned` // - [225] `nextInitialized` // - [232..255] `extraData` mapping(uint256 => uint256) private _packedOwnerships; // Mapping owner address to address data. // // Bits Layout: // - [0..63] `balance` // - [64..127] `numberMinted` // - [128..191] `numberBurned` // - [192..255] `aux` mapping(address => uint256) private _packedAddressData; // Mapping from token ID to approved address. mapping(uint256 => TokenApprovalRef) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; // Mapping from token ID to address who staked token. mapping(uint256 => address) public _tokenOwners; // ============================================================= // CONSTRUCTOR // ============================================================= constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; _currentIndex = _startTokenId(); } // ============================================================= // TOKEN COUNTING OPERATIONS // ============================================================= /** * @dev Returns the starting token ID. * To change the starting token ID, please override this function. */ function _startTokenId() internal view virtual returns (uint256) { return 0; } /** * @dev Returns the next token ID to be minted. */ function _nextTokenId() internal view virtual returns (uint256) { return _currentIndex; } /** * @dev Returns the total number of tokens in existence. * Burned tokens will reduce the count. * To get the total number of tokens minted, please see {_totalMinted}. */ function totalSupply() public view virtual override returns (uint256) { // Counter underflow is impossible as _burnCounter cannot be incremented // more than `_currentIndex - _startTokenId()` times. unchecked { return _currentIndex - _burnCounter - _startTokenId(); } } /** * @dev Returns the total amount of tokens minted in the contract. */ function _totalMinted() internal view virtual returns (uint256) { // Counter underflow is impossible as `_currentIndex` does not decrement, // and it is initialized to `_startTokenId()`. unchecked { return _currentIndex - _startTokenId(); } } /** * @dev Returns the total number of tokens burned. */ function _totalBurned() internal view virtual returns (uint256) { return _burnCounter; } // ============================================================= // ADDRESS DATA OPERATIONS // ============================================================= /** * @dev Returns the number of tokens in `owner`'s account. */ function balanceOf(address owner) public view virtual override returns (uint256) { if (owner == address(0)) revert BalanceQueryForZeroAddress(); return _packedAddressData[owner] & _BITMASK_ADDRESS_DATA_ENTRY; } /** * Returns the number of tokens minted by `owner`. */ function _numberMinted(address owner) internal view returns (uint256) { return (_packedAddressData[owner] >> _BITPOS_NUMBER_MINTED) & _BITMASK_ADDRESS_DATA_ENTRY; } /** * Returns the number of tokens burned by or on behalf of `owner`. */ function _numberBurned(address owner) internal view returns (uint256) { return (_packedAddressData[owner] >> _BITPOS_NUMBER_BURNED) & _BITMASK_ADDRESS_DATA_ENTRY; } /** * Returns the auxiliary data for `owner`. (e.g. number of whitelist mint slots used). */ function _getAux(address owner) internal view returns (uint64) { return uint64(_packedAddressData[owner] >> _BITPOS_AUX); } /** * Sets the auxiliary data for `owner`. (e.g. number of whitelist mint slots used). * If there are multiple variables, please pack them into a uint64. */ function _setAux(address owner, uint64 aux) internal virtual { uint256 packed = _packedAddressData[owner]; uint256 auxCasted; // Cast `aux` with assembly to avoid redundant masking. assembly { auxCasted := aux } packed = (packed & _BITMASK_AUX_COMPLEMENT) | (auxCasted << _BITPOS_AUX); _packedAddressData[owner] = packed; } // ============================================================= // IERC165 // ============================================================= /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * [EIP section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified) * to learn more about how these ids are created. * * This function call must use less than 30000 gas. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { // The interface IDs are constants representing the first 4 bytes // of the XOR of all function selectors in the interface. // See: [ERC165](https://eips.ethereum.org/EIPS/eip-165) // (e.g. `bytes4(i.functionA.selector ^ i.functionB.selector ^ ...)`) return interfaceId == 0x01ffc9a7 || // ERC165 interface ID for ERC165. interfaceId == 0x80ac58cd || // ERC165 interface ID for ERC721. interfaceId == 0x5b5e139f; // ERC165 interface ID for ERC721Metadata. } // ============================================================= // IERC721Metadata // ============================================================= /** * @dev Returns the token collection name. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the token collection symbol. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { if (!_exists(tokenId)) revert URIQueryForNonexistentToken(); string memory baseURI = _baseURI(); return bytes(baseURI).length != 0 ? string(abi.encodePacked(baseURI, _toString(tokenId))) : ''; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, it can be overridden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ''; } // ============================================================= // OWNERSHIPS OPERATIONS // ============================================================= /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { return address(uint160(_packedOwnershipOf(tokenId))); } /** * @dev Gas spent here starts off proportional to the maximum mint batch size. * It gradually moves to O(1) as tokens get transferred around over time. */ function _ownershipOf(uint256 tokenId) internal view virtual returns (TokenOwnership memory) { return _unpackedOwnership(_packedOwnershipOf(tokenId)); } /** * @dev Returns the unpacked `TokenOwnership` struct at `index`. */ function _ownershipAt(uint256 index) internal view virtual returns (TokenOwnership memory) { return _unpackedOwnership(_packedOwnerships[index]); } /** * @dev Initializes the ownership slot minted at `index` for efficiency purposes. */ function _initializeOwnershipAt(uint256 index) internal virtual { if (_packedOwnerships[index] == 0) { _packedOwnerships[index] = _packedOwnershipOf(index); } } /** * Returns the packed ownership data of `tokenId`. */ function _packedOwnershipOf(uint256 tokenId) private view returns (uint256) { uint256 curr = tokenId; unchecked { if (_startTokenId() <= curr) if (curr < _currentIndex) { uint256 packed = _packedOwnerships[curr]; // If not burned. if (packed & _BITMASK_BURNED == 0) { // Invariant: // There will always be an initialized ownership slot // (i.e. `ownership.addr != address(0) && ownership.burned == false`) // before an unintialized ownership slot // (i.e. `ownership.addr == address(0) && ownership.burned == false`) // Hence, `curr` will not underflow. // // We can directly compare the packed value. // If the address is zero, packed will be zero. while (packed == 0) { packed = _packedOwnerships[--curr]; } return packed; } } } revert OwnerQueryForNonexistentToken(); } /** * @dev Returns the unpacked `TokenOwnership` struct from `packed`. */ function _unpackedOwnership(uint256 packed) private pure returns (TokenOwnership memory ownership) { ownership.addr = address(uint160(packed)); ownership.startTimestamp = uint64(packed >> _BITPOS_START_TIMESTAMP); ownership.burned = packed & _BITMASK_BURNED != 0; ownership.extraData = uint24(packed >> _BITPOS_EXTRA_DATA); } /** * @dev Packs ownership data into a single uint256. */ function _packOwnershipData(address owner, uint256 flags) private view returns (uint256 result) { assembly { // Mask `owner` to the lower 160 bits, in case the upper bits somehow aren't clean. owner := and(owner, _BITMASK_ADDRESS) // `owner | (block.timestamp << _BITPOS_START_TIMESTAMP) | flags`. result := or(owner, or(shl(_BITPOS_START_TIMESTAMP, timestamp()), flags)) } } /** * @dev Returns the `nextInitialized` flag set if `quantity` equals 1. */ function _nextInitializedFlag(uint256 quantity) private pure returns (uint256 result) { // For branchless setting of the `nextInitialized` flag. assembly { // `(quantity == 1) << _BITPOS_NEXT_INITIALIZED`. result := shl(_BITPOS_NEXT_INITIALIZED, eq(quantity, 1)) } } // ============================================================= // APPROVAL OPERATIONS // ============================================================= /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the * zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ownerOf(tokenId); if (_msgSenderERC721A() != owner) if (!isApprovedForAll(owner, _msgSenderERC721A())) { revert ApprovalCallerNotOwnerNorApproved(); } _tokenApprovals[tokenId].value = to; emit Approval(owner, to, tokenId); } /** * @dev Approves user to transfer token from contract for unstaking. */ function _approveUnstake(uint256 tokenId) internal { address user = _msgSenderERC721A(); address currentOwner = ownerOf(tokenId); require(currentOwner == address(this), "NOT_STAKED"); require(user == _tokenOwners[tokenId], "NOT_AUTHORISED"); _tokenApprovals[tokenId].value = user; emit Approval(currentOwner, user, tokenId); } /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { if (!_exists(tokenId)) revert ApprovalQueryForNonexistentToken(); return _tokenApprovals[tokenId].value; } /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} * for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool approved) public virtual override { if (operator == _msgSenderERC721A()) revert ApproveToCaller(); _operatorApprovals[_msgSenderERC721A()][operator] = approved; emit ApprovalForAll(_msgSenderERC721A(), operator, approved); } /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted. See {_mint}. */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _startTokenId() <= tokenId && tokenId < _currentIndex && // If within bounds, _packedOwnerships[tokenId] & _BITMASK_BURNED == 0; // and not burned. } /** * @dev Returns whether `msgSender` is equal to `approvedAddress` or `owner`. */ function _isSenderApprovedOrOwner( address approvedAddress, address owner, address msgSender ) private pure returns (bool result) { assembly { // Mask `owner` to the lower 160 bits, in case the upper bits somehow aren't clean. owner := and(owner, _BITMASK_ADDRESS) // Mask `msgSender` to the lower 160 bits, in case the upper bits somehow aren't clean. msgSender := and(msgSender, _BITMASK_ADDRESS) // `msgSender == owner || msgSender == approvedAddress`. result := or(eq(msgSender, owner), eq(msgSender, approvedAddress)) } } /** * @dev Returns the storage slot and value for the approved address of `tokenId`. */ function _getApprovedSlotAndAddress(uint256 tokenId) private view returns (uint256 approvedAddressSlot, address approvedAddress) { TokenApprovalRef storage tokenApproval = _tokenApprovals[tokenId]; // The following is equivalent to `approvedAddress = _tokenApprovals[tokenId]`. assembly { approvedAddressSlot := tokenApproval.slot approvedAddress := sload(approvedAddressSlot) } } // ============================================================= // TRANSFER OPERATIONS // ============================================================= /** * @dev Transfers `tokenId` from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token * by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { uint256 prevOwnershipPacked = _packedOwnershipOf(tokenId); if (address(uint160(prevOwnershipPacked)) != from) revert TransferFromIncorrectOwner(); (uint256 approvedAddressSlot, address approvedAddress) = _getApprovedSlotAndAddress(tokenId); // The nested ifs save around 20+ gas over a compound boolean condition. if (!_isSenderApprovedOrOwner(approvedAddress, from, _msgSenderERC721A())) if (!isApprovedForAll(from, _msgSenderERC721A())) revert TransferCallerNotOwnerNorApproved(); if (to == address(0)) revert TransferToZeroAddress(); _beforeTokenTransfers(from, to, tokenId, 1); // Clear approvals from the previous owner. assembly { if approvedAddress { // This is equivalent to `delete _tokenApprovals[tokenId]`. sstore(approvedAddressSlot, 0) } } // Underflow of the sender's balance is impossible because we check for // ownership above and the recipient's balance can't realistically overflow. // Counter overflow is incredibly unrealistic as `tokenId` would have to be 2**256. unchecked { // We can directly increment and decrement the balances. --_packedAddressData[from]; // Updates: `balance -= 1`. ++_packedAddressData[to]; // Updates: `balance += 1`. // Updates: // - `address` to the next owner. // - `startTimestamp` to the timestamp of transfering. // - `burned` to `false`. // - `nextInitialized` to `true`. _packedOwnerships[tokenId] = _packOwnershipData( to, _BITMASK_NEXT_INITIALIZED | _nextExtraData(from, to, prevOwnershipPacked) ); // If the next slot may not have been initialized (i.e. `nextInitialized == false`) . if (prevOwnershipPacked & _BITMASK_NEXT_INITIALIZED == 0) { uint256 nextTokenId = tokenId + 1; // If the next slot's address is zero and not burned (i.e. packed value is zero). if (_packedOwnerships[nextTokenId] == 0) { // If the next slot is within bounds. if (nextTokenId != _currentIndex) { // Initialize the next slot to maintain correctness for `ownerOf(tokenId + 1)`. _packedOwnerships[nextTokenId] = prevOwnershipPacked; } } } } emit Transfer(from, to, tokenId); _afterTokenTransfers(from, to, tokenId, 1); } /** * @dev Equivalent to `safeTransferFrom(from, to, tokenId, '')`. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ''); } /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token * by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement * {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public virtual override { transferFrom(from, to, tokenId); if (to.code.length != 0) if (!_checkContractOnERC721Received(from, to, tokenId, _data)) { revert TransferToNonERC721ReceiverImplementer(); } } /** * @dev Hook that is called before a set of serially-ordered token IDs * are about to be transferred. This includes minting. * And also called before burning one token. * * `startTokenId` - the first token ID to be transferred. * `quantity` - the amount to be transferred. * * Calling conditions: * * - When `from` and `to` are both non-zero, `from`'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, `tokenId` will be burned by `from`. * - `from` and `to` are never both zero. */ function _beforeTokenTransfers( address from, address to, uint256 startTokenId, uint256 quantity ) internal virtual {} /** * @dev Hook that is called after a set of serially-ordered token IDs * have been transferred. This includes minting. * And also called after one token has been burned. * * `startTokenId` - the first token ID to be transferred. * `quantity` - the amount to be transferred. * * Calling conditions: * * - When `from` and `to` are both non-zero, `from`'s `tokenId` has been * transferred to `to`. * - When `from` is zero, `tokenId` has been minted for `to`. * - When `to` is zero, `tokenId` has been burned by `from`. * - `from` and `to` are never both zero. */ function _afterTokenTransfers( address from, address to, uint256 startTokenId, uint256 quantity ) internal virtual {} /** * @dev Private function to invoke {IERC721Receiver-onERC721Received} on a target contract. * * `from` - Previous owner of the given token ID. * `to` - Target address that will receive the token. * `tokenId` - Token ID to be transferred. * `_data` - Optional data to send along with the call. * * Returns whether the call correctly returned the expected magic value. */ function _checkContractOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { try ERC721A__IERC721Receiver(to).onERC721Received(_msgSenderERC721A(), from, tokenId, _data) returns ( bytes4 retval ) { return retval == ERC721A__IERC721Receiver(to).onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert TransferToNonERC721ReceiverImplementer(); } else { assembly { revert(add(32, reason), mload(reason)) } } } } // ============================================================= // MINT OPERATIONS // ============================================================= /** * @dev Mints `quantity` tokens and transfers them to `to`. * * Requirements: * * - `to` cannot be the zero address. * - `quantity` must be greater than 0. * * Emits a {Transfer} event for each mint. */ function _mint(address to, uint256 quantity) internal virtual { uint256 startTokenId = _currentIndex; if (quantity == 0) revert MintZeroQuantity(); _beforeTokenTransfers(address(0), to, startTokenId, quantity); // Overflows are incredibly unrealistic. // `balance` and `numberMinted` have a maximum limit of 2**64. // `tokenId` has a maximum limit of 2**256. unchecked { // Updates: // - `balance += quantity`. // - `numberMinted += quantity`. // // We can directly add to the `balance` and `numberMinted`. _packedAddressData[to] += quantity * ((1 << _BITPOS_NUMBER_MINTED) | 1); // Updates: // - `address` to the owner. // - `startTimestamp` to the timestamp of minting. // - `burned` to `false`. // - `nextInitialized` to `quantity == 1`. _packedOwnerships[startTokenId] = _packOwnershipData( to, _nextInitializedFlag(quantity) | _nextExtraData(address(0), to, 0) ); uint256 toMasked; uint256 end = startTokenId + quantity; // Use assembly to loop and emit the `Transfer` event for gas savings. assembly { // Mask `to` to the lower 160 bits, in case the upper bits somehow aren't clean. toMasked := and(to, _BITMASK_ADDRESS) // Emit the `Transfer` event. log4( 0, // Start of data (0, since no data). 0, // End of data (0, since no data). _TRANSFER_EVENT_SIGNATURE, // Signature. 0, // `address(0)`. toMasked, // `to`. startTokenId // `tokenId`. ) for { let tokenId := add(startTokenId, 1) } iszero(eq(tokenId, end)) { tokenId := add(tokenId, 1) } { // Emit the `Transfer` event. Similar to above. log4(0, 0, _TRANSFER_EVENT_SIGNATURE, 0, toMasked, tokenId) } } if (toMasked == 0) revert MintToZeroAddress(); _currentIndex = end; } _afterTokenTransfers(address(0), to, startTokenId, quantity); } /** * @dev Mints `quantity` tokens and transfers them to `to`. * * This function is intended for efficient minting only during contract creation. * * It emits only one {ConsecutiveTransfer} as defined in * [ERC2309](https://eips.ethereum.org/EIPS/eip-2309), * instead of a sequence of {Transfer} event(s). * * Calling this function outside of contract creation WILL make your contract * non-compliant with the ERC721 standard. * For full ERC721 compliance, substituting ERC721 {Transfer} event(s) with the ERC2309 * {ConsecutiveTransfer} event is only permissible during contract creation. * * Requirements: * * - `to` cannot be the zero address. * - `quantity` must be greater than 0. * * Emits a {ConsecutiveTransfer} event. */ function _mintERC2309(address to, uint256 quantity) internal virtual { uint256 startTokenId = _currentIndex; if (to == address(0)) revert MintToZeroAddress(); if (quantity == 0) revert MintZeroQuantity(); if (quantity > _MAX_MINT_ERC2309_QUANTITY_LIMIT) revert MintERC2309QuantityExceedsLimit(); _beforeTokenTransfers(address(0), to, startTokenId, quantity); // Overflows are unrealistic due to the above check for `quantity` to be below the limit. unchecked { // Updates: // - `balance += quantity`. // - `numberMinted += quantity`. // // We can directly add to the `balance` and `numberMinted`. _packedAddressData[to] += quantity * ((1 << _BITPOS_NUMBER_MINTED) | 1); // Updates: // - `address` to the owner. // - `startTimestamp` to the timestamp of minting. // - `burned` to `false`. // - `nextInitialized` to `quantity == 1`. _packedOwnerships[startTokenId] = _packOwnershipData( to, _nextInitializedFlag(quantity) | _nextExtraData(address(0), to, 0) ); emit ConsecutiveTransfer(startTokenId, startTokenId + quantity - 1, address(0), to); _currentIndex = startTokenId + quantity; } _afterTokenTransfers(address(0), to, startTokenId, quantity); } /** * @dev Safely mints `quantity` tokens and transfers them to `to`. * * Requirements: * * - If `to` refers to a smart contract, it must implement * {IERC721Receiver-onERC721Received}, which is called for each safe transfer. * - `quantity` must be greater than 0. * * See {_mint}. * * Emits a {Transfer} event for each mint. */ function _safeMint( address to, uint256 quantity, bytes memory _data ) internal virtual { _mint(to, quantity); unchecked { if (to.code.length != 0) { uint256 end = _currentIndex; uint256 index = end - quantity; do { if (!_checkContractOnERC721Received(address(0), to, index++, _data)) { revert TransferToNonERC721ReceiverImplementer(); } } while (index < end); // Reentrancy protection. if (_currentIndex != end) revert(); } } } /** * @dev Equivalent to `_safeMint(to, quantity, '')`. */ function _safeMint(address to, uint256 quantity) internal virtual { _safeMint(to, quantity, ''); } // ============================================================= // BURN OPERATIONS // ============================================================= /** * @dev Equivalent to `_burn(tokenId, false)`. */ function _burn(uint256 tokenId) internal virtual { _burn(tokenId, false); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId, bool approvalCheck) internal virtual { uint256 prevOwnershipPacked = _packedOwnershipOf(tokenId); address from = address(uint160(prevOwnershipPacked)); (uint256 approvedAddressSlot, address approvedAddress) = _getApprovedSlotAndAddress(tokenId); if (approvalCheck) { // The nested ifs save around 20+ gas over a compound boolean condition. if (!_isSenderApprovedOrOwner(approvedAddress, from, _msgSenderERC721A())) if (!isApprovedForAll(from, _msgSenderERC721A())) revert TransferCallerNotOwnerNorApproved(); } _beforeTokenTransfers(from, address(0), tokenId, 1); // Clear approvals from the previous owner. assembly { if approvedAddress { // This is equivalent to `delete _tokenApprovals[tokenId]`. sstore(approvedAddressSlot, 0) } } // Underflow of the sender's balance is impossible because we check for // ownership above and the recipient's balance can't realistically overflow. // Counter overflow is incredibly unrealistic as `tokenId` would have to be 2**256. unchecked { // Updates: // - `balance -= 1`. // - `numberBurned += 1`. // // We can directly decrement the balance, and increment the number burned. // This is equivalent to `packed -= 1; packed += 1 << _BITPOS_NUMBER_BURNED;`. _packedAddressData[from] += (1 << _BITPOS_NUMBER_BURNED) - 1; // Updates: // - `address` to the last owner. // - `startTimestamp` to the timestamp of burning. // - `burned` to `true`. // - `nextInitialized` to `true`. _packedOwnerships[tokenId] = _packOwnershipData( from, (_BITMASK_BURNED | _BITMASK_NEXT_INITIALIZED) | _nextExtraData(from, address(0), prevOwnershipPacked) ); // If the next slot may not have been initialized (i.e. `nextInitialized == false`) . if (prevOwnershipPacked & _BITMASK_NEXT_INITIALIZED == 0) { uint256 nextTokenId = tokenId + 1; // If the next slot's address is zero and not burned (i.e. packed value is zero). if (_packedOwnerships[nextTokenId] == 0) { // If the next slot is within bounds. if (nextTokenId != _currentIndex) { // Initialize the next slot to maintain correctness for `ownerOf(tokenId + 1)`. _packedOwnerships[nextTokenId] = prevOwnershipPacked; } } } } emit Transfer(from, address(0), tokenId); _afterTokenTransfers(from, address(0), tokenId, 1); // Overflow not possible, as _burnCounter cannot be exceed _currentIndex times. unchecked { _burnCounter++; } } // ============================================================= // EXTRA DATA OPERATIONS // ============================================================= /** * @dev Directly sets the extra data for the ownership data `index`. */ function _setExtraDataAt(uint256 index, uint24 extraData) internal virtual { uint256 packed = _packedOwnerships[index]; if (packed == 0) revert OwnershipNotInitializedForExtraData(); uint256 extraDataCasted; // Cast `extraData` with assembly to avoid redundant masking. assembly { extraDataCasted := extraData } packed = (packed & _BITMASK_EXTRA_DATA_COMPLEMENT) | (extraDataCasted << _BITPOS_EXTRA_DATA); _packedOwnerships[index] = packed; } /** * @dev Called during each token transfer to set the 24bit `extraData` field. * Intended to be overridden by the cosumer contract. * * `previousExtraData` - the value of `extraData` before transfer. * * Calling conditions: * * - When `from` and `to` are both non-zero, `from`'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, `tokenId` will be burned by `from`. * - `from` and `to` are never both zero. */ function _extraData( address from, address to, uint24 previousExtraData ) internal view virtual returns (uint24) {} /** * @dev Returns the next extra data for the packed ownership data. * The returned result is shifted into position. */ function _nextExtraData( address from, address to, uint256 prevOwnershipPacked ) private view returns (uint256) { uint24 extraData = uint24(prevOwnershipPacked >> _BITPOS_EXTRA_DATA); return uint256(_extraData(from, to, extraData)) << _BITPOS_EXTRA_DATA; } // ============================================================= // OTHER OPERATIONS // ============================================================= /** * @dev Returns the message sender (defaults to `msg.sender`). * * If you are writing GSN compatible contracts, you need to override this function. */ function _msgSenderERC721A() internal view virtual returns (address) { return msg.sender; } /** * @dev Converts a uint256 to its ASCII string decimal representation. */ function _toString(uint256 value) internal pure virtual returns (string memory ptr) { assembly { // The maximum value of a uint256 contains 78 digits (1 byte per digit), // but we allocate 128 bytes to keep the free memory pointer 32-byte word aliged. // We will need 1 32-byte word to store the length, // and 3 32-byte words to store a maximum of 78 digits. Total: 32 + 3 * 32 = 128. ptr := add(mload(0x40), 128) // Update the free memory pointer to allocate. mstore(0x40, ptr) // Cache the end of the memory to calculate the length later. let end := ptr // We write the string from the rightmost digit to the leftmost digit. // The following is essentially a do-while loop that also handles the zero case. // Costs a bit more than early returning for the zero case, // but cheaper in terms of deployment and overall runtime costs. for { // Initialize and perform the first pass without check. let temp := value // Move the pointer 1 byte leftwards to point to an empty character slot. ptr := sub(ptr, 1) // Write the character to the pointer. // The ASCII index of the '0' character is 48. mstore8(ptr, add(48, mod(temp, 10))) temp := div(temp, 10) } temp { // Keep dividing `temp` until zero. temp := div(temp, 10) } { // Body of the for loop. ptr := sub(ptr, 1) mstore8(ptr, add(48, mod(temp, 10))) } let length := sub(end, ptr) // Move the pointer 32 bytes leftwards to make room for the length. ptr := sub(ptr, 32) // Store the length. mstore(ptr, length) } } }
// SPDX-License-Identifier: MIT // ERC721A Contracts v4.2.0 // Creator: Chiru Labs pragma solidity ^0.8.4; /** * @dev Interface of ERC721A. */ interface IERC721A { /** * The caller must own the token or be an approved operator. */ error ApprovalCallerNotOwnerNorApproved(); /** * The token does not exist. */ error ApprovalQueryForNonexistentToken(); /** * The caller cannot approve to their own address. */ error ApproveToCaller(); /** * Cannot query the balance for the zero address. */ error BalanceQueryForZeroAddress(); /** * Cannot mint to the zero address. */ error MintToZeroAddress(); /** * The quantity of tokens minted must be more than zero. */ error MintZeroQuantity(); /** * The token does not exist. */ error OwnerQueryForNonexistentToken(); /** * The caller must own the token or be an approved operator. */ error TransferCallerNotOwnerNorApproved(); /** * The token must be owned by `from`. */ error TransferFromIncorrectOwner(); /** * Cannot safely transfer to a contract that does not implement the * ERC721Receiver interface. */ error TransferToNonERC721ReceiverImplementer(); /** * Cannot transfer to the zero address. */ error TransferToZeroAddress(); /** * The token does not exist. */ error URIQueryForNonexistentToken(); /** * The `quantity` minted with ERC2309 exceeds the safety limit. */ error MintERC2309QuantityExceedsLimit(); /** * The `extraData` cannot be set on an unintialized ownership slot. */ error OwnershipNotInitializedForExtraData(); // ============================================================= // STRUCTS // ============================================================= struct TokenOwnership { // The address of the owner. address addr; // Stores the start time of ownership with minimal overhead for tokenomics. uint64 startTimestamp; // Whether the token has been burned. bool burned; // Arbitrary data similar to `startTimestamp` that can be set via {_extraData}. uint24 extraData; } // ============================================================= // TOKEN COUNTERS // ============================================================= /** * @dev Returns the total number of tokens in existence. * Burned tokens will reduce the count. * To get the total number of tokens minted, please see {_totalMinted}. */ function totalSupply() external view returns (uint256); // ============================================================= // IERC165 // ============================================================= /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * [EIP section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified) * to learn more about how these ids are created. * * This function call must use less than 30000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); // ============================================================= // IERC721 // ============================================================= /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables * (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in `owner`'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, * checking first that contract recipients are aware of the ERC721 protocol * to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move * this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement * {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; /** * @dev Equivalent to `safeTransferFrom(from, to, tokenId, '')`. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} * whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token * by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the * zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} * for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll}. */ function isApprovedForAll(address owner, address operator) external view returns (bool); // ============================================================= // IERC721Metadata // ============================================================= /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); // ============================================================= // IERC2309 // ============================================================= /** * @dev Emitted when tokens in `fromTokenId` to `toTokenId` * (inclusive) is transferred from `from` to `to`, as defined in the * [ERC2309](https://eips.ethereum.org/EIPS/eip-2309) standard. * * See {_mintERC2309} for more details. */ event ConsecutiveTransfer(uint256 indexed fromTokenId, uint256 toTokenId, address indexed from, address indexed to); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/ERC721.sol) pragma solidity ^0.8.0; import "./IERC721.sol"; import "./IERC721Receiver.sol"; import "./extensions/IERC721Metadata.sol"; import "../../utils/Address.sol"; import "../../utils/Context.sol"; import "../../utils/Strings.sol"; import "../../utils/introspection/ERC165.sol"; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: address zero is not a valid owner"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: invalid token ID"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { _requireMinted(tokenId); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overridden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not token owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { _requireMinted(tokenId); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner nor approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory data ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner nor approved"); _safeTransfer(from, to, tokenId, data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { address owner = ERC721.ownerOf(tokenId); return (spender == owner || isApprovedForAll(owner, spender) || getApproved(tokenId) == spender); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint( address to, uint256 tokenId, bytes memory data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); _afterTokenTransfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); _afterTokenTransfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId); _afterTokenTransfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits an {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits an {ApprovalForAll} event. */ function _setApprovalForAll( address owner, address operator, bool approved ) internal virtual { require(owner != operator, "ERC721: approve to caller"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Reverts if the `tokenId` has not been minted yet. */ function _requireMinted(uint256 tokenId) internal view virtual { require(_exists(tokenId), "ERC721: invalid token ID"); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { /// @solidity memory-safe-assembly assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/extensions/IERC721Enumerable.sol) pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); }
{ "optimizer": { "enabled": true, "runs": 200 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"address","name":"signer","type":"address"},{"internalType":"address","name":"magicFolkMainhand","type":"address"},{"internalType":"address","name":"magicFolkOffhand","type":"address"},{"internalType":"address","name":"magicFolkPet","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"ApprovalCallerNotOwnerNorApproved","type":"error"},{"inputs":[],"name":"ApprovalQueryForNonexistentToken","type":"error"},{"inputs":[],"name":"ApproveToCaller","type":"error"},{"inputs":[],"name":"BalanceQueryForZeroAddress","type":"error"},{"inputs":[],"name":"InvalidQueryRange","type":"error"},{"inputs":[],"name":"MintERC2309QuantityExceedsLimit","type":"error"},{"inputs":[],"name":"MintToZeroAddress","type":"error"},{"inputs":[],"name":"MintZeroQuantity","type":"error"},{"inputs":[],"name":"OwnerQueryForNonexistentToken","type":"error"},{"inputs":[],"name":"OwnershipNotInitializedForExtraData","type":"error"},{"inputs":[],"name":"TransferCallerNotOwnerNorApproved","type":"error"},{"inputs":[],"name":"TransferFromIncorrectOwner","type":"error"},{"inputs":[],"name":"TransferToNonERC721ReceiverImplementer","type":"error"},{"inputs":[],"name":"TransferToZeroAddress","type":"error"},{"inputs":[],"name":"URIQueryForNonexistentToken","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"fromTokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"toTokenId","type":"uint256"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"}],"name":"ConsecutiveTransfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"_tokenId","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"_itemId","type":"uint256"},{"indexed":false,"internalType":"enum ItemType","name":"_itemType","type":"uint8"}],"name":"Equipped","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"_tokenId","type":"uint256"},{"indexed":false,"internalType":"address","name":"owner","type":"address"}],"name":"Staked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"_tokenId","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"_itemId","type":"uint256"},{"indexed":false,"internalType":"enum ItemType","name":"_itemType","type":"uint8"}],"name":"Unequipped","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"_tokenId","type":"uint256"},{"indexed":false,"internalType":"address","name":"owner","type":"address"}],"name":"Unstaked","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"state","type":"bool"}],"name":"privateSaleToggled","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"state","type":"bool"}],"name":"publicSaleToggled","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"state","type":"bool"}],"name":"stakingToggled","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"FEE_ADDRESS","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_MINT","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MIGRATION_MINTS","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MINTER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MINTS_PER_MIGRATION","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PRIVATE_PRICE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PUBLIC_ALLOWANCE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PUBLIC_PRICE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"TEAM_MINT","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_URI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_fees","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_initialFeesWithdrawn","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_listable","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_migrationMints","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"_mintNonce","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"_payees","outputs":[{"internalType":"address","name":"wallet","type":"address"},{"internalType":"uint16","name":"percentagePoints","type":"uint16"},{"internalType":"bytes24","name":"payeeId","type":"bytes24"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_publicSaleSignatureRequired","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_signer","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"_stakedTokens","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_stakingEnabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_teamMinted","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"_tokenOwners","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"claimAllGems","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"claimGems","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"explicitOwnershipOf","outputs":[{"components":[{"internalType":"address","name":"addr","type":"address"},{"internalType":"uint64","name":"startTimestamp","type":"uint64"},{"internalType":"bool","name":"burned","type":"bool"},{"internalType":"uint24","name":"extraData","type":"uint24"}],"internalType":"struct IERC721A.TokenOwnership","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"}],"name":"explicitOwnershipsOf","outputs":[{"components":[{"internalType":"address","name":"addr","type":"address"},{"internalType":"uint64","name":"startTimestamp","type":"uint64"},{"internalType":"bool","name":"burned","type":"bool"},{"internalType":"uint24","name":"extraData","type":"uint24"}],"internalType":"struct IERC721A.TokenOwnership[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getAllocation","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getBasePowerLevel","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getGemRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"getQuantityStaked","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"getStakedTokens","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getStats","outputs":[{"components":[{"internalType":"uint8","name":"powerLevel","type":"uint8"},{"components":[{"internalType":"uint256","name":"itemId","type":"uint256"},{"internalType":"uint8","name":"powerLevel","type":"uint8"},{"internalType":"enum ItemType","name":"itemType","type":"uint8"}],"internalType":"struct Item","name":"mainHand","type":"tuple"},{"components":[{"internalType":"uint256","name":"itemId","type":"uint256"},{"internalType":"uint8","name":"powerLevel","type":"uint8"},{"internalType":"enum ItemType","name":"itemType","type":"uint8"}],"internalType":"struct Item","name":"offHand","type":"tuple"},{"components":[{"internalType":"uint256","name":"itemId","type":"uint256"},{"internalType":"uint8","name":"powerLevel","type":"uint8"},{"internalType":"enum ItemType","name":"itemType","type":"uint8"}],"internalType":"struct Item","name":"pet","type":"tuple"}],"internalType":"struct MagicFolk.Stats","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"getTotalUnclaimed","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"hashMsg","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"isTokenStaked","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lockPowerLevels","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"qty","type":"uint256"}],"name":"migrationMint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC1155BatchReceived","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"_operator","type":"address"},{"internalType":"address","name":"_from","type":"address"},{"internalType":"uint256","name":"_id","type":"uint256"},{"internalType":"uint256","name":"_value","type":"uint256"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"onERC1155Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC721Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"privateSaleActive","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"publicSaleActive","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"qty","type":"uint256"},{"internalType":"uint256","name":"privateSaleAllowance","type":"uint256"},{"internalType":"bytes32","name":"msgHash","type":"bytes32"},{"internalType":"bytes","name":"signature","type":"bytes"}],"name":"safeMintPrivate","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"qty","type":"uint256"},{"internalType":"uint256","name":"mintNonce","type":"uint256"},{"internalType":"bytes32","name":"msgHash","type":"bytes32"},{"internalType":"bytes","name":"signature","type":"bytes"}],"name":"safeMintPublic","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"URI","type":"string"}],"name":"setBaseURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newFees","type":"uint256"}],"name":"setFees","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newGemRate","type":"uint256"}],"name":"setGemRate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"magicFolkGems","type":"address"}],"name":"setMagicFolkGemsContract","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"magicFolkItems","type":"address"},{"internalType":"enum ItemType","name":"itemType","type":"uint8"}],"name":"setMagicFolkItemsContract","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"migrationProxy","type":"address"}],"name":"setMigrationProxy","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint8[]","name":"powerLevels","type":"uint8[]"},{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"}],"name":"setPowerLevels","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newPrice","type":"uint256"}],"name":"setPrivatePrice","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newPrice","type":"uint256"}],"name":"setPublicPrice","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"signer","type":"address"}],"name":"setSignerAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"stakeToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"}],"name":"stakeTokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceID","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"qty","type":"uint256"}],"name":"teamMint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"togglePrivateSale","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"togglePublicSale","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"togglePublicSaleSigRequired","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"toggleStaking","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"tokensOfOwner","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"start","type":"uint256"},{"internalType":"uint256","name":"stop","type":"uint256"}],"name":"tokensOfOwnerIn","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"unequip","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"unstakeToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"}],"name":"unstakeTokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"bytes32","name":"msgHash","type":"bytes32"},{"internalType":"bytes","name":"signature","type":"bytes"},{"internalType":"address","name":"_signer","type":"address"}],"name":"verifyMsg","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bytes32","name":"msgHash","type":"bytes32"},{"internalType":"bytes","name":"signature","type":"bytes"},{"internalType":"address","name":"_signer","type":"address"}],"name":"verifySigner","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
66b1a2bc2ec50000602c819055602d556801a055690d9db80000602e556000602f819055603055600a60325560e060405260296080818152906200671760a0398051620000559160339160209091019062000857565b5060e2805466ffffffffffffff191663010000001790553480156200007957600080fd5b5060405162006740380380620067408339810160408190526200009c916200091a565b6040518060400160405280600a8152602001694d6167696320466f6c6b60b01b8152506040518060400160405280600281526020016126a360f11b8152508160029080519060200190620000f292919062000857565b5080516200010890600390602084019062000857565b5060008055505060016009556200011f3362000760565b6200012c600033620007b2565b603180546001600160a01b038087166001600160a01b0319928316179092556028805486841690831617905560298054858416908316179055602a80549284169290911691909117905562000183600033620007b2565b604080516060808201835273586a6c03da4959c6341845c210b4cdbec930af37825261010960208084019190915268454c4f4e5f4d55534b60b81b92840192909252600c8054750109586a6c03da4959c6341845c210b4cdbec930af376001600160b01b031991821617909155600d80546001600160c01b031990811668454c4f4e5f4d55534b60781b179091558451808401865273a8fd19cb5f949677504dd90f8b6efe044286e6b281526050818601526b0444f4e414c445f5452554d560a41b90860152600e80547450a8fd19cb5f949677504dd90f8b6efe044286e6b2908416179055600f8054821677444f4e414c445f5452554d500000000000000000000000001790558451808401865273d85aa7341a63b413972c8e8d63ae7a7bc08a5afd815260198186018190526c15d05494915397d09551919155609a1b91870191909152601080547419d85aa7341a63b413972c8e8d63ae7a7bc08a5afd9085161790556011805483167757415252454e5f425546464554000000000000000000000017905585518085018752734fb91f8b17702aff47be977a226dddabf54756618152808601829052694a4546465f42455a4f5360b01b908701526012805474194fb91f8b17702aff47be977a226dddabf5475661908516179055601380548316694a4546465f42455a4f5360701b17905585518085018752737913feda30503465edadc674a66fbdcb581f684081526078818701526942494c4c5f474154455360b01b908701526014805474787913feda30503465edadc674a66fbdcb581f68409085161790556015805483166942494c4c5f474154455360701b17905585518085018752732e8a3f14feda7fa7690260a06a1656bfe20be1ac8152603c818701526b4c4542524f4e5f4a414d455360a01b9087015260168054743c2e8a3f14feda7fa7690260a06a1656bfe20be1ac908516179055601780548316774c4542524f4e5f4a414d4553000000000000000000000000179055855180850187527360d1082d0fdab22990f56a70b68addc049f75ec8815260648187018190526b4e49434f4c41535f4341474560a01b9188019190915260188054746460d1082d0fdab22990f56a70b68addc049f75ec890861617905581548316774e49434f4c41535f43414745000000000000000000000000178255865180860188527371dcb19a6d322c9d826aa6b61442828436aa6fb281526032818801526d25a2a7222924a1a5afa620a6a0a960911b90880152601a8054743271dcb19a6d322c9d826aa6b61442828436aa6fb2908616179055601b80548416774b454e445249434b5f4c414d4152000000000000000000001790558651808601885273996107a817f0fbaf389f1dcc1a48dfb2edb78d3381528087019290925266525f4b454c4c5960c81b91870191909152601c80547419996107a817f0fbaf389f1dcc1a48dfb2edb78d33908516179055601d8054831666525f4b454c4c5960881b1790558551808501875273ab1ca28b50edc107023d81e71640da3ee26f93a08152609681870152684c494c5f4449434b5960b81b90870152601e80547496ab1ca28b50edc107023d81e71640da3ee26f93a0908516179055601f80548316684c494c5f4449434b5960781b17905585519384018652733750737d7fbf284705a329ab674d9309485b5be2845283850152692524a6a6acafa1a0a92960b11b9290940191909152815474643750737d7fbf284705a329ab674d9309485b5be2911617905560218054909116692524a6a6acafa1a0a92960711b1790556000805b600b811015620006fe57600c81600b8110620006cb57634e487b7160e01b600052603260045260246000fd5b6002020154620006e790600160a01b900461ffff168362000976565b915080620006f581620009ce565b9150506200069f565b50806103e814620007555760405162461bcd60e51b815260206004820152601360248201527f494e56414c49445f50455243454e544147455300000000000000000000000000604482015260640160405180910390fd5b505050505062000a02565b600b80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6000828152600a602090815260408083206001600160a01b038516845290915290205460ff1662000853576000828152600a602090815260408083206001600160a01b03851684529091529020805460ff19166001179055620008123390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45b5050565b828054620008659062000991565b90600052602060002090601f016020900481019282620008895760008555620008d4565b82601f10620008a457805160ff1916838001178555620008d4565b82800160010185558215620008d4579182015b82811115620008d4578251825591602001919060010190620008b7565b50620008e2929150620008e6565b5090565b5b80821115620008e25760008155600101620008e7565b80516001600160a01b03811681146200091557600080fd5b919050565b6000806000806080858703121562000930578384fd5b6200093b85620008fd565b93506200094b60208601620008fd565b92506200095b60408601620008fd565b91506200096b60608601620008fd565b905092959194509250565b600082198211156200098c576200098c620009ec565b500190565b600181811c90821680620009a657607f821691505b60208210811415620009c857634e487b7160e01b600052602260045260246000fd5b50919050565b6000600019821415620009e557620009e5620009ec565b5060010190565b634e487b7160e01b600052601160045260246000fd5b615d058062000a126000396000f3fe6080604052600436106104f75760003560e01c8063764f1a591161028c578063c23dc68f1161015a578063dd48f07d116100cc578063f0292a0311610085578063f0292a031461100f578063f0a5242414611024578063f23a6e6114611044578063f2fde38b14611064578063fd09035d14611084578063fdb359b4146110a457600080fd5b8063dd48f07d14610f4b578063dfe5dd6814610f61578063e222c7f914610f76578063e985e9c514610f8b578063eb1edd6114610fd4578063edee469914610ffc57600080fd5b8063cda6b8471161011e578063cda6b84714610e99578063d200bec814610eb9578063d212a69a14610ecc578063d539139314610ee2578063d547741f14610f16578063d8ec6cfa14610f3657600080fd5b8063c23dc68f14610dec578063c627525514610e19578063c782311c14610e39578063c87b56dd14610e59578063ca29e8c814610e7957600080fd5b806395d89b41116101fe578063a22cb465116101b7578063a22cb46514610d3f578063ac4e88af14610d5f578063b4e87e8f14610d82578063b88d4fde14610d97578063bc197c8114610db7578063bc8893b414610dd757600080fd5b806395d89b4114610c9f578063999ec86314610cb457806399a2557a14610cd55780639d24863014610cf5578063a10f151e14610d0a578063a217fddf14610d2a57600080fd5b806386ad5ebc1161025057806386ad5ebc14610bcb5780638c85c3c814610beb5780638da5cb5b14610c0b57806391d1485414610c2957806392673ff514610c4957806392ae9bfd14610c7f57600080fd5b8063764f1a5914610b1757806377f8383014610b495780637b30396514610b5e57806381af84c314610b8b5780638462151c14610bab57600080fd5b8063353b3172116103c95780634e9118171161033b57806363c28db1116102f457806363c28db114610a6b57806364124e1a14610a9857806370a0823114610aad57806370ea028f14610acd578063715018a614610aed5780637290990514610b0257600080fd5b80634e911817146109b357806355f804b3146109c85780635a5804b3146109e85780635bbb217714610a08578063611f3f1014610a355780636352211e14610a4b57600080fd5b80633cd01bb51161038d5780633cd01bb5146108e85780633d18678e1461091e5780633dda86521461093e57806342842e0e14610953578063485dcbc7146109735780634af9a0301461099357600080fd5b8063353b31721461085d57806336568abe1461087d57806338de114e1461089d5780633b8105b3146108be5780633ccfd60b146108d357600080fd5b806318160ddd1161046d578063283248be11610426578063283248be146107775780632a237bb6146107ca5780632cfb6688146107e75780632e2047d4146108075780632f2ff15d1461081d5780632fbba1151461083d57600080fd5b806318160ddd146106b65780631e81e656146106cf5780631f220560146106ef57806323b872dd14610711578063248a9ca31461073157806327d5f20e1461076157600080fd5b8063095ea7b3116104bf578063095ea7b3146105c257806309f0138c146105e25780630b1350a21461061d5780630f1740d11461063d57806312c61be81461065d578063150b7a021461067d57600080fd5b806301ffc9a7146104fc578063046dc16614610531578063057557621461055357806306fdde0314610568578063081812fc1461058a575b600080fd5b34801561050857600080fd5b5061051c610517366004615671565b6110c4565b60405190151581526020015b60405180910390f35b34801561053d57600080fd5b5061055161054c3660046151c3565b611126565b005b34801561055f57600080fd5b50610551611154565b34801561057457600080fd5b5061057d611189565b604051610528919061599f565b34801561059657600080fd5b506105aa6105a53660046155e3565b61121b565b6040516001600160a01b039091168152602001610528565b3480156105ce57600080fd5b506105516105dd366004615472565b61125f565b3480156105ee57600080fd5b5061060f6105fd3660046151c3565b60246020526000908152604090205481565b604051908152602001610528565b34801561062957600080fd5b506105516106383660046155e3565b6112ff565b34801561064957600080fd5b506105516106583660046153f7565b611456565b34801561066957600080fd5b5061051c61067836600461549b565b611628565b34801561068957600080fd5b5061069d6106983660046152f5565b611641565b6040516001600160e01b03199091168152602001610528565b3480156106c257600080fd5b506001546000540361060f565b3480156106db57600080fd5b5061051c6106ea36600461561d565b611652565b3480156106fb57600080fd5b5060e25461051c90640100000000900460ff1681565b34801561071d57600080fd5b5061055161072c3660046152ba565b611669565b34801561073d57600080fd5b5061060f61074c3660046155e3565b6000908152600a602052604090206001015490565b34801561076d57600080fd5b5061060f60305481565b34801561078357600080fd5b506107976107923660046155e3565b6117fb565b604080516001600160a01b03909416845261ffff909216602084015267ffffffffffffffff191690820152606001610528565b3480156107d657600080fd5b5060e254610100900460ff1661051c565b3480156107f357600080fd5b506105516108023660046155e3565b61183b565b34801561081357600080fd5b5061060f602c5481565b34801561082957600080fd5b506105516108383660046155fb565b611875565b34801561084957600080fd5b506105516108583660046155e3565b61189f565b34801561086957600080fd5b5061060f610878366004615472565b611961565b34801561088957600080fd5b506105516108983660046155fb565b611992565b3480156108a957600080fd5b5060e25461051c906301000000900460ff1681565b3480156108ca57600080fd5b50610551611a10565b3480156108df57600080fd5b50610551611a84565b3480156108f457600080fd5b5061060f6109033660046151c3565b6001600160a01b031660009081526026602052604090205490565b34801561092a57600080fd5b506105516109393660046155e3565b611c5c565b34801561094a57600080fd5b50610551611c6d565b34801561095f57600080fd5b5061055161096e3660046152ba565b611c9a565b34801561097f57600080fd5b5061055161098e36600461557b565b611cb5565b34801561099f57600080fd5b506105516109ae3660046151c3565b611d9d565b3480156109bf57600080fd5b5061060f600a81565b3480156109d457600080fd5b506105516109e33660046156e1565b611dd2565b3480156109f457600080fd5b5061060f610a033660046155e3565b611de9565b348015610a1457600080fd5b50610a28610a2336600461553c565b611df4565b6040516105289190615917565b348015610a4157600080fd5b5061060f602d5481565b348015610a5757600080fd5b506105aa610a663660046155e3565b611ee9565b348015610a7757600080fd5b50610a8b610a863660046151c3565b611ef4565b6040516105289190615959565b348015610aa457600080fd5b5061060f611f60565b348015610ab957600080fd5b5061060f610ac83660046151c3565b611f70565b348015610ad957600080fd5b50610551610ae836600461553c565b611fbe565b348015610af957600080fd5b5061055161203d565b348015610b0e57600080fd5b5061060f600281565b348015610b2357600080fd5b50610b37610b323660046155e3565b612051565b60405160ff9091168152602001610528565b348015610b5557600080fd5b5061060f61208b565b348015610b6a57600080fd5b50610b7e610b793660046155e3565b612096565b6040516105289190615a8c565b348015610b9757600080fd5b50610551610ba63660046155e3565b6120cf565b348015610bb757600080fd5b50610a8b610bc63660046151c3565b6120e3565b348015610bd757600080fd5b5061060f610be6366004615472565b61220e565b348015610bf757600080fd5b5061060f610c063660046151c3565b61221a565b348015610c1757600080fd5b50600b546001600160a01b03166105aa565b348015610c3557600080fd5b5061051c610c443660046155fb565b6122e6565b348015610c5557600080fd5b506105aa610c643660046155e3565b6008602052600090815260409020546001600160a01b031681565b348015610c8b57600080fd5b50610551610c9a366004615447565b612311565b348015610cab57600080fd5b5061057d6123fa565b348015610cc057600080fd5b5060e25461051c90600160301b900460ff1681565b348015610ce157600080fd5b50610a8b610cf036600461550a565b612409565b348015610d0157600080fd5b5061060f603181565b348015610d1657600080fd5b50610551610d253660046155e3565b6125a0565b348015610d3657600080fd5b5061060f600081565b348015610d4b57600080fd5b50610551610d5a3660046153bd565b6125b1565b348015610d6b57600080fd5b5060e25461051c9065010000000000900460ff1681565b348015610d8e57600080fd5b5061057d612647565b348015610da357600080fd5b50610551610db23660046152f5565b6126d5565b348015610dc357600080fd5b5061069d610dd236600461520f565b612719565b348015610de357600080fd5b5061051c612720565b348015610df857600080fd5b50610e0c610e073660046155e3565b61272e565b6040516105289190615ad1565b348015610e2557600080fd5b50610551610e343660046155e3565b6127a6565b348015610e4557600080fd5b50610551610e5436600461553c565b6127b7565b348015610e6557600080fd5b5061057d610e743660046155e3565b61282c565b348015610e8557600080fd5b506031546105aa906001600160a01b031681565b348015610ea557600080fd5b50610551610eb43660046155e3565b6128b0565b610551610ec7366004615714565b6128e2565b348015610ed857600080fd5b5061060f602e5481565b348015610eee57600080fd5b5061060f7f9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a681565b348015610f2257600080fd5b50610551610f313660046155fb565b612b45565b348015610f4257600080fd5b50610551612b6a565b348015610f5757600080fd5b5061060f602f5481565b348015610f6d57600080fd5b50610551612c41565b348015610f8257600080fd5b50610551612cb4565b348015610f9757600080fd5b5061051c610fa63660046151dd565b6001600160a01b03918216600090815260076020908152604080832093909416825291909152205460ff1690565b348015610fe057600080fd5b506105aa73670326f4470d4d2f5347377ff187717a81ab131881565b61055161100a366004615714565b612d1c565b34801561101b57600080fd5b5061060f612f47565b34801561103057600080fd5b5061051c61103f3660046155e3565b612f6b565b34801561105057600080fd5b5061069d61105f36600461535a565b612f76565b34801561107057600080fd5b5061055161107f3660046151c3565b61324c565b34801561109057600080fd5b5061055161109f3660046151c3565b6132c5565b3480156110b057600080fd5b506105516110bf366004615472565b6132f3565b60006110cf82613353565b806110ea57506001600160e01b03198216630271189760e51b145b8061110557506301ffc9a760e01b6001600160e01b03198316145b806111205750630271189760e51b6001600160e01b03198316145b92915050565b600061113181613378565b50603180546001600160a01b0319166001600160a01b0392909216919091179055565b600061115f81613378565b60e25462010000900460ff161561117557600080fd5b5060e2805462ff0000191662010000179055565b60606002805461119890615c30565b80601f01602080910402602001604051908101604052809291908181526020018280546111c490615c30565b80156112115780601f106111e657610100808354040283529160200191611211565b820191906000526020600020905b8154815290600101906020018083116111f457829003601f168201915b5050505050905090565b600061122682613382565b611243576040516333d1c03960e21b815260040160405180910390fd5b506000908152600660205260409020546001600160a01b031690565b600061126a82611ee9565b9050336001600160a01b038216146112a3576112868133610fa6565b6112a3576040516367d9dca160e11b815260040160405180910390fd5b60008281526006602052604080822080546001600160a01b0319166001600160a01b0387811691821790925591518593918516917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591a4505050565b6002600954141561132b5760405162461bcd60e51b815260040161132290615a55565b60405180910390fd5b6002600955611339816133a9565b6113555760405162461bcd60e51b815260040161132290615a09565b6000818152600860205260409020546001600160a01b0316331461138b5760405162461bcd60e51b8152600401611322906159e1565b6000611396826133c5565b9050600081116113d25760405162461bcd60e51b81526020600482015260076024820152664e4f5f47454d5360c81b6044820152606401611322565b602b546001600160a01b03166340c10f19336040516001600160e01b031960e084901b1681526001600160a01b03909116600482015260248101849052604401600060405180830381600087803b15801561142c57600080fd5b505af1158015611440573d6000803e3d6000fd5b5050505061144d82613416565b50506001600955565b6028546001600160a01b031633148061147957506029546001600160a01b031633145b8061148e5750602a546001600160a01b031633145b6114cb5760405162461bcd60e51b815260206004820152600e60248201526d24b73b30b634b21031b0b63632b960911b6044820152606401611322565b6000806114d88484613450565b91509150846001600160a01b03166114ef83611ee9565b6001600160a01b0316148061151d57506000828152600860205260409020546001600160a01b038681169116145b6115585760405162461bcd60e51b815260206004820152600c60248201526b1393d517d653d55497d3919560a21b6044820152606401611322565b611562818361355a565b8051604051637921219560e11b81523060048201526001600160a01b038716602482015260448101919091526001606482015260a06084820152600060a4820152339063f242432a9060c401600060405180830381600087803b1580156115c857600080fd5b505af11580156115dc573d6000803e3d6000fd5b505050508060000151827f88d85d9fe75c8583ec7f6a1262ac69c91c1a8e071726926638c91bf077df2c2683604001516040516116199190615991565b60405180910390a35050505050565b600061163786868686866136fa565b9695505050505050565b630a85bd0160e11b5b949350505050565b600061165f848484613724565b90505b9392505050565b6000611674826137a3565b9050836001600160a01b0316816001600160a01b0316146116a75760405162a1148160e81b815260040160405180910390fd5b60008281526006602052604090208054338082146001600160a01b038816909114176116f4576116d78633610fa6565b6116f457604051632ce44b5f60e11b815260040160405180910390fd5b6001600160a01b03851661171b57604051633a954ecd60e21b815260040160405180910390fd5b801561172657600082555b6001600160a01b038681166000908152600560205260408082208054600019019055918716808252919020805460010190554260a01b17600160e11b17600085815260046020526040902055600160e11b83166117b157600184016000818152600460205260409020546117af5760005481146117af5760008181526004602052604090208490555b505b83856001600160a01b0316876001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45b505050505050565b600c81600b811061180b57600080fd5b6002020180546001909101546001600160a01b0382169250600160a01b90910461ffff169060401b83565b905090565b6002600954141561185e5760405162461bcd60e51b815260040161132290615a55565b600260095561186d3382613804565b506001600955565b6000828152600a602052604090206001015461189081613378565b61189a8383613a53565b505050565b60006118aa81613378565b60e25460ff16806118c2575060e254610100900460ff165b6118cb57600080fd5b602f5433906031906118dd9085615b37565b111561192b5760405162461bcd60e51b815260206004820152601760248201527f5445414d5f4d494e545f4c494d49545f524541434845440000000000000000006044820152606401611322565b611945818460405180602001604052806000815250613ad9565b82602f60008282546119579190615b37565b9091555050505050565b6026602052816000526040600020818154811061197d57600080fd5b90600052602060002001600091509150505481565b6001600160a01b0381163314611a025760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b6064820152608401611322565b611a0c8282613b3f565b5050565b6000611a1b81613378565b60e2805460ff640100000000808304821615810264ff000000001990931692909217928390556040517f6097f9dfed16094120986b76714f42f75cca68d783b5a8d0da2f78dacb90c50693611a799390049091161515815260200190565b60405180910390a150565b6000611a8f81613378565b60e25460009047908290600160301b900460ff16611b6e57602e548211611ab857819250611abe565b602e5492505b60405173670326f4470d4d2f5347377ff187717a81ab1318908490600081818185875af1925050503d8060008114611b12576040519150601f19603f3d011682016040523d82523d6000602084013e611b17565b606091505b50508091505080611b535760405162461bcd60e51b8152600401611322906020808252600490820152634e4f504560e01b604082015260600190565b60e2805466ff0000000000001916600160301b179055611c56565b60005b600b811015611c5457600c81600b8110611b9b57634e487b7160e01b600052603260045260246000fd5b60020201546001600160a01b03166103e8600c83600b8110611bcd57634e487b7160e01b600052603260045260246000fd5b6002020154611be790600160a01b900461ffff1686615b94565b611bf19190615b74565b604051600081818185875af1925050503d8060008114611c2d576040519150601f19603f3d011682016040523d82523d6000602084013e611c32565b606091505b50508092505081611c4257600080fd5b80611c4c81615c65565b915050611b71565b505b50505050565b6000611c6781613378565b50602e55565b6000611c7881613378565b5060e2805463ff00000019811663010000009182900460ff1615909102179055565b61189a838383604051806020016040528060008152506126d5565b6000611cc081613378565b60e25462010000900460ff1615611cd657600080fd5b838214611ce257600080fd5b60005b848110156117f357858582818110611d0d57634e487b7160e01b600052603260045260246000fd5b9050602002016020810190611d229190615772565b6034858584818110611d4457634e487b7160e01b600052603260045260246000fd5b905060200201356115b38110611d6a57634e487b7160e01b600052603260045260246000fd5b602091828204019190066101000a81548160ff021916908360ff1602179055508080611d9590615c65565b915050611ce5565b6000611da881613378565b611a0c7f9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a683611875565b6000611ddd81613378565b611c5660338484614f1a565b6000611120826133c5565b6060816000816001600160401b03811115611e1f57634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015611e7157816020015b604080516080810182526000808252602080830182905292820181905260608201528252600019909201910181611e3d5790505b50905060005b828114611ee057611ead868683818110611ea157634e487b7160e01b600052603260045260246000fd5b9050602002013561272e565b828281518110611ecd57634e487b7160e01b600052603260045260246000fd5b6020908102919091010152600101611e77565b50949350505050565b6000611120826137a3565b6001600160a01b038116600090815260266020908152604091829020805483518184028101840190945280845260609392830182828015611f5457602002820191906000526020600020905b815481526020019060010190808311611f40575b50505050509050919050565b611f6d6002610252615b94565b81565b60006001600160a01b038216611f99576040516323d3ad8160e21b815260040160405180910390fd5b506001600160a01b03166000908152600560205260409020546001600160401b031690565b60026009541415611fe15760405162461bcd60e51b815260040161132290615a55565b600260095560005b81811015612033576120213384848481811061201557634e487b7160e01b600052603260045260246000fd5b90506020020135613ba6565b8061202b81615c65565b915050611fe9565b5050600160095550565b612045613c6d565b61204f6000613cc7565b565b60008161205d81613382565b6120795760405162461bcd60e51b8152600401611322906159b2565b61208283613d19565b91505b50919050565b600061183660325490565b61209e614f9e565b816120a881613382565b6120c45760405162461bcd60e51b8152600401611322906159b2565b600061164a84613d93565b60006120da81613378565b611a0c82603255565b606060008060006120f385611f70565b90506000816001600160401b0381111561211d57634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015612146578160200160208202803683370190505b50905061217360408051608081018252600080825260208201819052918101829052606081019190915290565b60005b8386146122025761218681613def565b9150816040015115612197576121fa565b81516001600160a01b0316156121ac57815194505b876001600160a01b0316856001600160a01b031614156121fa57808387806001019850815181106121ed57634e487b7160e01b600052603260045260246000fd5b6020026020010181815250505b600101612176565b50909695505050505050565b60006116628383613e2b565b6001600160a01b038116600090815260266020908152604080832080548251818502810185019093528083528493849392919083018282801561227c57602002820191906000526020600020905b815481526020019060010190808311612268575b5050505050905060005b81518110156122dd576122bf8282815181106122b257634e487b7160e01b600052603260045260246000fd5b60200260200101516133c5565b6122c99084615b37565b9250806122d581615c65565b915050612286565b50909392505050565b6000918252600a602090815260408084206001600160a01b0393909316845291905290205460ff1690565b600061231c81613378565b600182600381111561233e57634e487b7160e01b600052602160045260246000fd5b141561236657602880546001600160a01b0385166001600160a01b0319909116179055505050565b600282600381111561238857634e487b7160e01b600052602160045260246000fd5b14156123b057602980546001600160a01b0385166001600160a01b0319909116179055505050565b60038260038111156123d257634e487b7160e01b600052602160045260246000fd5b14156104f757602a80546001600160a01b0385166001600160a01b0319909116179055505050565b60606003805461119890615c30565b606081831061242b57604051631960ccad60e11b815260040160405180910390fd5b60008061243760005490565b905080841115612445578093505b600061245087611f70565b90508486101561246f5785850381811015612469578091505b50612473565b5060005b6000816001600160401b0381111561249b57634e487b7160e01b600052604160045260246000fd5b6040519080825280602002602001820160405280156124c4578160200160208202803683370190505b509050816124d757935061166292505050565b60006124e28861272e565b9050600081604001516124f3575080515b885b8881141580156125055750848714155b1561258f5761251381613def565b925082604001511561252457612587565b82516001600160a01b03161561253957825191505b8a6001600160a01b0316826001600160a01b03161415612587578084888060010199508151811061257a57634e487b7160e01b600052603260045260246000fd5b6020026020010181815250505b6001016124f5565b505050928352509095945050505050565b60006125ab81613378565b50602c55565b6001600160a01b0382163314156125db5760405163b06307db60e01b815260040160405180910390fd5b3360008181526007602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b6033805461265490615c30565b80601f016020809104026020016040519081016040528092919081815260200182805461268090615c30565b80156126cd5780601f106126a2576101008083540402835291602001916126cd565b820191906000526020600020905b8154815290600101906020018083116126b057829003601f168201915b505050505081565b6126e0848484611669565b6001600160a01b0383163b15611c56576126fc84848484613e72565b611c56576040516368d2bf6b60e11b815260040160405180910390fd5b6000806000fd5b600061183660e25460ff1690565b60408051608080820183526000808352602080840182905283850182905260608085018390528551938401865282845290830182905293820181905292810183905290915060005483106127825792915050565b61278b83613def565b905080604001511561279d5792915050565b61208283613f66565b60006127b181613378565b50602d55565b600260095414156127da5760405162461bcd60e51b815260040161132290615a55565b600260095560005b818110156120335761281a3384848481811061280e57634e487b7160e01b600052603260045260246000fd5b90506020020135613804565b8061282481615c65565b9150506127e2565b606061283782613382565b61285457604051630a14c4b560e41b815260040160405180910390fd5b600061285e613f9b565b905080516000141561287f5760405180602001604052806000815250612082565b8061288984613faa565b60405160200161289a929190615840565b6040516020818303038152906040529392505050565b600260095414156128d35760405162461bcd60e51b815260040161132290615a55565b600260095561186d3382613ba6565b60e254339060ff1661292f5760405162461bcd60e51b81526020600482015260166024820152755075626c69632073616c65206e6f742061637469766560501b6044820152606401611322565b602d5461293c9087615b94565b3410156129805760405162461bcd60e51b8152602060048201526012602482015271496e73756666696369656e742066756e647360701b6044820152606401611322565b600a8611156129c45760405162461bcd60e51b815260206004820152601060248201526f4558434545445f414c4c4f57414e434560801b6044820152606401611322565b6129cd86613ff9565b15612a055760405162461bcd60e51b815260206004820152600860248201526714d3d31117d3d55560c21b6044820152606401611322565b6001600160a01b0381166000908152602460205260409020548514612a5c5760405162461bcd60e51b815260206004820152600d60248201526c494e56414c49445f4e4f4e434560981b6044820152606401611322565b612aab81868686868080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250506031546001600160a01b031691506136fa9050565b80612ac0575060e2546301000000900460ff16155b612afa5760405162461bcd60e51b815260206004820152600b60248201526a494e56414c49445f53494760a81b6044820152606401611322565b612b14818760405180602001604052806000815250613ad9565b6001600160a01b0381166000908152602460205260408120805491612b3883615c65565b9190505550505050505050565b6000828152600a6020526040902060010154612b6081613378565b61189a8383613b3f565b33600090815260266020908152604080832080548251818502810185019093528083529192909190830182828015612bc157602002820191906000526020600020905b815481526020019060010190808311612bad575b5050505050905060005b8151811015611a0c576000612bf98383815181106122b257634e487b7160e01b600052603260045260246000fd5b1115612c2f57612c2f828281518110612c2257634e487b7160e01b600052603260045260246000fd5b60200260200101516112ff565b80612c3981615c65565b915050612bcb565b6000612c4c81613378565b60e25460ff1615612c5c57600080fd5b60e2805460ff610100808304821615810261ff001990931692909217928390556040517fb5a6cf6d450acd3f8d515b1cb8e1198f105cd0bf77285a79bb78f7e10ee712a693611a799390049091161515815260200190565b6000612cbf81613378565b60e254610100900460ff1615612cd457600080fd5b60e2805460ff8082161560ff1990921682179092556040519116151581527fd95db27fb727a8efc81657db609938fd60d724f29d367d50680bc54a1c0e1ae290602001611a79565b60e2543390610100900460ff16612d755760405162461bcd60e51b815260206004820152601760248201527f507269766174652073616c65206e6f74206163746976650000000000000000006044820152606401611322565b602c54612d829087615b94565b341015612dc65760405162461bcd60e51b8152602060048201526012602482015271496e73756666696369656e742066756e647360701b6044820152606401611322565b6001600160a01b0381166000908152602360205260409020548590612deb9088615b37565b1115612e2e5760405162461bcd60e51b8152602060048201526012602482015271457863656564656420616c6c6f77616e636560701b6044820152606401611322565b612e7d81868686868080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250506031546001600160a01b031691506136fa9050565b612eb75760405162461bcd60e51b815260206004820152600b60248201526a494e56414c49445f53494760a81b6044820152606401611322565b612ec086613ff9565b15612ef85760405162461bcd60e51b815260206004820152600860248201526714d3d31117d3d55560c21b6044820152606401611322565b612f12818760405180602001604052806000815250613ad9565b6001600160a01b03811660009081526023602052604081208054889290612f3a908490615b37565b9091555050505050505050565b612f546002610252615b94565b612f6160316115b3615bb3565b611f6d9190615bb3565b6000611120826133a9565b6000856001600160a01b0316876001600160a01b031614612fa95760405162461bcd60e51b8152600401611322906159e1565b6028546001600160a01b0316331480612fcc57506029546001600160a01b031633145b80612fe15750602a546001600160a01b031633145b6130225760405162461bcd60e51b8152602060048201526012602482015271494e56414c49445f544f4b454e5f5459504560701b6044820152606401611322565b60008061302f8585613450565b91509150876001600160a01b031661304683611ee9565b6001600160a01b0316148061307457506000828152600860205260409020546001600160a01b038981169116145b6130af5760405162461bcd60e51b815260206004820152600c60248201526b1393d517d653d55497d3919560a21b6044820152606401611322565b805187146130f45760405162461bcd60e51b81526020600482015260126024820152711253959053125117d11150d3d1115117d25160721b6044820152606401611322565b856001146131395760405162461bcd60e51b815260206004820152601260248201527143414e5f4f4e4c595f45515549505f4f4e4560701b6044820152606401611322565b336001600160a01b031663976fb5436040518163ffffffff1660e01b815260040160206040518083038186803b15801561317257600080fd5b505afa158015613186573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131aa91906156c5565b60038111156131c957634e487b7160e01b600052602160045260246000fd5b816040015160038111156131ed57634e487b7160e01b600052602160045260246000fd5b1461322d5760405162461bcd60e51b815260206004820152601060248201526f494e56414c49445f4954454d5459504560801b6044820152606401611322565b6132378183614054565b5063f23a6e6160e01b98975050505050505050565b613254613c6d565b6001600160a01b0381166132b95760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401611322565b6132c281613cc7565b50565b60006132d081613378565b50602b80546001600160a01b0319166001600160a01b0392909216919091179055565b7f9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a661331d81613378565b6133418361332c600285615b94565b60405180602001604052806000815250613ad9565b81603060008282546119579190615b37565b60006001600160e01b03198216637965db0b60e01b14806111205750611120826141be565b6132c2813361420c565b6000805482108015611120575050600090815260046020526040902054600160e01b161590565b6000306133b583611ee9565b6001600160a01b03161492915050565b6000806133d183613d93565b90506000620151806133e285614270565b6133ec9042615bb3565b6133f69190615b74565b60325483519192509061340c9060ff1683615b94565b61164a9190615b94565b8061342081613382565b61343c5760405162461bcd60e51b8152600401611322906159b2565b506000908152602560205260409020429055565b60408051606081018252600080825260208201819052918101829052600061347b6020828688615b0f565b81019061348891906155e3565b90506134ab60408051606081018252600080825260208201819052909182015290565b6134b9604060208789615b0f565b8101906134c691906155e3565b81526134d6606060408789615b0f565b8101906134e39190615772565b60ff1660208201526134f88560608189615b0f565b81019061350591906156a9565b8160400190600381111561352957634e487b7160e01b600052602160045260246000fd5b9081600381111561354a57634e487b7160e01b600052602160045260246000fd5b90525090925090505b9250929050565b6135688183604001516142ac565b6135a45760405162461bcd60e51b815260206004820152600d60248201526c536c6f7420697320656d70747960981b6044820152606401611322565b60006135af826143bf565b90506001836040015160038111156135d757634e487b7160e01b600052602160045260246000fd5b1415613614578251602082015151146136025760405162461bcd60e51b815260040161132290615a2d565b61360a614586565b60208201526136d6565b60028360400151600381111561363a57634e487b7160e01b600052602160045260246000fd5b1415613677578251604082015151146136655760405162461bcd60e51b815260040161132290615a2d565b61366d614586565b60408201526136d6565b60038360400151600381111561369d57634e487b7160e01b600052602160045260246000fd5b14156104f7578251606082015151146136c85760405162461bcd60e51b815260040161132290615a2d565b6136d0614586565b60608201525b6020830151815182906136ea908390615bca565b60ff1690525061189a82826145c7565b6000613707848484613724565b80156116375750836137198787613e2b565b149695505050505050565b6000816001600160a01b03166137918461378b876040517f19457468657265756d205369676e6564204d6573736167653a0a3332000000006020820152603c8101829052600090605c01604051602081830303815290604052805190602001209050919050565b9061473e565b6001600160a01b031614949350505050565b6000816000548110156137eb57600081815260046020526040902054600160e01b81166137e9575b806116625750600019016000818152600460205260409020546137cb565b505b604051636f96cda160e11b815260040160405180910390fd5b61380d816133a9565b6138295760405162461bcd60e51b815260040161132290615a09565b61383281614762565b600061383d826133c5565b905080156138b857602b546001600160a01b03166340c10f19336040516001600160e01b031960e084901b1681526001600160a01b03909116600482015260248101849052604401600060405180830381600087803b15801561389f57600080fd5b505af11580156138b3573d6000803e3d6000fd5b505050505b6001600160a01b03831660009081526026602052604081205481906138df90600190615bb3565b90505b6001600160a01b038516600090815260266020526040902080548591908490811061391d57634e487b7160e01b600052603260045260246000fd5b90600052602060002001541461393f578161393781615c65565b9250506138e2565b6001600160a01b038516600090815260266020526040902080548290811061397757634e487b7160e01b600052603260045260246000fd5b906000526020600020015460266000876001600160a01b03166001600160a01b0316815260200190815260200160002083815481106139c657634e487b7160e01b600052603260045260246000fd5b60009182526020808320909101929092556001600160a01b0387168152602690915260409020805480613a0957634e487b7160e01b600052603160045260246000fd5b6000828152602080822083016000199081018390559092019092558582526025815260408083208390556008909152902080546001600160a01b0319169055611c54308686611669565b613a5d82826122e6565b611a0c576000828152600a602090815260408083206001600160a01b03851684529091529020805460ff19166001179055613a953390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b613ae3838361482d565b6001600160a01b0383163b1561189a576000548281035b613b0d6000868380600101945086613e72565b613b2a576040516368d2bf6b60e11b815260040160405180910390fd5b818110613afa578160005414611c5457600080fd5b613b4982826122e6565b15611a0c576000828152600a602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b613bb08282614924565b613bcc5760405162461bcd60e51b8152600401611322906159e1565b613bd5816133a9565b15613c135760405162461bcd60e51b815260206004820152600e60248201526d1053149150511657d4d51052d15160921b6044820152606401611322565b613c1c81613416565b600081815260086020908152604080832080546001600160a01b0319166001600160a01b03871690811790915583526026825282208054600181018255908352912001819055611a0c823083611c9a565b600b546001600160a01b0316331461204f5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401611322565b600b80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600081613d2581613382565b613d415760405162461bcd60e51b8152600401611322906159b2565b60006034846115b38110613d6557634e487b7160e01b600052603260045260246000fd5b602081049091015460ff601f9092166101000a900416905080613d8c576005925050612085565b9150612085565b613d9b614f9e565b81613da581613382565b613dc15760405162461bcd60e51b8152600401611322906159b2565b6000613dcc846143bf565b9050613dd784613d19565b8151613de39190615b4f565b60ff1681529392505050565b6040805160808101825260008082526020820181905291810182905260608101919091526000828152600460205260409020546111209061495e565b6040516bffffffffffffffffffffffff19606084901b1660208201526034810182905260009060540160405160208183030381529060405280519060200120905092915050565b604051630a85bd0160e11b81526000906001600160a01b0385169063150b7a0290613ea79033908990889088906004016158e4565b602060405180830381600087803b158015613ec157600080fd5b505af1925050508015613ef1575060408051601f3d908101601f19168201909252613eee9181019061568d565b60015b613f4c573d808015613f1f576040519150601f19603f3d011682016040523d82523d6000602084013e613f24565b606091505b508051613f44576040516368d2bf6b60e11b815260040160405180910390fd5b805181602001fd5b6001600160e01b031916630a85bd0160e11b14905061164a565b604080516080810182526000808252602082018190529181018290526060810191909152611120613f96836137a3565b61495e565b60606033805461119890615c30565b604080516080810191829052607f0190826030600a8206018353600a90045b8015613fe757600183039250600a81066030018353600a9004613fc9565b50819003601f19909101908152919050565b60006140086002610252615b94565b61401560316115b3615bb3565b61401f9190615bb3565b82603054602f5461402f60005490565b6140399190615bb3565b6140439190615bb3565b61404d9190615b37565b1192915050565b6140628183604001516142ac565b156140a35760405162461bcd60e51b8152602060048201526011602482015270536c6f74206973206e6f7420656d70747960781b6044820152606401611322565b60006140ae826143bf565b90506001836040015160038111156140d657634e487b7160e01b600052602160045260246000fd5b14156140e85760208101839052614154565b60028360400151600381111561410e57634e487b7160e01b600052602160045260246000fd5b14156141205760408101839052614154565b60038360400151600381111561414657634e487b7160e01b600052602160045260246000fd5b14156104f757606081018390525b602083015181518290614168908390615b4f565b60ff1690525061417882826145c7565b8260000151827f770f9b8c440277434bb6e78e7dab021f412675ae32d83b7b172487ab66bc04bd85604001516040516141b19190615991565b60405180910390a3505050565b60006301ffc9a760e01b6001600160e01b0319831614806141ef57506380ac58cd60e01b6001600160e01b03198316145b806111205750506001600160e01b031916635b5e139f60e01b1490565b61421682826122e6565b611a0c5761422e816001600160a01b031660146149a5565b6142398360206149a5565b60405160200161424a92919061586f565b60408051601f198184030181529082905262461bcd60e51b82526113229160040161599f565b60008161427c81613382565b6142985760405162461bcd60e51b8152600401611322906159b2565b505060009081526025602052604090205490565b6000826142b881613382565b6142d45760405162461bcd60e51b8152600401611322906159b2565b60006142df856143bf565b9050600184600381111561430357634e487b7160e01b600052602160045260246000fd5b141561433c576001816020015160400151600381111561433357634e487b7160e01b600052602160045260246000fd5b149250506143b8565b600284600381111561435e57634e487b7160e01b600052602160045260246000fd5b141561438e576002816040015160400151600381111561433357634e487b7160e01b600052602160045260246000fd5b6003816060015160400151600381111561433357634e487b7160e01b600052602160045260246000fd5b5092915050565b6143c7614f9e565b816143d181613382565b6143ed5760405162461bcd60e51b8152600401611322906159b2565b60008381526022602090815260408083208151608081018352815460ff9081168252835160608101855260018401805482526002850154808416838901529396949594870194919390929184019161010090910416600381111561446157634e487b7160e01b600052602160045260246000fd5b600381111561448057634e487b7160e01b600052602160045260246000fd5b905250815260408051606081018252600384810180548352600486015460ff808216602086810191909152909601959394919391850192610100909104909116908111156144de57634e487b7160e01b600052602160045260246000fd5b60038111156144fd57634e487b7160e01b600052602160045260246000fd5b9052508152604080516060810182526005840180548252600685015460ff80821660208581019190915290950194929391929184019161010090910416600381111561455957634e487b7160e01b600052602160045260246000fd5b600381111561457857634e487b7160e01b600052602160045260246000fd5b905250905250949350505050565b6145a760408051606081018252600080825260208201819052909182015290565b604080516060810182526000808252602082018190529091820152919050565b816145d181613382565b6145ed5760405162461bcd60e51b8152600401611322906159b2565b6000838152602260209081526040918290208451815460ff91821660ff19918216178355838701518051600185019081559481015160028501805491909416928116831784559581015188969495919491939092909161ffff19161761010083600381111561466c57634e487b7160e01b600052602160045260246000fd5b0217905550505060408281015180516003808501918255602083015160048601805460ff90921660ff19831681178255958501519495939493909261ffff1990921617906101009084908111156146d357634e487b7160e01b600052602160045260246000fd5b021790555050506060820151805160058301908155602082015160068401805460ff90921660ff1983168117825560408501519261ffff19161761010083600381111561473057634e487b7160e01b600052602160045260246000fd5b021790555050505050505050565b600080600061474d8585614b86565b9150915061475a81614bf3565b509392505050565b33600061476e83611ee9565b90506001600160a01b03811630146147985760405162461bcd60e51b815260040161132290615a09565b6000838152600860205260409020546001600160a01b038381169116146147d15760405162461bcd60e51b8152600401611322906159e1565b60008381526006602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518693918516917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591a4505050565b6000548161484e5760405163b562e8dd60e01b815260040160405180910390fd5b6001600160a01b03831660008181526005602090815260408083208054680100000000000000018802019055848352600490915281206001851460e11b4260a01b178317905582840190839083907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8180a4600183015b8181146148fd57808360007fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef600080a46001016148c5565b508161491b57604051622e076360e81b815260040160405180910390fd5b60005550505050565b60008061493083613f66565b9050836001600160a01b031681600001516001600160a01b031614801561164a575060400151159392505050565b604080516080810182526001600160a01b038316815260a083901c6001600160401b03166020820152600160e01b831615159181019190915260e89190911c606082015290565b606060006149b4836002615b94565b6149bf906002615b37565b6001600160401b038111156149e457634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015614a0e576020820181803683370190505b509050600360fc1b81600081518110614a3757634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110614a7457634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a9053506000614a98846002615b94565b614aa3906001615b37565b90505b6001811115614b37576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110614ae557634e487b7160e01b600052603260045260246000fd5b1a60f81b828281518110614b0957634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a90535060049490941c93614b3081615c19565b9050614aa6565b5083156116625760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401611322565b600080825160411415614bbd5760208301516040840151606085015160001a614bb187828585614df4565b94509450505050613553565b825160401415614be75760208301516040840151614bdc868383614ee1565b935093505050613553565b50600090506002613553565b6000816004811115614c1557634e487b7160e01b600052602160045260246000fd5b1415614c1e5750565b6001816004811115614c4057634e487b7160e01b600052602160045260246000fd5b1415614c8e5760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606401611322565b6002816004811115614cb057634e487b7160e01b600052602160045260246000fd5b1415614cfe5760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606401611322565b6003816004811115614d2057634e487b7160e01b600052602160045260246000fd5b1415614d795760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b6064820152608401611322565b6004816004811115614d9b57634e487b7160e01b600052602160045260246000fd5b14156132c25760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202776272076616c604482015261756560f01b6064820152608401611322565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0831115614e2b5750600090506003614ed8565b8460ff16601b14158015614e4357508460ff16601c14155b15614e545750600090506004614ed8565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015614ea8573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116614ed157600060019250925050614ed8565b9150600090505b94509492505050565b6000806001600160ff1b03831681614efe60ff86901c601b615b37565b9050614f0c87828885614df4565b935093505050935093915050565b828054614f2690615c30565b90600052602060002090601f016020900481019282614f485760008555614f8e565b82601f10614f615782800160ff19823516178555614f8e565b82800160010185558215614f8e579182015b82811115614f8e578235825591602001919060010190614f73565b50614f9a929150615025565b5090565b6040518060800160405280600060ff168152602001614fd460408051606081018252600080825260208201819052909182015290565b8152602001614ffa60408051606081018252600080825260208201819052909182015290565b815260200161502060408051606081018252600080825260208201819052909182015290565b905290565b5b80821115614f9a5760008155600101615026565b80356001600160a01b038116811461505157600080fd5b919050565b60008083601f840112615067578182fd5b5081356001600160401b0381111561507d578182fd5b6020830191508360208260051b850101111561355357600080fd5b600082601f8301126150a8578081fd5b813560206001600160401b038211156150c3576150c3615c96565b8160051b6150d2828201615adf565b8381528281019086840183880185018910156150ec578687fd5b8693505b8584101561510e5780358352600193909301929184019184016150f0565b50979650505050505050565b60008083601f84011261512b578182fd5b5081356001600160401b03811115615141578182fd5b60208301915083602082850101111561355357600080fd5b600082601f830112615169578081fd5b81356001600160401b0381111561518257615182615c96565b615195601f8201601f1916602001615adf565b8181528460208386010111156151a9578283fd5b816020850160208301379081016020019190915292915050565b6000602082840312156151d4578081fd5b6116628261503a565b600080604083850312156151ef578081fd5b6151f88361503a565b91506152066020840161503a565b90509250929050565b60008060008060008060a08789031215615227578182fd5b6152308761503a565b955061523e6020880161503a565b945060408701356001600160401b0380821115615259578384fd5b6152658a838b01615098565b9550606089013591508082111561527a578384fd5b6152868a838b01615098565b9450608089013591508082111561529b578384fd5b506152a889828a0161511a565b979a9699509497509295939492505050565b6000806000606084860312156152ce578283fd5b6152d78461503a565b92506152e56020850161503a565b9150604084013590509250925092565b6000806000806080858703121561530a578384fd5b6153138561503a565b93506153216020860161503a565b92506040850135915060608501356001600160401b03811115615342578182fd5b61534e87828801615159565b91505092959194509250565b60008060008060008060a08789031215615372578182fd5b61537b8761503a565b95506153896020880161503a565b9450604087013593506060870135925060808701356001600160401b038111156153b1578283fd5b6152a889828a0161511a565b600080604083850312156153cf578182fd5b6153d88361503a565b9150602083013580151581146153ec578182fd5b809150509250929050565b60008060006040848603121561540b578081fd5b6154148461503a565b925060208401356001600160401b0381111561542e578182fd5b61543a8682870161511a565b9497909650939450505050565b60008060408385031215615459578182fd5b6154628361503a565b915060208301356153ec81615cc2565b60008060408385031215615484578182fd5b61548d8361503a565b946020939093013593505050565b600080600080600060a086880312156154b2578283fd5b6154bb8661503a565b9450602086013593506040860135925060608601356001600160401b038111156154e3578182fd5b6154ef88828901615159565b9250506154fe6080870161503a565b90509295509295909350565b60008060006060848603121561551e578081fd5b6155278461503a565b95602085013595506040909401359392505050565b6000806020838503121561554e578182fd5b82356001600160401b03811115615563578283fd5b61556f85828601615056565b90969095509350505050565b60008060008060408587031215615590578182fd5b84356001600160401b03808211156155a6578384fd5b6155b288838901615056565b909650945060208701359150808211156155ca578384fd5b506155d787828801615056565b95989497509550505050565b6000602082840312156155f4578081fd5b5035919050565b6000806040838503121561560d578182fd5b823591506152066020840161503a565b600080600060608486031215615631578081fd5b8335925060208401356001600160401b0381111561564d578182fd5b61565986828701615159565b9250506156686040850161503a565b90509250925092565b600060208284031215615682578081fd5b813561166281615cac565b60006020828403121561569e578081fd5b815161166281615cac565b6000602082840312156156ba578081fd5b813561166281615cc2565b6000602082840312156156d6578081fd5b815161166281615cc2565b600080602083850312156156f3578182fd5b82356001600160401b03811115615708578283fd5b61556f8582860161511a565b60008060008060006080868803121561572b578283fd5b85359450602086013593506040860135925060608601356001600160401b03811115615755578182fd5b6157618882890161511a565b969995985093965092949392505050565b600060208284031215615783578081fd5b813560ff81168114611662578182fd5b600081518084526157ab816020860160208601615bed565b601f01601f19169290920160200192915050565b600481106157dd57634e487b7160e01b600052602160045260246000fd5b9052565b8051825260ff6020820151166020830152604081015161189a60408401826157bf565b80516001600160a01b031682526020808201516001600160401b03169083015260408082015115159083015260609081015162ffffff16910152565b60008351615852818460208801615bed565b835190830190615866818360208801615bed565b01949350505050565b7f416363657373436f6e74726f6c3a206163636f756e74200000000000000000008152600083516158a7816017850160208801615bed565b7001034b99036b4b9b9b4b733903937b6329607d1b60179184019182015283516158d8816028840160208801615bed565b01602801949350505050565b6001600160a01b038581168252841660208201526040810183905260806060820181905260009061163790830184615793565b6020808252825182820181905260009190848201906040850190845b8181101561220257615946838551615804565b9284019260809290920191600101615933565b6020808252825182820181905260009190848201906040850190845b8181101561220257835183529284019291840191600101615975565b6020810161112082846157bf565b6020815260006116626020830184615793565b6020808252601590820152742a37b5b2b7103237b2b9903737ba1032bc34b9ba1760591b604082015260600190565b6020808252600e908201526d1393d517d055551213d49254d15160921b604082015260600190565b6020808252600a90820152691393d517d4d51052d15160b21b604082015260600190565b6020808252600e908201526d496e636f7272656374206974656d60901b604082015260600190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b815160ff168152602080830151610140830191615aab908401826157e1565b506040830151615abe60808401826157e1565b5060608301516143b860e08401826157e1565b608081016111208284615804565b604051601f8201601f191681016001600160401b0381118282101715615b0757615b07615c96565b604052919050565b60008085851115615b1e578182fd5b83861115615b2a578182fd5b5050820193919092039150565b60008219821115615b4a57615b4a615c80565b500190565b600060ff821660ff84168060ff03821115615b6c57615b6c615c80565b019392505050565b600082615b8f57634e487b7160e01b81526012600452602481fd5b500490565b6000816000190483118215151615615bae57615bae615c80565b500290565b600082821015615bc557615bc5615c80565b500390565b600060ff821660ff841680821015615be457615be4615c80565b90039392505050565b60005b83811015615c08578181015183820152602001615bf0565b83811115611c565750506000910152565b600081615c2857615c28615c80565b506000190190565b600181811c90821680615c4457607f821691505b6020821081141561208557634e487b7160e01b600052602260045260246000fd5b6000600019821415615c7957615c79615c80565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160e01b0319811681146132c257600080fd5b600481106132c257600080fdfea264697066735822122087ca08849f30dcfbe79d96b5c0b2997ef105966ab3be014d3f393e74742aead064736f6c6343000804003368747470733a2f2f63646e2d7374672e6d61676963666f6c6b2e696f2f6170692f67656e657369732f000000000000000000000000c80f2f0598db841f48afa998fb70122e37361f4a0000000000000000000000000f88130d3a638bace612ca21b2916a62ad9a0b3d000000000000000000000000fa912057f195a35214da31c2b623b6b2eb45baaf00000000000000000000000088d6f1be76b5a86cff11f76051f191f00dda116a
Deployed Bytecode
0x6080604052600436106104f75760003560e01c8063764f1a591161028c578063c23dc68f1161015a578063dd48f07d116100cc578063f0292a0311610085578063f0292a031461100f578063f0a5242414611024578063f23a6e6114611044578063f2fde38b14611064578063fd09035d14611084578063fdb359b4146110a457600080fd5b8063dd48f07d14610f4b578063dfe5dd6814610f61578063e222c7f914610f76578063e985e9c514610f8b578063eb1edd6114610fd4578063edee469914610ffc57600080fd5b8063cda6b8471161011e578063cda6b84714610e99578063d200bec814610eb9578063d212a69a14610ecc578063d539139314610ee2578063d547741f14610f16578063d8ec6cfa14610f3657600080fd5b8063c23dc68f14610dec578063c627525514610e19578063c782311c14610e39578063c87b56dd14610e59578063ca29e8c814610e7957600080fd5b806395d89b41116101fe578063a22cb465116101b7578063a22cb46514610d3f578063ac4e88af14610d5f578063b4e87e8f14610d82578063b88d4fde14610d97578063bc197c8114610db7578063bc8893b414610dd757600080fd5b806395d89b4114610c9f578063999ec86314610cb457806399a2557a14610cd55780639d24863014610cf5578063a10f151e14610d0a578063a217fddf14610d2a57600080fd5b806386ad5ebc1161025057806386ad5ebc14610bcb5780638c85c3c814610beb5780638da5cb5b14610c0b57806391d1485414610c2957806392673ff514610c4957806392ae9bfd14610c7f57600080fd5b8063764f1a5914610b1757806377f8383014610b495780637b30396514610b5e57806381af84c314610b8b5780638462151c14610bab57600080fd5b8063353b3172116103c95780634e9118171161033b57806363c28db1116102f457806363c28db114610a6b57806364124e1a14610a9857806370a0823114610aad57806370ea028f14610acd578063715018a614610aed5780637290990514610b0257600080fd5b80634e911817146109b357806355f804b3146109c85780635a5804b3146109e85780635bbb217714610a08578063611f3f1014610a355780636352211e14610a4b57600080fd5b80633cd01bb51161038d5780633cd01bb5146108e85780633d18678e1461091e5780633dda86521461093e57806342842e0e14610953578063485dcbc7146109735780634af9a0301461099357600080fd5b8063353b31721461085d57806336568abe1461087d57806338de114e1461089d5780633b8105b3146108be5780633ccfd60b146108d357600080fd5b806318160ddd1161046d578063283248be11610426578063283248be146107775780632a237bb6146107ca5780632cfb6688146107e75780632e2047d4146108075780632f2ff15d1461081d5780632fbba1151461083d57600080fd5b806318160ddd146106b65780631e81e656146106cf5780631f220560146106ef57806323b872dd14610711578063248a9ca31461073157806327d5f20e1461076157600080fd5b8063095ea7b3116104bf578063095ea7b3146105c257806309f0138c146105e25780630b1350a21461061d5780630f1740d11461063d57806312c61be81461065d578063150b7a021461067d57600080fd5b806301ffc9a7146104fc578063046dc16614610531578063057557621461055357806306fdde0314610568578063081812fc1461058a575b600080fd5b34801561050857600080fd5b5061051c610517366004615671565b6110c4565b60405190151581526020015b60405180910390f35b34801561053d57600080fd5b5061055161054c3660046151c3565b611126565b005b34801561055f57600080fd5b50610551611154565b34801561057457600080fd5b5061057d611189565b604051610528919061599f565b34801561059657600080fd5b506105aa6105a53660046155e3565b61121b565b6040516001600160a01b039091168152602001610528565b3480156105ce57600080fd5b506105516105dd366004615472565b61125f565b3480156105ee57600080fd5b5061060f6105fd3660046151c3565b60246020526000908152604090205481565b604051908152602001610528565b34801561062957600080fd5b506105516106383660046155e3565b6112ff565b34801561064957600080fd5b506105516106583660046153f7565b611456565b34801561066957600080fd5b5061051c61067836600461549b565b611628565b34801561068957600080fd5b5061069d6106983660046152f5565b611641565b6040516001600160e01b03199091168152602001610528565b3480156106c257600080fd5b506001546000540361060f565b3480156106db57600080fd5b5061051c6106ea36600461561d565b611652565b3480156106fb57600080fd5b5060e25461051c90640100000000900460ff1681565b34801561071d57600080fd5b5061055161072c3660046152ba565b611669565b34801561073d57600080fd5b5061060f61074c3660046155e3565b6000908152600a602052604090206001015490565b34801561076d57600080fd5b5061060f60305481565b34801561078357600080fd5b506107976107923660046155e3565b6117fb565b604080516001600160a01b03909416845261ffff909216602084015267ffffffffffffffff191690820152606001610528565b3480156107d657600080fd5b5060e254610100900460ff1661051c565b3480156107f357600080fd5b506105516108023660046155e3565b61183b565b34801561081357600080fd5b5061060f602c5481565b34801561082957600080fd5b506105516108383660046155fb565b611875565b34801561084957600080fd5b506105516108583660046155e3565b61189f565b34801561086957600080fd5b5061060f610878366004615472565b611961565b34801561088957600080fd5b506105516108983660046155fb565b611992565b3480156108a957600080fd5b5060e25461051c906301000000900460ff1681565b3480156108ca57600080fd5b50610551611a10565b3480156108df57600080fd5b50610551611a84565b3480156108f457600080fd5b5061060f6109033660046151c3565b6001600160a01b031660009081526026602052604090205490565b34801561092a57600080fd5b506105516109393660046155e3565b611c5c565b34801561094a57600080fd5b50610551611c6d565b34801561095f57600080fd5b5061055161096e3660046152ba565b611c9a565b34801561097f57600080fd5b5061055161098e36600461557b565b611cb5565b34801561099f57600080fd5b506105516109ae3660046151c3565b611d9d565b3480156109bf57600080fd5b5061060f600a81565b3480156109d457600080fd5b506105516109e33660046156e1565b611dd2565b3480156109f457600080fd5b5061060f610a033660046155e3565b611de9565b348015610a1457600080fd5b50610a28610a2336600461553c565b611df4565b6040516105289190615917565b348015610a4157600080fd5b5061060f602d5481565b348015610a5757600080fd5b506105aa610a663660046155e3565b611ee9565b348015610a7757600080fd5b50610a8b610a863660046151c3565b611ef4565b6040516105289190615959565b348015610aa457600080fd5b5061060f611f60565b348015610ab957600080fd5b5061060f610ac83660046151c3565b611f70565b348015610ad957600080fd5b50610551610ae836600461553c565b611fbe565b348015610af957600080fd5b5061055161203d565b348015610b0e57600080fd5b5061060f600281565b348015610b2357600080fd5b50610b37610b323660046155e3565b612051565b60405160ff9091168152602001610528565b348015610b5557600080fd5b5061060f61208b565b348015610b6a57600080fd5b50610b7e610b793660046155e3565b612096565b6040516105289190615a8c565b348015610b9757600080fd5b50610551610ba63660046155e3565b6120cf565b348015610bb757600080fd5b50610a8b610bc63660046151c3565b6120e3565b348015610bd757600080fd5b5061060f610be6366004615472565b61220e565b348015610bf757600080fd5b5061060f610c063660046151c3565b61221a565b348015610c1757600080fd5b50600b546001600160a01b03166105aa565b348015610c3557600080fd5b5061051c610c443660046155fb565b6122e6565b348015610c5557600080fd5b506105aa610c643660046155e3565b6008602052600090815260409020546001600160a01b031681565b348015610c8b57600080fd5b50610551610c9a366004615447565b612311565b348015610cab57600080fd5b5061057d6123fa565b348015610cc057600080fd5b5060e25461051c90600160301b900460ff1681565b348015610ce157600080fd5b50610a8b610cf036600461550a565b612409565b348015610d0157600080fd5b5061060f603181565b348015610d1657600080fd5b50610551610d253660046155e3565b6125a0565b348015610d3657600080fd5b5061060f600081565b348015610d4b57600080fd5b50610551610d5a3660046153bd565b6125b1565b348015610d6b57600080fd5b5060e25461051c9065010000000000900460ff1681565b348015610d8e57600080fd5b5061057d612647565b348015610da357600080fd5b50610551610db23660046152f5565b6126d5565b348015610dc357600080fd5b5061069d610dd236600461520f565b612719565b348015610de357600080fd5b5061051c612720565b348015610df857600080fd5b50610e0c610e073660046155e3565b61272e565b6040516105289190615ad1565b348015610e2557600080fd5b50610551610e343660046155e3565b6127a6565b348015610e4557600080fd5b50610551610e5436600461553c565b6127b7565b348015610e6557600080fd5b5061057d610e743660046155e3565b61282c565b348015610e8557600080fd5b506031546105aa906001600160a01b031681565b348015610ea557600080fd5b50610551610eb43660046155e3565b6128b0565b610551610ec7366004615714565b6128e2565b348015610ed857600080fd5b5061060f602e5481565b348015610eee57600080fd5b5061060f7f9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a681565b348015610f2257600080fd5b50610551610f313660046155fb565b612b45565b348015610f4257600080fd5b50610551612b6a565b348015610f5757600080fd5b5061060f602f5481565b348015610f6d57600080fd5b50610551612c41565b348015610f8257600080fd5b50610551612cb4565b348015610f9757600080fd5b5061051c610fa63660046151dd565b6001600160a01b03918216600090815260076020908152604080832093909416825291909152205460ff1690565b348015610fe057600080fd5b506105aa73670326f4470d4d2f5347377ff187717a81ab131881565b61055161100a366004615714565b612d1c565b34801561101b57600080fd5b5061060f612f47565b34801561103057600080fd5b5061051c61103f3660046155e3565b612f6b565b34801561105057600080fd5b5061069d61105f36600461535a565b612f76565b34801561107057600080fd5b5061055161107f3660046151c3565b61324c565b34801561109057600080fd5b5061055161109f3660046151c3565b6132c5565b3480156110b057600080fd5b506105516110bf366004615472565b6132f3565b60006110cf82613353565b806110ea57506001600160e01b03198216630271189760e51b145b8061110557506301ffc9a760e01b6001600160e01b03198316145b806111205750630271189760e51b6001600160e01b03198316145b92915050565b600061113181613378565b50603180546001600160a01b0319166001600160a01b0392909216919091179055565b600061115f81613378565b60e25462010000900460ff161561117557600080fd5b5060e2805462ff0000191662010000179055565b60606002805461119890615c30565b80601f01602080910402602001604051908101604052809291908181526020018280546111c490615c30565b80156112115780601f106111e657610100808354040283529160200191611211565b820191906000526020600020905b8154815290600101906020018083116111f457829003601f168201915b5050505050905090565b600061122682613382565b611243576040516333d1c03960e21b815260040160405180910390fd5b506000908152600660205260409020546001600160a01b031690565b600061126a82611ee9565b9050336001600160a01b038216146112a3576112868133610fa6565b6112a3576040516367d9dca160e11b815260040160405180910390fd5b60008281526006602052604080822080546001600160a01b0319166001600160a01b0387811691821790925591518593918516917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591a4505050565b6002600954141561132b5760405162461bcd60e51b815260040161132290615a55565b60405180910390fd5b6002600955611339816133a9565b6113555760405162461bcd60e51b815260040161132290615a09565b6000818152600860205260409020546001600160a01b0316331461138b5760405162461bcd60e51b8152600401611322906159e1565b6000611396826133c5565b9050600081116113d25760405162461bcd60e51b81526020600482015260076024820152664e4f5f47454d5360c81b6044820152606401611322565b602b546001600160a01b03166340c10f19336040516001600160e01b031960e084901b1681526001600160a01b03909116600482015260248101849052604401600060405180830381600087803b15801561142c57600080fd5b505af1158015611440573d6000803e3d6000fd5b5050505061144d82613416565b50506001600955565b6028546001600160a01b031633148061147957506029546001600160a01b031633145b8061148e5750602a546001600160a01b031633145b6114cb5760405162461bcd60e51b815260206004820152600e60248201526d24b73b30b634b21031b0b63632b960911b6044820152606401611322565b6000806114d88484613450565b91509150846001600160a01b03166114ef83611ee9565b6001600160a01b0316148061151d57506000828152600860205260409020546001600160a01b038681169116145b6115585760405162461bcd60e51b815260206004820152600c60248201526b1393d517d653d55497d3919560a21b6044820152606401611322565b611562818361355a565b8051604051637921219560e11b81523060048201526001600160a01b038716602482015260448101919091526001606482015260a06084820152600060a4820152339063f242432a9060c401600060405180830381600087803b1580156115c857600080fd5b505af11580156115dc573d6000803e3d6000fd5b505050508060000151827f88d85d9fe75c8583ec7f6a1262ac69c91c1a8e071726926638c91bf077df2c2683604001516040516116199190615991565b60405180910390a35050505050565b600061163786868686866136fa565b9695505050505050565b630a85bd0160e11b5b949350505050565b600061165f848484613724565b90505b9392505050565b6000611674826137a3565b9050836001600160a01b0316816001600160a01b0316146116a75760405162a1148160e81b815260040160405180910390fd5b60008281526006602052604090208054338082146001600160a01b038816909114176116f4576116d78633610fa6565b6116f457604051632ce44b5f60e11b815260040160405180910390fd5b6001600160a01b03851661171b57604051633a954ecd60e21b815260040160405180910390fd5b801561172657600082555b6001600160a01b038681166000908152600560205260408082208054600019019055918716808252919020805460010190554260a01b17600160e11b17600085815260046020526040902055600160e11b83166117b157600184016000818152600460205260409020546117af5760005481146117af5760008181526004602052604090208490555b505b83856001600160a01b0316876001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45b505050505050565b600c81600b811061180b57600080fd5b6002020180546001909101546001600160a01b0382169250600160a01b90910461ffff169060401b83565b905090565b6002600954141561185e5760405162461bcd60e51b815260040161132290615a55565b600260095561186d3382613804565b506001600955565b6000828152600a602052604090206001015461189081613378565b61189a8383613a53565b505050565b60006118aa81613378565b60e25460ff16806118c2575060e254610100900460ff165b6118cb57600080fd5b602f5433906031906118dd9085615b37565b111561192b5760405162461bcd60e51b815260206004820152601760248201527f5445414d5f4d494e545f4c494d49545f524541434845440000000000000000006044820152606401611322565b611945818460405180602001604052806000815250613ad9565b82602f60008282546119579190615b37565b9091555050505050565b6026602052816000526040600020818154811061197d57600080fd5b90600052602060002001600091509150505481565b6001600160a01b0381163314611a025760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b6064820152608401611322565b611a0c8282613b3f565b5050565b6000611a1b81613378565b60e2805460ff640100000000808304821615810264ff000000001990931692909217928390556040517f6097f9dfed16094120986b76714f42f75cca68d783b5a8d0da2f78dacb90c50693611a799390049091161515815260200190565b60405180910390a150565b6000611a8f81613378565b60e25460009047908290600160301b900460ff16611b6e57602e548211611ab857819250611abe565b602e5492505b60405173670326f4470d4d2f5347377ff187717a81ab1318908490600081818185875af1925050503d8060008114611b12576040519150601f19603f3d011682016040523d82523d6000602084013e611b17565b606091505b50508091505080611b535760405162461bcd60e51b8152600401611322906020808252600490820152634e4f504560e01b604082015260600190565b60e2805466ff0000000000001916600160301b179055611c56565b60005b600b811015611c5457600c81600b8110611b9b57634e487b7160e01b600052603260045260246000fd5b60020201546001600160a01b03166103e8600c83600b8110611bcd57634e487b7160e01b600052603260045260246000fd5b6002020154611be790600160a01b900461ffff1686615b94565b611bf19190615b74565b604051600081818185875af1925050503d8060008114611c2d576040519150601f19603f3d011682016040523d82523d6000602084013e611c32565b606091505b50508092505081611c4257600080fd5b80611c4c81615c65565b915050611b71565b505b50505050565b6000611c6781613378565b50602e55565b6000611c7881613378565b5060e2805463ff00000019811663010000009182900460ff1615909102179055565b61189a838383604051806020016040528060008152506126d5565b6000611cc081613378565b60e25462010000900460ff1615611cd657600080fd5b838214611ce257600080fd5b60005b848110156117f357858582818110611d0d57634e487b7160e01b600052603260045260246000fd5b9050602002016020810190611d229190615772565b6034858584818110611d4457634e487b7160e01b600052603260045260246000fd5b905060200201356115b38110611d6a57634e487b7160e01b600052603260045260246000fd5b602091828204019190066101000a81548160ff021916908360ff1602179055508080611d9590615c65565b915050611ce5565b6000611da881613378565b611a0c7f9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a683611875565b6000611ddd81613378565b611c5660338484614f1a565b6000611120826133c5565b6060816000816001600160401b03811115611e1f57634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015611e7157816020015b604080516080810182526000808252602080830182905292820181905260608201528252600019909201910181611e3d5790505b50905060005b828114611ee057611ead868683818110611ea157634e487b7160e01b600052603260045260246000fd5b9050602002013561272e565b828281518110611ecd57634e487b7160e01b600052603260045260246000fd5b6020908102919091010152600101611e77565b50949350505050565b6000611120826137a3565b6001600160a01b038116600090815260266020908152604091829020805483518184028101840190945280845260609392830182828015611f5457602002820191906000526020600020905b815481526020019060010190808311611f40575b50505050509050919050565b611f6d6002610252615b94565b81565b60006001600160a01b038216611f99576040516323d3ad8160e21b815260040160405180910390fd5b506001600160a01b03166000908152600560205260409020546001600160401b031690565b60026009541415611fe15760405162461bcd60e51b815260040161132290615a55565b600260095560005b81811015612033576120213384848481811061201557634e487b7160e01b600052603260045260246000fd5b90506020020135613ba6565b8061202b81615c65565b915050611fe9565b5050600160095550565b612045613c6d565b61204f6000613cc7565b565b60008161205d81613382565b6120795760405162461bcd60e51b8152600401611322906159b2565b61208283613d19565b91505b50919050565b600061183660325490565b61209e614f9e565b816120a881613382565b6120c45760405162461bcd60e51b8152600401611322906159b2565b600061164a84613d93565b60006120da81613378565b611a0c82603255565b606060008060006120f385611f70565b90506000816001600160401b0381111561211d57634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015612146578160200160208202803683370190505b50905061217360408051608081018252600080825260208201819052918101829052606081019190915290565b60005b8386146122025761218681613def565b9150816040015115612197576121fa565b81516001600160a01b0316156121ac57815194505b876001600160a01b0316856001600160a01b031614156121fa57808387806001019850815181106121ed57634e487b7160e01b600052603260045260246000fd5b6020026020010181815250505b600101612176565b50909695505050505050565b60006116628383613e2b565b6001600160a01b038116600090815260266020908152604080832080548251818502810185019093528083528493849392919083018282801561227c57602002820191906000526020600020905b815481526020019060010190808311612268575b5050505050905060005b81518110156122dd576122bf8282815181106122b257634e487b7160e01b600052603260045260246000fd5b60200260200101516133c5565b6122c99084615b37565b9250806122d581615c65565b915050612286565b50909392505050565b6000918252600a602090815260408084206001600160a01b0393909316845291905290205460ff1690565b600061231c81613378565b600182600381111561233e57634e487b7160e01b600052602160045260246000fd5b141561236657602880546001600160a01b0385166001600160a01b0319909116179055505050565b600282600381111561238857634e487b7160e01b600052602160045260246000fd5b14156123b057602980546001600160a01b0385166001600160a01b0319909116179055505050565b60038260038111156123d257634e487b7160e01b600052602160045260246000fd5b14156104f757602a80546001600160a01b0385166001600160a01b0319909116179055505050565b60606003805461119890615c30565b606081831061242b57604051631960ccad60e11b815260040160405180910390fd5b60008061243760005490565b905080841115612445578093505b600061245087611f70565b90508486101561246f5785850381811015612469578091505b50612473565b5060005b6000816001600160401b0381111561249b57634e487b7160e01b600052604160045260246000fd5b6040519080825280602002602001820160405280156124c4578160200160208202803683370190505b509050816124d757935061166292505050565b60006124e28861272e565b9050600081604001516124f3575080515b885b8881141580156125055750848714155b1561258f5761251381613def565b925082604001511561252457612587565b82516001600160a01b03161561253957825191505b8a6001600160a01b0316826001600160a01b03161415612587578084888060010199508151811061257a57634e487b7160e01b600052603260045260246000fd5b6020026020010181815250505b6001016124f5565b505050928352509095945050505050565b60006125ab81613378565b50602c55565b6001600160a01b0382163314156125db5760405163b06307db60e01b815260040160405180910390fd5b3360008181526007602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b6033805461265490615c30565b80601f016020809104026020016040519081016040528092919081815260200182805461268090615c30565b80156126cd5780601f106126a2576101008083540402835291602001916126cd565b820191906000526020600020905b8154815290600101906020018083116126b057829003601f168201915b505050505081565b6126e0848484611669565b6001600160a01b0383163b15611c56576126fc84848484613e72565b611c56576040516368d2bf6b60e11b815260040160405180910390fd5b6000806000fd5b600061183660e25460ff1690565b60408051608080820183526000808352602080840182905283850182905260608085018390528551938401865282845290830182905293820181905292810183905290915060005483106127825792915050565b61278b83613def565b905080604001511561279d5792915050565b61208283613f66565b60006127b181613378565b50602d55565b600260095414156127da5760405162461bcd60e51b815260040161132290615a55565b600260095560005b818110156120335761281a3384848481811061280e57634e487b7160e01b600052603260045260246000fd5b90506020020135613804565b8061282481615c65565b9150506127e2565b606061283782613382565b61285457604051630a14c4b560e41b815260040160405180910390fd5b600061285e613f9b565b905080516000141561287f5760405180602001604052806000815250612082565b8061288984613faa565b60405160200161289a929190615840565b6040516020818303038152906040529392505050565b600260095414156128d35760405162461bcd60e51b815260040161132290615a55565b600260095561186d3382613ba6565b60e254339060ff1661292f5760405162461bcd60e51b81526020600482015260166024820152755075626c69632073616c65206e6f742061637469766560501b6044820152606401611322565b602d5461293c9087615b94565b3410156129805760405162461bcd60e51b8152602060048201526012602482015271496e73756666696369656e742066756e647360701b6044820152606401611322565b600a8611156129c45760405162461bcd60e51b815260206004820152601060248201526f4558434545445f414c4c4f57414e434560801b6044820152606401611322565b6129cd86613ff9565b15612a055760405162461bcd60e51b815260206004820152600860248201526714d3d31117d3d55560c21b6044820152606401611322565b6001600160a01b0381166000908152602460205260409020548514612a5c5760405162461bcd60e51b815260206004820152600d60248201526c494e56414c49445f4e4f4e434560981b6044820152606401611322565b612aab81868686868080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250506031546001600160a01b031691506136fa9050565b80612ac0575060e2546301000000900460ff16155b612afa5760405162461bcd60e51b815260206004820152600b60248201526a494e56414c49445f53494760a81b6044820152606401611322565b612b14818760405180602001604052806000815250613ad9565b6001600160a01b0381166000908152602460205260408120805491612b3883615c65565b9190505550505050505050565b6000828152600a6020526040902060010154612b6081613378565b61189a8383613b3f565b33600090815260266020908152604080832080548251818502810185019093528083529192909190830182828015612bc157602002820191906000526020600020905b815481526020019060010190808311612bad575b5050505050905060005b8151811015611a0c576000612bf98383815181106122b257634e487b7160e01b600052603260045260246000fd5b1115612c2f57612c2f828281518110612c2257634e487b7160e01b600052603260045260246000fd5b60200260200101516112ff565b80612c3981615c65565b915050612bcb565b6000612c4c81613378565b60e25460ff1615612c5c57600080fd5b60e2805460ff610100808304821615810261ff001990931692909217928390556040517fb5a6cf6d450acd3f8d515b1cb8e1198f105cd0bf77285a79bb78f7e10ee712a693611a799390049091161515815260200190565b6000612cbf81613378565b60e254610100900460ff1615612cd457600080fd5b60e2805460ff8082161560ff1990921682179092556040519116151581527fd95db27fb727a8efc81657db609938fd60d724f29d367d50680bc54a1c0e1ae290602001611a79565b60e2543390610100900460ff16612d755760405162461bcd60e51b815260206004820152601760248201527f507269766174652073616c65206e6f74206163746976650000000000000000006044820152606401611322565b602c54612d829087615b94565b341015612dc65760405162461bcd60e51b8152602060048201526012602482015271496e73756666696369656e742066756e647360701b6044820152606401611322565b6001600160a01b0381166000908152602360205260409020548590612deb9088615b37565b1115612e2e5760405162461bcd60e51b8152602060048201526012602482015271457863656564656420616c6c6f77616e636560701b6044820152606401611322565b612e7d81868686868080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250506031546001600160a01b031691506136fa9050565b612eb75760405162461bcd60e51b815260206004820152600b60248201526a494e56414c49445f53494760a81b6044820152606401611322565b612ec086613ff9565b15612ef85760405162461bcd60e51b815260206004820152600860248201526714d3d31117d3d55560c21b6044820152606401611322565b612f12818760405180602001604052806000815250613ad9565b6001600160a01b03811660009081526023602052604081208054889290612f3a908490615b37565b9091555050505050505050565b612f546002610252615b94565b612f6160316115b3615bb3565b611f6d9190615bb3565b6000611120826133a9565b6000856001600160a01b0316876001600160a01b031614612fa95760405162461bcd60e51b8152600401611322906159e1565b6028546001600160a01b0316331480612fcc57506029546001600160a01b031633145b80612fe15750602a546001600160a01b031633145b6130225760405162461bcd60e51b8152602060048201526012602482015271494e56414c49445f544f4b454e5f5459504560701b6044820152606401611322565b60008061302f8585613450565b91509150876001600160a01b031661304683611ee9565b6001600160a01b0316148061307457506000828152600860205260409020546001600160a01b038981169116145b6130af5760405162461bcd60e51b815260206004820152600c60248201526b1393d517d653d55497d3919560a21b6044820152606401611322565b805187146130f45760405162461bcd60e51b81526020600482015260126024820152711253959053125117d11150d3d1115117d25160721b6044820152606401611322565b856001146131395760405162461bcd60e51b815260206004820152601260248201527143414e5f4f4e4c595f45515549505f4f4e4560701b6044820152606401611322565b336001600160a01b031663976fb5436040518163ffffffff1660e01b815260040160206040518083038186803b15801561317257600080fd5b505afa158015613186573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131aa91906156c5565b60038111156131c957634e487b7160e01b600052602160045260246000fd5b816040015160038111156131ed57634e487b7160e01b600052602160045260246000fd5b1461322d5760405162461bcd60e51b815260206004820152601060248201526f494e56414c49445f4954454d5459504560801b6044820152606401611322565b6132378183614054565b5063f23a6e6160e01b98975050505050505050565b613254613c6d565b6001600160a01b0381166132b95760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401611322565b6132c281613cc7565b50565b60006132d081613378565b50602b80546001600160a01b0319166001600160a01b0392909216919091179055565b7f9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a661331d81613378565b6133418361332c600285615b94565b60405180602001604052806000815250613ad9565b81603060008282546119579190615b37565b60006001600160e01b03198216637965db0b60e01b14806111205750611120826141be565b6132c2813361420c565b6000805482108015611120575050600090815260046020526040902054600160e01b161590565b6000306133b583611ee9565b6001600160a01b03161492915050565b6000806133d183613d93565b90506000620151806133e285614270565b6133ec9042615bb3565b6133f69190615b74565b60325483519192509061340c9060ff1683615b94565b61164a9190615b94565b8061342081613382565b61343c5760405162461bcd60e51b8152600401611322906159b2565b506000908152602560205260409020429055565b60408051606081018252600080825260208201819052918101829052600061347b6020828688615b0f565b81019061348891906155e3565b90506134ab60408051606081018252600080825260208201819052909182015290565b6134b9604060208789615b0f565b8101906134c691906155e3565b81526134d6606060408789615b0f565b8101906134e39190615772565b60ff1660208201526134f88560608189615b0f565b81019061350591906156a9565b8160400190600381111561352957634e487b7160e01b600052602160045260246000fd5b9081600381111561354a57634e487b7160e01b600052602160045260246000fd5b90525090925090505b9250929050565b6135688183604001516142ac565b6135a45760405162461bcd60e51b815260206004820152600d60248201526c536c6f7420697320656d70747960981b6044820152606401611322565b60006135af826143bf565b90506001836040015160038111156135d757634e487b7160e01b600052602160045260246000fd5b1415613614578251602082015151146136025760405162461bcd60e51b815260040161132290615a2d565b61360a614586565b60208201526136d6565b60028360400151600381111561363a57634e487b7160e01b600052602160045260246000fd5b1415613677578251604082015151146136655760405162461bcd60e51b815260040161132290615a2d565b61366d614586565b60408201526136d6565b60038360400151600381111561369d57634e487b7160e01b600052602160045260246000fd5b14156104f7578251606082015151146136c85760405162461bcd60e51b815260040161132290615a2d565b6136d0614586565b60608201525b6020830151815182906136ea908390615bca565b60ff1690525061189a82826145c7565b6000613707848484613724565b80156116375750836137198787613e2b565b149695505050505050565b6000816001600160a01b03166137918461378b876040517f19457468657265756d205369676e6564204d6573736167653a0a3332000000006020820152603c8101829052600090605c01604051602081830303815290604052805190602001209050919050565b9061473e565b6001600160a01b031614949350505050565b6000816000548110156137eb57600081815260046020526040902054600160e01b81166137e9575b806116625750600019016000818152600460205260409020546137cb565b505b604051636f96cda160e11b815260040160405180910390fd5b61380d816133a9565b6138295760405162461bcd60e51b815260040161132290615a09565b61383281614762565b600061383d826133c5565b905080156138b857602b546001600160a01b03166340c10f19336040516001600160e01b031960e084901b1681526001600160a01b03909116600482015260248101849052604401600060405180830381600087803b15801561389f57600080fd5b505af11580156138b3573d6000803e3d6000fd5b505050505b6001600160a01b03831660009081526026602052604081205481906138df90600190615bb3565b90505b6001600160a01b038516600090815260266020526040902080548591908490811061391d57634e487b7160e01b600052603260045260246000fd5b90600052602060002001541461393f578161393781615c65565b9250506138e2565b6001600160a01b038516600090815260266020526040902080548290811061397757634e487b7160e01b600052603260045260246000fd5b906000526020600020015460266000876001600160a01b03166001600160a01b0316815260200190815260200160002083815481106139c657634e487b7160e01b600052603260045260246000fd5b60009182526020808320909101929092556001600160a01b0387168152602690915260409020805480613a0957634e487b7160e01b600052603160045260246000fd5b6000828152602080822083016000199081018390559092019092558582526025815260408083208390556008909152902080546001600160a01b0319169055611c54308686611669565b613a5d82826122e6565b611a0c576000828152600a602090815260408083206001600160a01b03851684529091529020805460ff19166001179055613a953390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b613ae3838361482d565b6001600160a01b0383163b1561189a576000548281035b613b0d6000868380600101945086613e72565b613b2a576040516368d2bf6b60e11b815260040160405180910390fd5b818110613afa578160005414611c5457600080fd5b613b4982826122e6565b15611a0c576000828152600a602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b613bb08282614924565b613bcc5760405162461bcd60e51b8152600401611322906159e1565b613bd5816133a9565b15613c135760405162461bcd60e51b815260206004820152600e60248201526d1053149150511657d4d51052d15160921b6044820152606401611322565b613c1c81613416565b600081815260086020908152604080832080546001600160a01b0319166001600160a01b03871690811790915583526026825282208054600181018255908352912001819055611a0c823083611c9a565b600b546001600160a01b0316331461204f5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401611322565b600b80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600081613d2581613382565b613d415760405162461bcd60e51b8152600401611322906159b2565b60006034846115b38110613d6557634e487b7160e01b600052603260045260246000fd5b602081049091015460ff601f9092166101000a900416905080613d8c576005925050612085565b9150612085565b613d9b614f9e565b81613da581613382565b613dc15760405162461bcd60e51b8152600401611322906159b2565b6000613dcc846143bf565b9050613dd784613d19565b8151613de39190615b4f565b60ff1681529392505050565b6040805160808101825260008082526020820181905291810182905260608101919091526000828152600460205260409020546111209061495e565b6040516bffffffffffffffffffffffff19606084901b1660208201526034810182905260009060540160405160208183030381529060405280519060200120905092915050565b604051630a85bd0160e11b81526000906001600160a01b0385169063150b7a0290613ea79033908990889088906004016158e4565b602060405180830381600087803b158015613ec157600080fd5b505af1925050508015613ef1575060408051601f3d908101601f19168201909252613eee9181019061568d565b60015b613f4c573d808015613f1f576040519150601f19603f3d011682016040523d82523d6000602084013e613f24565b606091505b508051613f44576040516368d2bf6b60e11b815260040160405180910390fd5b805181602001fd5b6001600160e01b031916630a85bd0160e11b14905061164a565b604080516080810182526000808252602082018190529181018290526060810191909152611120613f96836137a3565b61495e565b60606033805461119890615c30565b604080516080810191829052607f0190826030600a8206018353600a90045b8015613fe757600183039250600a81066030018353600a9004613fc9565b50819003601f19909101908152919050565b60006140086002610252615b94565b61401560316115b3615bb3565b61401f9190615bb3565b82603054602f5461402f60005490565b6140399190615bb3565b6140439190615bb3565b61404d9190615b37565b1192915050565b6140628183604001516142ac565b156140a35760405162461bcd60e51b8152602060048201526011602482015270536c6f74206973206e6f7420656d70747960781b6044820152606401611322565b60006140ae826143bf565b90506001836040015160038111156140d657634e487b7160e01b600052602160045260246000fd5b14156140e85760208101839052614154565b60028360400151600381111561410e57634e487b7160e01b600052602160045260246000fd5b14156141205760408101839052614154565b60038360400151600381111561414657634e487b7160e01b600052602160045260246000fd5b14156104f757606081018390525b602083015181518290614168908390615b4f565b60ff1690525061417882826145c7565b8260000151827f770f9b8c440277434bb6e78e7dab021f412675ae32d83b7b172487ab66bc04bd85604001516040516141b19190615991565b60405180910390a3505050565b60006301ffc9a760e01b6001600160e01b0319831614806141ef57506380ac58cd60e01b6001600160e01b03198316145b806111205750506001600160e01b031916635b5e139f60e01b1490565b61421682826122e6565b611a0c5761422e816001600160a01b031660146149a5565b6142398360206149a5565b60405160200161424a92919061586f565b60408051601f198184030181529082905262461bcd60e51b82526113229160040161599f565b60008161427c81613382565b6142985760405162461bcd60e51b8152600401611322906159b2565b505060009081526025602052604090205490565b6000826142b881613382565b6142d45760405162461bcd60e51b8152600401611322906159b2565b60006142df856143bf565b9050600184600381111561430357634e487b7160e01b600052602160045260246000fd5b141561433c576001816020015160400151600381111561433357634e487b7160e01b600052602160045260246000fd5b149250506143b8565b600284600381111561435e57634e487b7160e01b600052602160045260246000fd5b141561438e576002816040015160400151600381111561433357634e487b7160e01b600052602160045260246000fd5b6003816060015160400151600381111561433357634e487b7160e01b600052602160045260246000fd5b5092915050565b6143c7614f9e565b816143d181613382565b6143ed5760405162461bcd60e51b8152600401611322906159b2565b60008381526022602090815260408083208151608081018352815460ff9081168252835160608101855260018401805482526002850154808416838901529396949594870194919390929184019161010090910416600381111561446157634e487b7160e01b600052602160045260246000fd5b600381111561448057634e487b7160e01b600052602160045260246000fd5b905250815260408051606081018252600384810180548352600486015460ff808216602086810191909152909601959394919391850192610100909104909116908111156144de57634e487b7160e01b600052602160045260246000fd5b60038111156144fd57634e487b7160e01b600052602160045260246000fd5b9052508152604080516060810182526005840180548252600685015460ff80821660208581019190915290950194929391929184019161010090910416600381111561455957634e487b7160e01b600052602160045260246000fd5b600381111561457857634e487b7160e01b600052602160045260246000fd5b905250905250949350505050565b6145a760408051606081018252600080825260208201819052909182015290565b604080516060810182526000808252602082018190529091820152919050565b816145d181613382565b6145ed5760405162461bcd60e51b8152600401611322906159b2565b6000838152602260209081526040918290208451815460ff91821660ff19918216178355838701518051600185019081559481015160028501805491909416928116831784559581015188969495919491939092909161ffff19161761010083600381111561466c57634e487b7160e01b600052602160045260246000fd5b0217905550505060408281015180516003808501918255602083015160048601805460ff90921660ff19831681178255958501519495939493909261ffff1990921617906101009084908111156146d357634e487b7160e01b600052602160045260246000fd5b021790555050506060820151805160058301908155602082015160068401805460ff90921660ff1983168117825560408501519261ffff19161761010083600381111561473057634e487b7160e01b600052602160045260246000fd5b021790555050505050505050565b600080600061474d8585614b86565b9150915061475a81614bf3565b509392505050565b33600061476e83611ee9565b90506001600160a01b03811630146147985760405162461bcd60e51b815260040161132290615a09565b6000838152600860205260409020546001600160a01b038381169116146147d15760405162461bcd60e51b8152600401611322906159e1565b60008381526006602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518693918516917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591a4505050565b6000548161484e5760405163b562e8dd60e01b815260040160405180910390fd5b6001600160a01b03831660008181526005602090815260408083208054680100000000000000018802019055848352600490915281206001851460e11b4260a01b178317905582840190839083907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8180a4600183015b8181146148fd57808360007fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef600080a46001016148c5565b508161491b57604051622e076360e81b815260040160405180910390fd5b60005550505050565b60008061493083613f66565b9050836001600160a01b031681600001516001600160a01b031614801561164a575060400151159392505050565b604080516080810182526001600160a01b038316815260a083901c6001600160401b03166020820152600160e01b831615159181019190915260e89190911c606082015290565b606060006149b4836002615b94565b6149bf906002615b37565b6001600160401b038111156149e457634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015614a0e576020820181803683370190505b509050600360fc1b81600081518110614a3757634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110614a7457634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a9053506000614a98846002615b94565b614aa3906001615b37565b90505b6001811115614b37576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110614ae557634e487b7160e01b600052603260045260246000fd5b1a60f81b828281518110614b0957634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a90535060049490941c93614b3081615c19565b9050614aa6565b5083156116625760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401611322565b600080825160411415614bbd5760208301516040840151606085015160001a614bb187828585614df4565b94509450505050613553565b825160401415614be75760208301516040840151614bdc868383614ee1565b935093505050613553565b50600090506002613553565b6000816004811115614c1557634e487b7160e01b600052602160045260246000fd5b1415614c1e5750565b6001816004811115614c4057634e487b7160e01b600052602160045260246000fd5b1415614c8e5760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606401611322565b6002816004811115614cb057634e487b7160e01b600052602160045260246000fd5b1415614cfe5760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606401611322565b6003816004811115614d2057634e487b7160e01b600052602160045260246000fd5b1415614d795760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b6064820152608401611322565b6004816004811115614d9b57634e487b7160e01b600052602160045260246000fd5b14156132c25760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202776272076616c604482015261756560f01b6064820152608401611322565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0831115614e2b5750600090506003614ed8565b8460ff16601b14158015614e4357508460ff16601c14155b15614e545750600090506004614ed8565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015614ea8573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116614ed157600060019250925050614ed8565b9150600090505b94509492505050565b6000806001600160ff1b03831681614efe60ff86901c601b615b37565b9050614f0c87828885614df4565b935093505050935093915050565b828054614f2690615c30565b90600052602060002090601f016020900481019282614f485760008555614f8e565b82601f10614f615782800160ff19823516178555614f8e565b82800160010185558215614f8e579182015b82811115614f8e578235825591602001919060010190614f73565b50614f9a929150615025565b5090565b6040518060800160405280600060ff168152602001614fd460408051606081018252600080825260208201819052909182015290565b8152602001614ffa60408051606081018252600080825260208201819052909182015290565b815260200161502060408051606081018252600080825260208201819052909182015290565b905290565b5b80821115614f9a5760008155600101615026565b80356001600160a01b038116811461505157600080fd5b919050565b60008083601f840112615067578182fd5b5081356001600160401b0381111561507d578182fd5b6020830191508360208260051b850101111561355357600080fd5b600082601f8301126150a8578081fd5b813560206001600160401b038211156150c3576150c3615c96565b8160051b6150d2828201615adf565b8381528281019086840183880185018910156150ec578687fd5b8693505b8584101561510e5780358352600193909301929184019184016150f0565b50979650505050505050565b60008083601f84011261512b578182fd5b5081356001600160401b03811115615141578182fd5b60208301915083602082850101111561355357600080fd5b600082601f830112615169578081fd5b81356001600160401b0381111561518257615182615c96565b615195601f8201601f1916602001615adf565b8181528460208386010111156151a9578283fd5b816020850160208301379081016020019190915292915050565b6000602082840312156151d4578081fd5b6116628261503a565b600080604083850312156151ef578081fd5b6151f88361503a565b91506152066020840161503a565b90509250929050565b60008060008060008060a08789031215615227578182fd5b6152308761503a565b955061523e6020880161503a565b945060408701356001600160401b0380821115615259578384fd5b6152658a838b01615098565b9550606089013591508082111561527a578384fd5b6152868a838b01615098565b9450608089013591508082111561529b578384fd5b506152a889828a0161511a565b979a9699509497509295939492505050565b6000806000606084860312156152ce578283fd5b6152d78461503a565b92506152e56020850161503a565b9150604084013590509250925092565b6000806000806080858703121561530a578384fd5b6153138561503a565b93506153216020860161503a565b92506040850135915060608501356001600160401b03811115615342578182fd5b61534e87828801615159565b91505092959194509250565b60008060008060008060a08789031215615372578182fd5b61537b8761503a565b95506153896020880161503a565b9450604087013593506060870135925060808701356001600160401b038111156153b1578283fd5b6152a889828a0161511a565b600080604083850312156153cf578182fd5b6153d88361503a565b9150602083013580151581146153ec578182fd5b809150509250929050565b60008060006040848603121561540b578081fd5b6154148461503a565b925060208401356001600160401b0381111561542e578182fd5b61543a8682870161511a565b9497909650939450505050565b60008060408385031215615459578182fd5b6154628361503a565b915060208301356153ec81615cc2565b60008060408385031215615484578182fd5b61548d8361503a565b946020939093013593505050565b600080600080600060a086880312156154b2578283fd5b6154bb8661503a565b9450602086013593506040860135925060608601356001600160401b038111156154e3578182fd5b6154ef88828901615159565b9250506154fe6080870161503a565b90509295509295909350565b60008060006060848603121561551e578081fd5b6155278461503a565b95602085013595506040909401359392505050565b6000806020838503121561554e578182fd5b82356001600160401b03811115615563578283fd5b61556f85828601615056565b90969095509350505050565b60008060008060408587031215615590578182fd5b84356001600160401b03808211156155a6578384fd5b6155b288838901615056565b909650945060208701359150808211156155ca578384fd5b506155d787828801615056565b95989497509550505050565b6000602082840312156155f4578081fd5b5035919050565b6000806040838503121561560d578182fd5b823591506152066020840161503a565b600080600060608486031215615631578081fd5b8335925060208401356001600160401b0381111561564d578182fd5b61565986828701615159565b9250506156686040850161503a565b90509250925092565b600060208284031215615682578081fd5b813561166281615cac565b60006020828403121561569e578081fd5b815161166281615cac565b6000602082840312156156ba578081fd5b813561166281615cc2565b6000602082840312156156d6578081fd5b815161166281615cc2565b600080602083850312156156f3578182fd5b82356001600160401b03811115615708578283fd5b61556f8582860161511a565b60008060008060006080868803121561572b578283fd5b85359450602086013593506040860135925060608601356001600160401b03811115615755578182fd5b6157618882890161511a565b969995985093965092949392505050565b600060208284031215615783578081fd5b813560ff81168114611662578182fd5b600081518084526157ab816020860160208601615bed565b601f01601f19169290920160200192915050565b600481106157dd57634e487b7160e01b600052602160045260246000fd5b9052565b8051825260ff6020820151166020830152604081015161189a60408401826157bf565b80516001600160a01b031682526020808201516001600160401b03169083015260408082015115159083015260609081015162ffffff16910152565b60008351615852818460208801615bed565b835190830190615866818360208801615bed565b01949350505050565b7f416363657373436f6e74726f6c3a206163636f756e74200000000000000000008152600083516158a7816017850160208801615bed565b7001034b99036b4b9b9b4b733903937b6329607d1b60179184019182015283516158d8816028840160208801615bed565b01602801949350505050565b6001600160a01b038581168252841660208201526040810183905260806060820181905260009061163790830184615793565b6020808252825182820181905260009190848201906040850190845b8181101561220257615946838551615804565b9284019260809290920191600101615933565b6020808252825182820181905260009190848201906040850190845b8181101561220257835183529284019291840191600101615975565b6020810161112082846157bf565b6020815260006116626020830184615793565b6020808252601590820152742a37b5b2b7103237b2b9903737ba1032bc34b9ba1760591b604082015260600190565b6020808252600e908201526d1393d517d055551213d49254d15160921b604082015260600190565b6020808252600a90820152691393d517d4d51052d15160b21b604082015260600190565b6020808252600e908201526d496e636f7272656374206974656d60901b604082015260600190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b815160ff168152602080830151610140830191615aab908401826157e1565b506040830151615abe60808401826157e1565b5060608301516143b860e08401826157e1565b608081016111208284615804565b604051601f8201601f191681016001600160401b0381118282101715615b0757615b07615c96565b604052919050565b60008085851115615b1e578182fd5b83861115615b2a578182fd5b5050820193919092039150565b60008219821115615b4a57615b4a615c80565b500190565b600060ff821660ff84168060ff03821115615b6c57615b6c615c80565b019392505050565b600082615b8f57634e487b7160e01b81526012600452602481fd5b500490565b6000816000190483118215151615615bae57615bae615c80565b500290565b600082821015615bc557615bc5615c80565b500390565b600060ff821660ff841680821015615be457615be4615c80565b90039392505050565b60005b83811015615c08578181015183820152602001615bf0565b83811115611c565750506000910152565b600081615c2857615c28615c80565b506000190190565b600181811c90821680615c4457607f821691505b6020821081141561208557634e487b7160e01b600052602260045260246000fd5b6000600019821415615c7957615c79615c80565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160e01b0319811681146132c257600080fd5b600481106132c257600080fdfea264697066735822122087ca08849f30dcfbe79d96b5c0b2997ef105966ab3be014d3f393e74742aead064736f6c63430008040033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000c80f2f0598db841f48afa998fb70122e37361f4a0000000000000000000000000f88130d3a638bace612ca21b2916a62ad9a0b3d000000000000000000000000fa912057f195a35214da31c2b623b6b2eb45baaf00000000000000000000000088d6f1be76b5a86cff11f76051f191f00dda116a
-----Decoded View---------------
Arg [0] : signer (address): 0xC80f2f0598db841f48AFA998fb70122e37361F4A
Arg [1] : magicFolkMainhand (address): 0x0f88130d3A638bACE612Ca21b2916a62ad9a0B3d
Arg [2] : magicFolkOffhand (address): 0xFA912057F195a35214Da31c2b623B6b2EB45Baaf
Arg [3] : magicFolkPet (address): 0x88d6F1BE76b5A86cFf11f76051F191f00DDa116A
-----Encoded View---------------
4 Constructor Arguments found :
Arg [0] : 000000000000000000000000c80f2f0598db841f48afa998fb70122e37361f4a
Arg [1] : 0000000000000000000000000f88130d3a638bace612ca21b2916a62ad9a0b3d
Arg [2] : 000000000000000000000000fa912057f195a35214da31c2b623b6b2eb45baaf
Arg [3] : 00000000000000000000000088d6f1be76b5a86cff11f76051f191f00dda116a
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
[ Download: CSV Export ]
A token is a representation of an on-chain or off-chain asset. The token page shows information such as price, total supply, holders, transfers and social links. Learn more about this page in our Knowledge Base.