Overview
ETH Balance
0 ETH
Eth Value
$0.00More Info
Private Name Tags
ContractCreator
Latest 1 from a total of 1 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
0x60806040 | 13714400 | 1011 days ago | IN | 0 ETH | 0.38856685 |
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
Contract Name:
MyPFPlandv3
Compiler Version
v0.6.5+commit.f956cc89
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.6.5; pragma experimental ABIEncoderV2; import "@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/CountersUpgradeable.sol"; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; contract MyPFPlandv3 is ERC721Upgradeable { using CountersUpgradeable for CountersUpgradeable.Counter; CountersUpgradeable.Counter internal toyTokenIDs; CountersUpgradeable.Counter internal paintingTokenIDs; CountersUpgradeable.Counter internal statuetteTokenIDs; uint256 internal toyTokenIDBase; uint256 internal paintingTokenIDBase; uint256 internal statuetteTokenIDBase; address public _owner; bool public isOpenPayment; bool public isPausedClaimingToy; bool public isPausedClaimingPainting; bool public isPausedClaimingStatteute; mapping(address => uint256) internal addressToClaimedToy; mapping(address => uint256) internal addressToClaimedPainting; mapping(address => uint256) internal addressToClaimedStateutte; mapping(uint256 => bool) public oldTokenIDUsed; mapping(address => uint256) internal addressToMigratedCameo; mapping(address => uint256) internal addressToMigratedHonorary; mapping(address => uint256) internal addressToRoyalty; ERC721 blootNFT; struct Point { uint256 x; uint256 y; } struct Rectangle { Point leftBottom; Point rightTop; } struct LandMetadata { uint256 collectionID; uint256 tokenID; } struct LandDerivateMetadata { address collectionAddress; uint256 tokenID; } bool public isPausedClaimingLand; bool public isPausedClaimingRoyal; bool public isPausedClaimingDerivative; string public _contractURI; bool public allowMetadataForAllReserved; uint256 constant landWidth = 100; uint256 constant landHeight = 100; uint256 totalCollection; uint256 constant landTokenBase = 10000; address constant blootAddress = 0x72541Ad75E05BC77C7A92304225937a8F6653372; address constant metaKeyAddress = 0x10DaA9f4c0F985430fdE4959adB2c791ef2CCF83; mapping(address => mapping(uint256 => uint256)) claimedLandOf; mapping(address => mapping(uint256 => bool)) usedRoyalToken; mapping(uint256 => LandMetadata) public landRoyalMetadataOf; mapping(uint256 => LandDerivateMetadata[]) public landDerivativeMetadataOf; mapping(uint256 => uint256) public landDerivativeBalance; mapping(uint256 => address) public collectionAddressByIndex; mapping(address => uint256[]) public collectionIndicesByAddress; mapping(uint256 => Rectangle) public collectionRectByIndex; mapping(address => uint256) mekakeyWallets; modifier onlyOwner() { require(_owner == msg.sender, "Ownable: caller is not the owner" ); _; } function initialize() initializer external { __ERC721_init("MyPFPland", "MyPFPland"); _owner = msg.sender; toyTokenIDBase = 0; paintingTokenIDBase = 300; statuetteTokenIDBase = 400; blootNFT = ERC721(0x72541Ad75E05BC77C7A92304225937a8F6653372); } function claim(uint256 _category, uint256 _count) external payable { require(_category >= 1, "out of range"); require(_category <= 3, "out of range"); if (_category == 1) require(isPausedClaimingToy == false, "toy claiming is paused"); if (_category == 2) require(isPausedClaimingPainting == false, "painting claiming is paused"); if (_category == 3) require(isPausedClaimingStatteute == false, "statteute claiming is paused"); uint256 totalDerivative = getTotalDerivative(msg.sender, _category); if (_category == 1) totalDerivative += addressToMigratedCameo[msg.sender]; else if (_category == 2) totalDerivative += addressToMigratedHonorary[msg.sender]; uint256 tokenID = 0; if (_category == 1) require(totalDerivative >= addressToClaimedToy[msg.sender] + _count, "already claimed all toys"); else if (_category == 2) require(totalDerivative >= addressToClaimedPainting[msg.sender] + _count, "already claimed all paintings"); else if (_category == 3) require(totalDerivative >= _count, "already claimed all statteutes"); for (uint8 i = 0; i < _count; i++) { if (_category == 1) { toyTokenIDs.increment(); tokenID = toyTokenIDs.current() + toyTokenIDBase; } else if (_category == 2) { paintingTokenIDs.increment(); tokenID = paintingTokenIDs.current() + paintingTokenIDBase; } else if (_category == 3) { statuetteTokenIDs.increment(); tokenID = statuetteTokenIDs.current() + statuetteTokenIDBase; } _safeMint(msg.sender, tokenID); _setTokenURI(tokenID, uint2str(tokenID)); } if (_category == 1) addressToClaimedToy[msg.sender] += _count; else if (_category == 2) addressToClaimedPainting[msg.sender] += _count; // set oldTokenIDUsed true for those IDs already used if (totalDerivative > 0 && _category == 3) { for (uint8 i = 0; i < blootNFT.balanceOf(msg.sender); i++) { uint256 tokenId = blootNFT.tokenOfOwnerByIndex(msg.sender, i); if (tokenId <= 1484) { oldTokenIDUsed[tokenId] = true; } } } } function getDerivativesToClaim(address _claimer, uint256 _category) external view returns(uint256) { uint256 remain = 0; if (_category < 1 || _category > 3) return remain; uint256 totalDerivative = getTotalDerivative(_claimer, _category); if (_category == 1) { totalDerivative += addressToMigratedCameo[_claimer]; remain = totalDerivative - addressToClaimedToy[_claimer]; } else if (_category == 2) { totalDerivative += addressToMigratedHonorary[_claimer]; remain = totalDerivative - addressToClaimedPainting[_claimer]; } else if (_category == 3) { remain = totalDerivative; } return remain; } function getTotalDerivative(address _claimer, uint256 _category) internal view returns(uint256) { uint256 result = 0; if (blootNFT.balanceOf(_claimer) == 0) return result; uint256 tokenIdMin; uint256 tokenIdMax; if (_category == 1) { tokenIdMin = 4790; tokenIdMax = 4962; } else if (_category == 2) { tokenIdMin = 4963; tokenIdMax = 5000; } else if (_category == 3) { tokenIdMin = 1; tokenIdMax = 1484; } for (uint256 i = 0; i < blootNFT.balanceOf(_claimer); i++) { uint256 tokenId = blootNFT.tokenOfOwnerByIndex(_claimer, i); if (tokenId >= tokenIdMin && tokenId <= tokenIdMax) { if (_category == 3) { if (!oldTokenIDUsed[tokenId]) result++; } else result++; } } return result; } function setPauseClaimingToy(bool _pauseClaimingToy) external onlyOwner { isPausedClaimingToy = _pauseClaimingToy; } function setPauseClaimingPainting(bool _pauseClaimingPainting) external onlyOwner { isPausedClaimingPainting = _pauseClaimingPainting; } function setPauseClaimingStatteute(bool _pauseClaimingStatteute) external onlyOwner { isPausedClaimingStatteute = _pauseClaimingStatteute; } function setBatchCameoWhitelist(address[] calldata _whitelist, uint256 _count) external onlyOwner { for (uint256 i = 0; i < _count; i++) { addressToMigratedCameo[_whitelist[i]] += 1; } } function setBatchHonoraryWhitelist(address[] calldata _whitelist, uint256 _count) external onlyOwner { for (uint256 i = 0; i < _count; i++) { addressToMigratedHonorary[_whitelist[i]] += 1; } } function setBatchCameoBlacklist(address[] calldata _blacklist, uint256 _count) external onlyOwner { for (uint256 i = 0; i < _count; i++) { addressToMigratedCameo[_blacklist[i]] = 0; } } function setBatchHonoraryBlacklist(address[] calldata _blacklist, uint256 _count) external onlyOwner { for (uint256 i = 0; i < _count; i++) { addressToMigratedHonorary[_blacklist[i]] = 0; } } function setBatchMekakeyWhitelist(address[] calldata _whitelist, uint256 _count) external onlyOwner { for (uint256 i = 0; i < _count; i++) { mekakeyWallets[_whitelist[i]] += 1; } } function setBatchMekakeyBlacklist(address[] calldata _blacklist, uint256 _count) external onlyOwner { for (uint256 i = 0; i < _count; i++) { mekakeyWallets[_blacklist[i]] = 0; } } function setBaseURI(string calldata _baseURI) external onlyOwner { super._setBaseURI(_baseURI); } function withdraw() external onlyOwner { (bool success, ) = _owner.call{value: address(this).balance}(""); require(success, "Failed to send"); } function transferOwnership(address newOwner) external onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _owner = newOwner; } function setPauseClaimingLand(bool _pauseClaimingLand) external onlyOwner { isPausedClaimingLand = _pauseClaimingLand; } function setPauseClaimingRoyal(bool _isPausedClaimingRoyal) external onlyOwner { isPausedClaimingRoyal = _isPausedClaimingRoyal; } function setPauseClaimingDerivative(bool _isPausedClaimingDerivative) external onlyOwner { isPausedClaimingDerivative = _isPausedClaimingDerivative; } function claimLand(uint256 x, uint256 y, uint256 collectionID) external payable { require(isPausedClaimingLand == false, "land claiming is paused"); require(x > collectionRectByIndex[collectionID].leftBottom.x && y > collectionRectByIndex[collectionID].leftBottom.y && x <= collectionRectByIndex[collectionID].rightTop.x && y <= collectionRectByIndex[collectionID].rightTop.y, "not contained"); address collectionAddress = collectionAddressByIndex[collectionID]; uint256 claimable; if (collectionID >= 4 && collectionID <= 6) { claimable = mekakeyWallets[msg.sender]; } else if (collectionAddress == blootAddress) { if (collectionID >= 0 && collectionID <= 3) { // honorary collection ids claimable = addressToMigratedHonorary[msg.sender]; } else { ERC721 collection = ERC721(collectionAddress); claimable = collection.balanceOf(msg.sender); claimable -= addressToMigratedHonorary[msg.sender]; } } else { require(msg.value == 30000000000000000, "invalid amount"); //0.03 ETH ERC721 collection = ERC721(collectionAddress); claimable = collection.balanceOf(msg.sender); } require(claimable > 0, "Don't own any NFT in this collection"); require(claimedLandOf[msg.sender][collectionID] < claimable, "Already claimed all lands"); uint256 assetID = _encodeTokenId(x, y); _safeMint(msg.sender, landTokenBase + assetID); _setTokenURI(landTokenBase + assetID, uint2str(landTokenBase + assetID)); if (collectionID == 0 || collectionID == 1 || collectionID == 2 || collectionID == 3) { // handle honorary exception for (uint256 i = 0; i < 4; i++) { claimedLandOf[msg.sender][i] ++; } } else { uint256[] memory collectionIndices = collectionIndicesByAddress[collectionAddress]; for (uint256 i = 0; i < collectionIndices.length; i++) { claimedLandOf[msg.sender][collectionIndices[i]] ++; } } } function landOwnerOf(uint256 tokenId) external view returns (address) { ERC721 collection = ERC721(address(this)); try collection.ownerOf(tokenId) returns(address owner) { return owner; } catch Error(string memory /*reason*/) { return address(0x0); } } function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual override { if (tokenId > landTokenBase) { // remove its royal and derivative tokens LandMetadata memory royalMetadata; royalMetadata.collectionID = 0; royalMetadata.tokenID = 0; // free original usedRoyalToken uint256 originalCollectionID = landRoyalMetadataOf[tokenId].collectionID; usedRoyalToken[collectionAddressByIndex[originalCollectionID]][landRoyalMetadataOf[tokenId].tokenID] = false; // free royal token, derivative token landRoyalMetadataOf[tokenId] = royalMetadata; landDerivativeBalance[tokenId] = 0; delete landDerivativeMetadataOf[tokenId]; } super._beforeTokenTransfer(from, to, tokenId); } function updateLandRoyalMetaData(uint256 x, uint256 y, uint256 collectionIDOfRoyalMetadata, uint256 tokenID) external { require(isPausedClaimingRoyal == false, "royal claiming is paused"); uint256 assetID = _encodeTokenId(x, y); require(super.ownerOf(landTokenBase + assetID) == msg.sender, "You are not the owner of this land"); if (!allowMetadataForAllReserved && addressToMigratedHonorary[msg.sender] == 0 && mekakeyWallets[msg.sender] == 0) { require(x > collectionRectByIndex[collectionIDOfRoyalMetadata].leftBottom.x && y > collectionRectByIndex[collectionIDOfRoyalMetadata].leftBottom.y && x <= collectionRectByIndex[collectionIDOfRoyalMetadata].rightTop.x && y <= collectionRectByIndex[collectionIDOfRoyalMetadata].rightTop.y, "not contained"); } address collectionAddress = collectionAddressByIndex[collectionIDOfRoyalMetadata]; require(collectionIDOfRoyalMetadata >= 7, "Invalid collection id, honorary or metakey"); ERC721 collection = ERC721(collectionAddress); require(collection.ownerOf(tokenID) == msg.sender, "You are not the owner of this tokenID"); require(usedRoyalToken[collectionAddress][tokenID] == false, "This royal NFT is already used"); // free original usedRoyalToken and set the new royalToken used as true uint256 originalCollectionID = landRoyalMetadataOf[landTokenBase + assetID].collectionID; usedRoyalToken[collectionAddressByIndex[originalCollectionID]][landRoyalMetadataOf[landTokenBase + assetID].tokenID] = false; usedRoyalToken[collectionAddress][tokenID] = true; //update royal metadata LandMetadata memory royalMetadata; royalMetadata.collectionID = collectionIDOfRoyalMetadata; royalMetadata.tokenID = tokenID; landRoyalMetadataOf[landTokenBase + assetID] = royalMetadata; // free derivative token landDerivativeBalance[landTokenBase + assetID] = 0; delete landDerivativeMetadataOf[landTokenBase + assetID]; } function updateLandDerivativeMetaData(uint256 x, uint256 y, address collectionAddrsOfDerMetadata, uint256 tokenID) external { require(isPausedClaimingDerivative == false, "derivative claiming is paused"); uint256 assetID = _encodeTokenId(x, y); require(super.ownerOf(landTokenBase + assetID) == msg.sender, "You are not the owner of this land"); require((landRoyalMetadataOf[landTokenBase + assetID].collectionID != 0 || landRoyalMetadataOf[landTokenBase + assetID].tokenID != 0), "Need to set royal NFT first"); ERC721 collection = ERC721(collectionAddrsOfDerMetadata); require(collection.ownerOf(tokenID) == msg.sender, "You are not the owner of this tokenID"); LandDerivateMetadata memory derivativeMetadata; derivativeMetadata.collectionAddress = collectionAddrsOfDerMetadata; derivativeMetadata.tokenID = tokenID; landDerivativeMetadataOf[landTokenBase + assetID].push(derivativeMetadata); landDerivativeBalance[landTokenBase + assetID] ++; } function setAllowMetadataForAllReserved(bool _allowMetadataForAllReserved) external onlyOwner { allowMetadataForAllReserved = _allowMetadataForAllReserved; } function getLandMetaData(uint256 collectionID, uint256 tokenID) external view returns(string memory) { address collectionAddress = collectionAddressByIndex[collectionID]; if (collectionID < 7) return ""; ERC721 collection = ERC721(collectionAddress); try collection.tokenURI(tokenID) returns(string memory tokenURI) { return tokenURI; } catch Error(string memory /*reason*/) { return ""; } } function collectionIDAt(uint256 x, uint256 y) external view returns (uint256) { uint256 collectionID; Rectangle memory area; Point memory pt; pt.x = x; pt.y = y; for (uint256 i = 0; i < totalCollection; i++) { area = collectionRectByIndex[i]; if (isInsideCollectionRect(pt, area)) { collectionID = i; return collectionID; } } return 100000; } function totalRoyalBalanceOf(address owner, uint256 collectionID) external view returns (uint256) { if (allowMetadataForAllReserved || (collectionID < 7 && (addressToMigratedHonorary[owner] > 0 || mekakeyWallets[owner] > 0))) { uint256 totalBalance = 0; address lastAddress; for (uint256 i = 0; i < totalCollection; i++) { address collectionAddress = collectionAddressByIndex[i]; if (collectionAddress == lastAddress) continue; lastAddress = collectionAddress; if (i < 7) // honorary and metakey continue; ERC721 collection = ERC721(collectionAddress); totalBalance += collection.balanceOf(owner); } return totalBalance; } else { address collectionAddress = collectionAddressByIndex[collectionID]; ERC721 collection = ERC721(collectionAddress); return collection.balanceOf(owner); } } function royalTokenOfOwnerByIndex(address owner, uint256 index, uint256 collectionID) external view returns (uint256, uint256) { uint256 tokenID; if (allowMetadataForAllReserved || (collectionID < 7 && (addressToMigratedHonorary[owner] > 0 || mekakeyWallets[owner] > 0))) { uint256 totalBalance = 0; address lastAddress; for (uint256 i = 0; i < totalCollection; i++) { address collectionAddress = collectionAddressByIndex[i]; if (collectionAddress == lastAddress) continue; lastAddress = collectionAddress; if (i < 7) continue; ERC721 collection = ERC721(collectionAddress); totalBalance += collection.balanceOf(owner); if (totalBalance - 1 < index) continue; uint256 tokenIndex = index - (totalBalance - collection.balanceOf(owner)); tokenID = collection.tokenOfOwnerByIndex(owner, tokenIndex); return (i, tokenID); } } else { address collectionAddress = collectionAddressByIndex[collectionID]; ERC721 collection = ERC721(collectionAddress); tokenID = collection.tokenOfOwnerByIndex(owner, index); return (collectionID, tokenID); } } function isInsideCollectionRect(Point memory point, Rectangle memory area) public pure returns(bool) { if (point.x > area.leftBottom.x && point.y > area.leftBottom.y && point.x <= area.rightTop.x && point.y <= area.rightTop.y) return true; else return false; } function setBatchCollectionRect(uint256[] calldata leftBottomX, uint256[] calldata leftBottomY, uint256[] calldata rightTopX, uint256[] calldata rightTopY, address[] calldata collectionAddress, uint256 count) external onlyOwner { Rectangle memory area; for (uint256 i = 0; i < count; i++) { area.leftBottom.x = leftBottomX[i]; area.leftBottom.y = leftBottomY[i]; area.rightTop.x = rightTopX[i]; area.rightTop.y = rightTopY[i]; collectionRectByIndex[totalCollection] = area; collectionAddressByIndex[totalCollection] = collectionAddress[i]; if (totalCollection != 0 && totalCollection != 1 && totalCollection != 2 && totalCollection != 3) collectionIndicesByAddress[collectionAddress[i]].push(totalCollection); totalCollection ++; } } function resetBatchCollectionRect(uint256[] calldata indices, address[] calldata collectionAddress, uint256 count) external onlyOwner { for (uint256 i = 0; i < count; i++) { delete collectionIndicesByAddress[collectionAddressByIndex[indices[i]]]; collectionAddressByIndex[indices[i]] = collectionAddress[i]; collectionIndicesByAddress[collectionAddress[i]].push(indices[i]); } } function _encodeTokenId(uint256 x, uint256 y) public pure returns (uint256) { return (x - 1) * landHeight + y; } function _decodeTokenId(uint256 value) external pure returns (uint256 x, uint256 y) { x = value / landHeight + 1; if (value % landHeight == 0) x = x - 1; y = value - (x - 1) * landHeight; } // for opensea collection function setContractURI(string calldata _contractURI_) external onlyOwner() { _contractURI = _contractURI_; } // for opensea collection function contractURI() external view returns (string memory) { return _contractURI; } function uint2str(uint _i) internal pure returns (string memory _uintAsString) { if (_i == 0) { return "0"; } uint j = _i; uint len; while (j != 0) { len++; j /= 10; } bytes memory bstr = new bytes(len); uint k = len - 1; while (_i != 0) { bstr[k--] = byte(uint8(48 + _i % 10)); _i /= 10; } return string(bstr); } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev String operations. */ library Strings { /** * @dev Converts a `uint256` to its ASCII `string` 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); uint256 index = digits - 1; temp = value; while (temp != 0) { buffer[index--] = bytes1(uint8(48 + temp % 10)); temp /= 10; } return string(buffer); } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. */ library EnumerableSet { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping (bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement. bytes32 lastvalue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastvalue; // Update the index for the moved value set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { require(set._values.length > index, "EnumerableSet: index out of bounds"); return set._values[index]; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values on the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Library for managing an enumerable variant of Solidity's * https://solidity.readthedocs.io/en/latest/types.html#mapping-types[`mapping`] * type. * * Maps have the following properties: * * - Entries are added, removed, and checked for existence in constant time * (O(1)). * - Entries are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableMap for EnumerableMap.UintToAddressMap; * * // Declare a set state variable * EnumerableMap.UintToAddressMap private myMap; * } * ``` * * As of v3.0.0, only maps of type `uint256 -> address` (`UintToAddressMap`) are * supported. */ library EnumerableMap { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Map type with // bytes32 keys and values. // The Map implementation uses private functions, and user-facing // implementations (such as Uint256ToAddressMap) are just wrappers around // the underlying Map. // This means that we can only create new EnumerableMaps for types that fit // in bytes32. struct MapEntry { bytes32 _key; bytes32 _value; } struct Map { // Storage of map keys and values MapEntry[] _entries; // Position of the entry defined by a key in the `entries` array, plus 1 // because index 0 means a key is not in the map. mapping (bytes32 => uint256) _indexes; } /** * @dev Adds a key-value pair to a map, or updates the value for an existing * key. O(1). * * Returns true if the key was added to the map, that is if it was not * already present. */ function _set(Map storage map, bytes32 key, bytes32 value) private returns (bool) { // We read and store the key's index to prevent multiple reads from the same storage slot uint256 keyIndex = map._indexes[key]; if (keyIndex == 0) { // Equivalent to !contains(map, key) map._entries.push(MapEntry({ _key: key, _value: value })); // The entry is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value map._indexes[key] = map._entries.length; return true; } else { map._entries[keyIndex - 1]._value = value; return false; } } /** * @dev Removes a key-value pair from a map. O(1). * * Returns true if the key was removed from the map, that is if it was present. */ function _remove(Map storage map, bytes32 key) private returns (bool) { // We read and store the key's index to prevent multiple reads from the same storage slot uint256 keyIndex = map._indexes[key]; if (keyIndex != 0) { // Equivalent to contains(map, key) // To delete a key-value pair from the _entries array in O(1), we swap the entry to delete with the last one // in the array, and then remove the last entry (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = keyIndex - 1; uint256 lastIndex = map._entries.length - 1; // When the entry to delete is the last one, the swap operation is unnecessary. However, since this occurs // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement. MapEntry storage lastEntry = map._entries[lastIndex]; // Move the last entry to the index where the entry to delete is map._entries[toDeleteIndex] = lastEntry; // Update the index for the moved entry map._indexes[lastEntry._key] = toDeleteIndex + 1; // All indexes are 1-based // Delete the slot where the moved entry was stored map._entries.pop(); // Delete the index for the deleted slot delete map._indexes[key]; return true; } else { return false; } } /** * @dev Returns true if the key is in the map. O(1). */ function _contains(Map storage map, bytes32 key) private view returns (bool) { return map._indexes[key] != 0; } /** * @dev Returns the number of key-value pairs in the map. O(1). */ function _length(Map storage map) private view returns (uint256) { return map._entries.length; } /** * @dev Returns the key-value pair stored at position `index` in the map. O(1). * * Note that there are no guarantees on the ordering of entries inside the * array, and it may change when more entries are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Map storage map, uint256 index) private view returns (bytes32, bytes32) { require(map._entries.length > index, "EnumerableMap: index out of bounds"); MapEntry storage entry = map._entries[index]; return (entry._key, entry._value); } /** * @dev Tries to returns the value associated with `key`. O(1). * Does not revert if `key` is not in the map. */ function _tryGet(Map storage map, bytes32 key) private view returns (bool, bytes32) { uint256 keyIndex = map._indexes[key]; if (keyIndex == 0) return (false, 0); // Equivalent to contains(map, key) return (true, map._entries[keyIndex - 1]._value); // All indexes are 1-based } /** * @dev Returns the value associated with `key`. O(1). * * Requirements: * * - `key` must be in the map. */ function _get(Map storage map, bytes32 key) private view returns (bytes32) { uint256 keyIndex = map._indexes[key]; require(keyIndex != 0, "EnumerableMap: nonexistent key"); // Equivalent to contains(map, key) return map._entries[keyIndex - 1]._value; // All indexes are 1-based } /** * @dev Same as {_get}, with a custom error message when `key` is not in the map. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {_tryGet}. */ function _get(Map storage map, bytes32 key, string memory errorMessage) private view returns (bytes32) { uint256 keyIndex = map._indexes[key]; require(keyIndex != 0, errorMessage); // Equivalent to contains(map, key) return map._entries[keyIndex - 1]._value; // All indexes are 1-based } // UintToAddressMap struct UintToAddressMap { Map _inner; } /** * @dev Adds a key-value pair to a map, or updates the value for an existing * key. O(1). * * Returns true if the key was added to the map, that is if it was not * already present. */ function set(UintToAddressMap storage map, uint256 key, address value) internal returns (bool) { return _set(map._inner, bytes32(key), bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the key was removed from the map, that is if it was present. */ function remove(UintToAddressMap storage map, uint256 key) internal returns (bool) { return _remove(map._inner, bytes32(key)); } /** * @dev Returns true if the key is in the map. O(1). */ function contains(UintToAddressMap storage map, uint256 key) internal view returns (bool) { return _contains(map._inner, bytes32(key)); } /** * @dev Returns the number of elements in the map. O(1). */ function length(UintToAddressMap storage map) internal view returns (uint256) { return _length(map._inner); } /** * @dev Returns the element stored at position `index` in the set. O(1). * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintToAddressMap storage map, uint256 index) internal view returns (uint256, address) { (bytes32 key, bytes32 value) = _at(map._inner, index); return (uint256(key), address(uint160(uint256(value)))); } /** * @dev Tries to returns the value associated with `key`. O(1). * Does not revert if `key` is not in the map. * * _Available since v3.4._ */ function tryGet(UintToAddressMap storage map, uint256 key) internal view returns (bool, address) { (bool success, bytes32 value) = _tryGet(map._inner, bytes32(key)); return (success, address(uint160(uint256(value)))); } /** * @dev Returns the value associated with `key`. O(1). * * Requirements: * * - `key` must be in the map. */ function get(UintToAddressMap storage map, uint256 key) internal view returns (address) { return address(uint160(uint256(_get(map._inner, bytes32(key))))); } /** * @dev Same as {get}, with a custom error message when `key` is not in the map. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryGet}. */ function get(UintToAddressMap storage map, uint256 key, string memory errorMessage) internal view returns (address) { return address(uint160(uint256(_get(map._inner, bytes32(key), errorMessage)))); } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <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 GSN 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 payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.2 <0.8.0; /** * @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 * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 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"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (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"); // solhint-disable-next-line avoid-low-level-calls (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"); // solhint-disable-next-line avoid-low-level-calls (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"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private 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 // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <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 `IERC721.onERC721Received.selector`. */ function onERC721Received(address operator, address from, uint256 tokenId, bytes calldata data) external returns (bytes4); }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.2 <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); }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.2 <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 tokenId); /** * @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 pragma solidity >=0.6.2 <0.8.0; import "../../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`, 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) 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 Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @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 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); /** * @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; }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "../../utils/Context.sol"; import "./IERC721.sol"; import "./IERC721Metadata.sol"; import "./IERC721Enumerable.sol"; import "./IERC721Receiver.sol"; import "../../introspection/ERC165.sol"; import "../../math/SafeMath.sol"; import "../../utils/Address.sol"; import "../../utils/EnumerableSet.sol"; import "../../utils/EnumerableMap.sol"; import "../../utils/Strings.sol"; /** * @title ERC721 Non-Fungible Token Standard basic implementation * @dev see https://eips.ethereum.org/EIPS/eip-721 */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable { using SafeMath for uint256; using Address for address; using EnumerableSet for EnumerableSet.UintSet; using EnumerableMap for EnumerableMap.UintToAddressMap; using Strings for uint256; // Equals to `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))` // which can be also obtained as `IERC721Receiver(0).onERC721Received.selector` bytes4 private constant _ERC721_RECEIVED = 0x150b7a02; // Mapping from holder address to their (enumerable) set of owned tokens mapping (address => EnumerableSet.UintSet) private _holderTokens; // Enumerable mapping from token ids to their owners EnumerableMap.UintToAddressMap private _tokenOwners; // 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; // Token name string private _name; // Token symbol string private _symbol; // Optional mapping for token URIs mapping (uint256 => string) private _tokenURIs; // Base URI string private _baseURI; /* * bytes4(keccak256('balanceOf(address)')) == 0x70a08231 * bytes4(keccak256('ownerOf(uint256)')) == 0x6352211e * bytes4(keccak256('approve(address,uint256)')) == 0x095ea7b3 * bytes4(keccak256('getApproved(uint256)')) == 0x081812fc * bytes4(keccak256('setApprovalForAll(address,bool)')) == 0xa22cb465 * bytes4(keccak256('isApprovedForAll(address,address)')) == 0xe985e9c5 * bytes4(keccak256('transferFrom(address,address,uint256)')) == 0x23b872dd * bytes4(keccak256('safeTransferFrom(address,address,uint256)')) == 0x42842e0e * bytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)')) == 0xb88d4fde * * => 0x70a08231 ^ 0x6352211e ^ 0x095ea7b3 ^ 0x081812fc ^ * 0xa22cb465 ^ 0xe985e9c5 ^ 0x23b872dd ^ 0x42842e0e ^ 0xb88d4fde == 0x80ac58cd */ bytes4 private constant _INTERFACE_ID_ERC721 = 0x80ac58cd; /* * bytes4(keccak256('name()')) == 0x06fdde03 * bytes4(keccak256('symbol()')) == 0x95d89b41 * bytes4(keccak256('tokenURI(uint256)')) == 0xc87b56dd * * => 0x06fdde03 ^ 0x95d89b41 ^ 0xc87b56dd == 0x5b5e139f */ bytes4 private constant _INTERFACE_ID_ERC721_METADATA = 0x5b5e139f; /* * bytes4(keccak256('totalSupply()')) == 0x18160ddd * bytes4(keccak256('tokenOfOwnerByIndex(address,uint256)')) == 0x2f745c59 * bytes4(keccak256('tokenByIndex(uint256)')) == 0x4f6ccce7 * * => 0x18160ddd ^ 0x2f745c59 ^ 0x4f6ccce7 == 0x780e9d63 */ bytes4 private constant _INTERFACE_ID_ERC721_ENUMERABLE = 0x780e9d63; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor (string memory name_, string memory symbol_) public { _name = name_; _symbol = symbol_; // register the supported interfaces to conform to ERC721 via ERC165 _registerInterface(_INTERFACE_ID_ERC721); _registerInterface(_INTERFACE_ID_ERC721_METADATA); _registerInterface(_INTERFACE_ID_ERC721_ENUMERABLE); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _holderTokens[owner].length(); } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { return _tokenOwners.get(tokenId, "ERC721: owner query for nonexistent token"); } /** * @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) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory _tokenURI = _tokenURIs[tokenId]; string memory base = baseURI(); // If there is no base URI, return the token URI. if (bytes(base).length == 0) { return _tokenURI; } // If both are set, concatenate the baseURI and tokenURI (via abi.encodePacked). if (bytes(_tokenURI).length > 0) { return string(abi.encodePacked(base, _tokenURI)); } // If there is a baseURI but no tokenURI, concatenate the tokenID to the baseURI. return string(abi.encodePacked(base, tokenId.toString())); } /** * @dev Returns the base URI set via {_setBaseURI}. This will be * automatically added as a prefix in {tokenURI} to each token's URI, or * to the token ID if no specific URI is set for that token ID. */ function baseURI() public view virtual returns (string memory) { return _baseURI; } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) { return _holderTokens[owner].at(index); } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { // _tokenOwners are indexed by tokenIds, so .length() returns the number of tokenIds return _tokenOwners.length(); } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view virtual override returns (uint256) { (uint256 tokenId, ) = _tokenOwners.at(index); return tokenId; } /** * @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 || ERC721.isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { require(operator != _msgSender(), "ERC721: approve to caller"); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_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: transfer caller is not 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: transfer caller is not 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 _tokenOwners.contains(tokenId); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || ERC721.isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: d* * - `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); _holderTokens[to].add(tokenId); _tokenOwners.set(tokenId, to); emit Transfer(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); // internal owner _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); // Clear metadata (if any) if (bytes(_tokenURIs[tokenId]).length != 0) { delete _tokenURIs[tokenId]; } _holderTokens[owner].remove(tokenId); _tokenOwners.remove(tokenId); emit Transfer(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 of token that is not own"); // internal 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); _holderTokens[from].remove(tokenId); _holderTokens[to].add(tokenId); _tokenOwners.set(tokenId, to); emit Transfer(from, to, tokenId); } /** * @dev Sets `_tokenURI` as the tokenURI of `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _setTokenURI(uint256 tokenId, string memory _tokenURI) internal virtual { require(_exists(tokenId), "ERC721Metadata: URI set of nonexistent token"); _tokenURIs[tokenId] = _tokenURI; } /** * @dev Internal function to set the base URI for all token IDs. It is * automatically added as a prefix to the value returned in {tokenURI}, * or to the token ID if {tokenURI} is empty. */ function _setBaseURI(string memory baseURI_) internal virtual { _baseURI = baseURI_; } /** * @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()) { return true; } bytes memory returndata = to.functionCall(abi.encodeWithSelector( IERC721Receiver(to).onERC721Received.selector, _msgSender(), from, tokenId, _data ), "ERC721: transfer to non ERC721Receiver implementer"); bytes4 retval = abi.decode(returndata, (bytes4)); return (retval == _ERC721_RECEIVED); } /** * @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); // internal owner } /** * @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 { } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } /** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b > a) return (false, 0); return (true, a - b); } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a / b); } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a % b); } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a, "SafeMath: subtraction overflow"); return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) return 0; uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: division by zero"); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: modulo by zero"); return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); return a - b; } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryDiv}. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a % b; } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <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 pragma solidity >=0.6.0 <0.8.0; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts may inherit from this and call {_registerInterface} to declare * their support of an interface. */ abstract contract ERC165 is IERC165 { /* * bytes4(keccak256('supportsInterface(bytes4)')) == 0x01ffc9a7 */ bytes4 private constant _INTERFACE_ID_ERC165 = 0x01ffc9a7; /** * @dev Mapping of interface ids to whether or not it's supported. */ mapping(bytes4 => bool) private _supportedInterfaces; constructor () internal { // Derived contracts need only register support for their own interfaces, // we register support for ERC165 itself here _registerInterface(_INTERFACE_ID_ERC165); } /** * @dev See {IERC165-supportsInterface}. * * Time complexity O(1), guaranteed to always use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return _supportedInterfaces[interfaceId]; } /** * @dev Registers the contract as an implementer of the interface defined by * `interfaceId`. Support of the actual ERC165 interface is automatic and * registering its interface id is not required. * * See {IERC165-supportsInterface}. * * Requirements: * * - `interfaceId` cannot be the ERC165 invalid interface (`0xffffffff`). */ function _registerInterface(bytes4 interfaceId) internal virtual { require(interfaceId != 0xffffffff, "ERC165: invalid interface id"); _supportedInterfaces[interfaceId] = true; } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev String operations. */ library StringsUpgradeable { /** * @dev Converts a `uint256` to its ASCII `string` 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); uint256 index = digits - 1; temp = value; while (temp != 0) { buffer[index--] = bytes1(uint8(48 + temp % 10)); temp /= 10; } return string(buffer); } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. */ library EnumerableSetUpgradeable { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping (bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement. bytes32 lastvalue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastvalue; // Update the index for the moved value set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { require(set._values.length > index, "EnumerableSet: index out of bounds"); return set._values[index]; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values on the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Library for managing an enumerable variant of Solidity's * https://solidity.readthedocs.io/en/latest/types.html#mapping-types[`mapping`] * type. * * Maps have the following properties: * * - Entries are added, removed, and checked for existence in constant time * (O(1)). * - Entries are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableMap for EnumerableMap.UintToAddressMap; * * // Declare a set state variable * EnumerableMap.UintToAddressMap private myMap; * } * ``` * * As of v3.0.0, only maps of type `uint256 -> address` (`UintToAddressMap`) are * supported. */ library EnumerableMapUpgradeable { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Map type with // bytes32 keys and values. // The Map implementation uses private functions, and user-facing // implementations (such as Uint256ToAddressMap) are just wrappers around // the underlying Map. // This means that we can only create new EnumerableMaps for types that fit // in bytes32. struct MapEntry { bytes32 _key; bytes32 _value; } struct Map { // Storage of map keys and values MapEntry[] _entries; // Position of the entry defined by a key in the `entries` array, plus 1 // because index 0 means a key is not in the map. mapping (bytes32 => uint256) _indexes; } /** * @dev Adds a key-value pair to a map, or updates the value for an existing * key. O(1). * * Returns true if the key was added to the map, that is if it was not * already present. */ function _set(Map storage map, bytes32 key, bytes32 value) private returns (bool) { // We read and store the key's index to prevent multiple reads from the same storage slot uint256 keyIndex = map._indexes[key]; if (keyIndex == 0) { // Equivalent to !contains(map, key) map._entries.push(MapEntry({ _key: key, _value: value })); // The entry is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value map._indexes[key] = map._entries.length; return true; } else { map._entries[keyIndex - 1]._value = value; return false; } } /** * @dev Removes a key-value pair from a map. O(1). * * Returns true if the key was removed from the map, that is if it was present. */ function _remove(Map storage map, bytes32 key) private returns (bool) { // We read and store the key's index to prevent multiple reads from the same storage slot uint256 keyIndex = map._indexes[key]; if (keyIndex != 0) { // Equivalent to contains(map, key) // To delete a key-value pair from the _entries array in O(1), we swap the entry to delete with the last one // in the array, and then remove the last entry (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = keyIndex - 1; uint256 lastIndex = map._entries.length - 1; // When the entry to delete is the last one, the swap operation is unnecessary. However, since this occurs // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement. MapEntry storage lastEntry = map._entries[lastIndex]; // Move the last entry to the index where the entry to delete is map._entries[toDeleteIndex] = lastEntry; // Update the index for the moved entry map._indexes[lastEntry._key] = toDeleteIndex + 1; // All indexes are 1-based // Delete the slot where the moved entry was stored map._entries.pop(); // Delete the index for the deleted slot delete map._indexes[key]; return true; } else { return false; } } /** * @dev Returns true if the key is in the map. O(1). */ function _contains(Map storage map, bytes32 key) private view returns (bool) { return map._indexes[key] != 0; } /** * @dev Returns the number of key-value pairs in the map. O(1). */ function _length(Map storage map) private view returns (uint256) { return map._entries.length; } /** * @dev Returns the key-value pair stored at position `index` in the map. O(1). * * Note that there are no guarantees on the ordering of entries inside the * array, and it may change when more entries are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Map storage map, uint256 index) private view returns (bytes32, bytes32) { require(map._entries.length > index, "EnumerableMap: index out of bounds"); MapEntry storage entry = map._entries[index]; return (entry._key, entry._value); } /** * @dev Tries to returns the value associated with `key`. O(1). * Does not revert if `key` is not in the map. */ function _tryGet(Map storage map, bytes32 key) private view returns (bool, bytes32) { uint256 keyIndex = map._indexes[key]; if (keyIndex == 0) return (false, 0); // Equivalent to contains(map, key) return (true, map._entries[keyIndex - 1]._value); // All indexes are 1-based } /** * @dev Returns the value associated with `key`. O(1). * * Requirements: * * - `key` must be in the map. */ function _get(Map storage map, bytes32 key) private view returns (bytes32) { uint256 keyIndex = map._indexes[key]; require(keyIndex != 0, "EnumerableMap: nonexistent key"); // Equivalent to contains(map, key) return map._entries[keyIndex - 1]._value; // All indexes are 1-based } /** * @dev Same as {_get}, with a custom error message when `key` is not in the map. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {_tryGet}. */ function _get(Map storage map, bytes32 key, string memory errorMessage) private view returns (bytes32) { uint256 keyIndex = map._indexes[key]; require(keyIndex != 0, errorMessage); // Equivalent to contains(map, key) return map._entries[keyIndex - 1]._value; // All indexes are 1-based } // UintToAddressMap struct UintToAddressMap { Map _inner; } /** * @dev Adds a key-value pair to a map, or updates the value for an existing * key. O(1). * * Returns true if the key was added to the map, that is if it was not * already present. */ function set(UintToAddressMap storage map, uint256 key, address value) internal returns (bool) { return _set(map._inner, bytes32(key), bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the key was removed from the map, that is if it was present. */ function remove(UintToAddressMap storage map, uint256 key) internal returns (bool) { return _remove(map._inner, bytes32(key)); } /** * @dev Returns true if the key is in the map. O(1). */ function contains(UintToAddressMap storage map, uint256 key) internal view returns (bool) { return _contains(map._inner, bytes32(key)); } /** * @dev Returns the number of elements in the map. O(1). */ function length(UintToAddressMap storage map) internal view returns (uint256) { return _length(map._inner); } /** * @dev Returns the element stored at position `index` in the set. O(1). * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintToAddressMap storage map, uint256 index) internal view returns (uint256, address) { (bytes32 key, bytes32 value) = _at(map._inner, index); return (uint256(key), address(uint160(uint256(value)))); } /** * @dev Tries to returns the value associated with `key`. O(1). * Does not revert if `key` is not in the map. * * _Available since v3.4._ */ function tryGet(UintToAddressMap storage map, uint256 key) internal view returns (bool, address) { (bool success, bytes32 value) = _tryGet(map._inner, bytes32(key)); return (success, address(uint160(uint256(value)))); } /** * @dev Returns the value associated with `key`. O(1). * * Requirements: * * - `key` must be in the map. */ function get(UintToAddressMap storage map, uint256 key) internal view returns (address) { return address(uint160(uint256(_get(map._inner, bytes32(key))))); } /** * @dev Same as {get}, with a custom error message when `key` is not in the map. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryGet}. */ function get(UintToAddressMap storage map, uint256 key, string memory errorMessage) internal view returns (address) { return address(uint160(uint256(_get(map._inner, bytes32(key), errorMessage)))); } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "../math/SafeMathUpgradeable.sol"; /** * @title Counters * @author Matt Condon (@shrugs) * @dev Provides counters that can only be incremented or decremented by one. 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;` * Since it is not possible to overflow a 256 bit integer with increments of one, `increment` can skip the {SafeMath} * overflow check, thereby saving gas. This does assume however correct usage, in that the underlying `_value` is never * directly accessed. */ library CountersUpgradeable { using SafeMathUpgradeable for uint256; 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 { // The {SafeMath} overflow check can be skipped here, see the comment at the top counter._value += 1; } function decrement(Counter storage counter) internal { counter._value = counter._value.sub(1); } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "../proxy/Initializable.sol"; /* * @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 GSN 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 ContextUpgradeable is Initializable { function __Context_init() internal initializer { __Context_init_unchained(); } function __Context_init_unchained() internal initializer { } function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } uint256[50] private __gap; }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.2 <0.8.0; /** * @dev Collection of functions related to the address type */ library AddressUpgradeable { /** * @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 * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 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"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (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"); // solhint-disable-next-line avoid-low-level-calls (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"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private 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 // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.2 <0.8.0; import "../../introspection/IERC165Upgradeable.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721Upgradeable is IERC165Upgradeable { /** * @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) 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 Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @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 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); /** * @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; }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721ReceiverUpgradeable { /** * @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 `IERC721.onERC721Received.selector`. */ function onERC721Received(address operator, address from, uint256 tokenId, bytes calldata data) external returns (bytes4); }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.2 <0.8.0; import "./IERC721Upgradeable.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721MetadataUpgradeable is IERC721Upgradeable { /** * @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); }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.2 <0.8.0; import "./IERC721Upgradeable.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721EnumerableUpgradeable is IERC721Upgradeable { /** * @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 tokenId); /** * @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 pragma solidity >=0.6.0 <0.8.0; import "../../utils/ContextUpgradeable.sol"; import "./IERC721Upgradeable.sol"; import "./IERC721MetadataUpgradeable.sol"; import "./IERC721EnumerableUpgradeable.sol"; import "./IERC721ReceiverUpgradeable.sol"; import "../../introspection/ERC165Upgradeable.sol"; import "../../math/SafeMathUpgradeable.sol"; import "../../utils/AddressUpgradeable.sol"; import "../../utils/EnumerableSetUpgradeable.sol"; import "../../utils/EnumerableMapUpgradeable.sol"; import "../../utils/StringsUpgradeable.sol"; import "../../proxy/Initializable.sol"; /** * @title ERC721 Non-Fungible Token Standard basic implementation * @dev see https://eips.ethereum.org/EIPS/eip-721 */ contract ERC721Upgradeable is Initializable, ContextUpgradeable, ERC165Upgradeable, IERC721Upgradeable, IERC721MetadataUpgradeable, IERC721EnumerableUpgradeable { using SafeMathUpgradeable for uint256; using AddressUpgradeable for address; using EnumerableSetUpgradeable for EnumerableSetUpgradeable.UintSet; using EnumerableMapUpgradeable for EnumerableMapUpgradeable.UintToAddressMap; using StringsUpgradeable for uint256; // Equals to `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))` // which can be also obtained as `IERC721Receiver(0).onERC721Received.selector` bytes4 private constant _ERC721_RECEIVED = 0x150b7a02; // Mapping from holder address to their (enumerable) set of owned tokens mapping (address => EnumerableSetUpgradeable.UintSet) private _holderTokens; // Enumerable mapping from token ids to their owners EnumerableMapUpgradeable.UintToAddressMap private _tokenOwners; // 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; // Token name string private _name; // Token symbol string private _symbol; // Optional mapping for token URIs mapping (uint256 => string) private _tokenURIs; // Base URI string private _baseURI; /* * bytes4(keccak256('balanceOf(address)')) == 0x70a08231 * bytes4(keccak256('ownerOf(uint256)')) == 0x6352211e * bytes4(keccak256('approve(address,uint256)')) == 0x095ea7b3 * bytes4(keccak256('getApproved(uint256)')) == 0x081812fc * bytes4(keccak256('setApprovalForAll(address,bool)')) == 0xa22cb465 * bytes4(keccak256('isApprovedForAll(address,address)')) == 0xe985e9c5 * bytes4(keccak256('transferFrom(address,address,uint256)')) == 0x23b872dd * bytes4(keccak256('safeTransferFrom(address,address,uint256)')) == 0x42842e0e * bytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)')) == 0xb88d4fde * * => 0x70a08231 ^ 0x6352211e ^ 0x095ea7b3 ^ 0x081812fc ^ * 0xa22cb465 ^ 0xe985e9c5 ^ 0x23b872dd ^ 0x42842e0e ^ 0xb88d4fde == 0x80ac58cd */ bytes4 private constant _INTERFACE_ID_ERC721 = 0x80ac58cd; /* * bytes4(keccak256('name()')) == 0x06fdde03 * bytes4(keccak256('symbol()')) == 0x95d89b41 * bytes4(keccak256('tokenURI(uint256)')) == 0xc87b56dd * * => 0x06fdde03 ^ 0x95d89b41 ^ 0xc87b56dd == 0x5b5e139f */ bytes4 private constant _INTERFACE_ID_ERC721_METADATA = 0x5b5e139f; /* * bytes4(keccak256('totalSupply()')) == 0x18160ddd * bytes4(keccak256('tokenOfOwnerByIndex(address,uint256)')) == 0x2f745c59 * bytes4(keccak256('tokenByIndex(uint256)')) == 0x4f6ccce7 * * => 0x18160ddd ^ 0x2f745c59 ^ 0x4f6ccce7 == 0x780e9d63 */ bytes4 private constant _INTERFACE_ID_ERC721_ENUMERABLE = 0x780e9d63; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ function __ERC721_init(string memory name_, string memory symbol_) internal initializer { __Context_init_unchained(); __ERC165_init_unchained(); __ERC721_init_unchained(name_, symbol_); } function __ERC721_init_unchained(string memory name_, string memory symbol_) internal initializer { _name = name_; _symbol = symbol_; // register the supported interfaces to conform to ERC721 via ERC165 _registerInterface(_INTERFACE_ID_ERC721); _registerInterface(_INTERFACE_ID_ERC721_METADATA); _registerInterface(_INTERFACE_ID_ERC721_ENUMERABLE); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _holderTokens[owner].length(); } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { return _tokenOwners.get(tokenId, "ERC721: owner query for nonexistent token"); } /** * @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) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory _tokenURI = _tokenURIs[tokenId]; string memory base = baseURI(); // If there is no base URI, return the token URI. if (bytes(base).length == 0) { return _tokenURI; } // If both are set, concatenate the baseURI and tokenURI (via abi.encodePacked). if (bytes(_tokenURI).length > 0) { return string(abi.encodePacked(base, _tokenURI)); } // If there is a baseURI but no tokenURI, concatenate the tokenID to the baseURI. return string(abi.encodePacked(base, tokenId.toString())); } /** * @dev Returns the base URI set via {_setBaseURI}. This will be * automatically added as a prefix in {tokenURI} to each token's URI, or * to the token ID if no specific URI is set for that token ID. */ function baseURI() public view virtual returns (string memory) { return _baseURI; } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) { return _holderTokens[owner].at(index); } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { // _tokenOwners are indexed by tokenIds, so .length() returns the number of tokenIds return _tokenOwners.length(); } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view virtual override returns (uint256) { (uint256 tokenId, ) = _tokenOwners.at(index); return tokenId; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721Upgradeable.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require(_msgSender() == owner || ERC721Upgradeable.isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { require(operator != _msgSender(), "ERC721: approve to caller"); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_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: transfer caller is not 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: transfer caller is not 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 _tokenOwners.contains(tokenId); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721Upgradeable.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || ERC721Upgradeable.isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: d* * - `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); _holderTokens[to].add(tokenId); _tokenOwners.set(tokenId, to); emit Transfer(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 = ERC721Upgradeable.ownerOf(tokenId); // internal owner _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); // Clear metadata (if any) if (bytes(_tokenURIs[tokenId]).length != 0) { delete _tokenURIs[tokenId]; } _holderTokens[owner].remove(tokenId); _tokenOwners.remove(tokenId); emit Transfer(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(ERC721Upgradeable.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); // internal 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); _holderTokens[from].remove(tokenId); _holderTokens[to].add(tokenId); _tokenOwners.set(tokenId, to); emit Transfer(from, to, tokenId); } /** * @dev Sets `_tokenURI` as the tokenURI of `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _setTokenURI(uint256 tokenId, string memory _tokenURI) internal virtual { require(_exists(tokenId), "ERC721Metadata: URI set of nonexistent token"); _tokenURIs[tokenId] = _tokenURI; } /** * @dev Internal function to set the base URI for all token IDs. It is * automatically added as a prefix to the value returned in {tokenURI}, * or to the token ID if {tokenURI} is empty. */ function _setBaseURI(string memory baseURI_) internal virtual { _baseURI = baseURI_; } /** * @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()) { return true; } bytes memory returndata = to.functionCall(abi.encodeWithSelector( IERC721ReceiverUpgradeable(to).onERC721Received.selector, _msgSender(), from, tokenId, _data ), "ERC721: transfer to non ERC721Receiver implementer"); bytes4 retval = abi.decode(returndata, (bytes4)); return (retval == _ERC721_RECEIVED); } /** * @dev Approve `to` to operate on `tokenId` * * Emits an {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721Upgradeable.ownerOf(tokenId), to, tokenId); // internal owner } /** * @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 { } uint256[41] private __gap; }
// SPDX-License-Identifier: MIT // solhint-disable-next-line compiler-version pragma solidity >=0.4.24 <0.8.0; import "../utils/AddressUpgradeable.sol"; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {UpgradeableProxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. */ bool private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Modifier to protect an initializer function from being invoked twice. */ modifier initializer() { require(_initializing || _isConstructor() || !_initialized, "Initializable: contract is already initialized"); bool isTopLevelCall = !_initializing; if (isTopLevelCall) { _initializing = true; _initialized = true; } _; if (isTopLevelCall) { _initializing = false; } } /// @dev Returns true if and only if the function is running in the constructor function _isConstructor() private view returns (bool) { return !AddressUpgradeable.isContract(address(this)); } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMathUpgradeable { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } /** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b > a) return (false, 0); return (true, a - b); } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a / b); } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a % b); } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a, "SafeMath: subtraction overflow"); return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) return 0; uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: division by zero"); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: modulo by zero"); return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); return a - b; } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryDiv}. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a % b; } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <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 IERC165Upgradeable { /** * @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 pragma solidity >=0.6.0 <0.8.0; import "./IERC165Upgradeable.sol"; import "../proxy/Initializable.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts may inherit from this and call {_registerInterface} to declare * their support of an interface. */ abstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable { /* * bytes4(keccak256('supportsInterface(bytes4)')) == 0x01ffc9a7 */ bytes4 private constant _INTERFACE_ID_ERC165 = 0x01ffc9a7; /** * @dev Mapping of interface ids to whether or not it's supported. */ mapping(bytes4 => bool) private _supportedInterfaces; function __ERC165_init() internal initializer { __ERC165_init_unchained(); } function __ERC165_init_unchained() internal initializer { // Derived contracts need only register support for their own interfaces, // we register support for ERC165 itself here _registerInterface(_INTERFACE_ID_ERC165); } /** * @dev See {IERC165-supportsInterface}. * * Time complexity O(1), guaranteed to always use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return _supportedInterfaces[interfaceId]; } /** * @dev Registers the contract as an implementer of the interface defined by * `interfaceId`. Support of the actual ERC165 interface is automatic and * registering its interface id is not required. * * See {IERC165-supportsInterface}. * * Requirements: * * - `interfaceId` cannot be the ERC165 invalid interface (`0xffffffff`). */ function _registerInterface(bytes4 interfaceId) internal virtual { require(interfaceId != 0xffffffff, "ERC165: invalid interface id"); _supportedInterfaces[interfaceId] = true; } uint256[49] private __gap; }
{ "remappings": [], "optimizer": { "enabled": true, "runs": 200 }, "evmVersion": "istanbul", "libraries": {}, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } } }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"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":"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"},{"inputs":[],"name":"_contractURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"value","type":"uint256"}],"name":"_decodeTokenId","outputs":[{"internalType":"uint256","name":"x","type":"uint256"},{"internalType":"uint256","name":"y","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"x","type":"uint256"},{"internalType":"uint256","name":"y","type":"uint256"}],"name":"_encodeTokenId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"_owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"allowMetadataForAllReserved","outputs":[{"internalType":"bool","name":"","type":"bool"}],"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":"baseURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_category","type":"uint256"},{"internalType":"uint256","name":"_count","type":"uint256"}],"name":"claim","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"x","type":"uint256"},{"internalType":"uint256","name":"y","type":"uint256"},{"internalType":"uint256","name":"collectionID","type":"uint256"}],"name":"claimLand","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"collectionAddressByIndex","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"x","type":"uint256"},{"internalType":"uint256","name":"y","type":"uint256"}],"name":"collectionIDAt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"collectionIndicesByAddress","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"collectionRectByIndex","outputs":[{"components":[{"internalType":"uint256","name":"x","type":"uint256"},{"internalType":"uint256","name":"y","type":"uint256"}],"internalType":"struct MyPFPlandv3.Point","name":"leftBottom","type":"tuple"},{"components":[{"internalType":"uint256","name":"x","type":"uint256"},{"internalType":"uint256","name":"y","type":"uint256"}],"internalType":"struct MyPFPlandv3.Point","name":"rightTop","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"contractURI","outputs":[{"internalType":"string","name":"","type":"string"}],"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":"address","name":"_claimer","type":"address"},{"internalType":"uint256","name":"_category","type":"uint256"}],"name":"getDerivativesToClaim","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"collectionID","type":"uint256"},{"internalType":"uint256","name":"tokenID","type":"uint256"}],"name":"getLandMetaData","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"initialize","outputs":[],"stateMutability":"nonpayable","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":[{"components":[{"internalType":"uint256","name":"x","type":"uint256"},{"internalType":"uint256","name":"y","type":"uint256"}],"internalType":"struct MyPFPlandv3.Point","name":"point","type":"tuple"},{"components":[{"components":[{"internalType":"uint256","name":"x","type":"uint256"},{"internalType":"uint256","name":"y","type":"uint256"}],"internalType":"struct MyPFPlandv3.Point","name":"leftBottom","type":"tuple"},{"components":[{"internalType":"uint256","name":"x","type":"uint256"},{"internalType":"uint256","name":"y","type":"uint256"}],"internalType":"struct MyPFPlandv3.Point","name":"rightTop","type":"tuple"}],"internalType":"struct MyPFPlandv3.Rectangle","name":"area","type":"tuple"}],"name":"isInsideCollectionRect","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"isOpenPayment","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isPausedClaimingDerivative","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isPausedClaimingLand","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isPausedClaimingPainting","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isPausedClaimingRoyal","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isPausedClaimingStatteute","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isPausedClaimingToy","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"landDerivativeBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"landDerivativeMetadataOf","outputs":[{"internalType":"address","name":"collectionAddress","type":"address"},{"internalType":"uint256","name":"tokenID","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"landOwnerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"landRoyalMetadataOf","outputs":[{"internalType":"uint256","name":"collectionID","type":"uint256"},{"internalType":"uint256","name":"tokenID","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"oldTokenIDUsed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"indices","type":"uint256[]"},{"internalType":"address[]","name":"collectionAddress","type":"address[]"},{"internalType":"uint256","name":"count","type":"uint256"}],"name":"resetBatchCollectionRect","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"index","type":"uint256"},{"internalType":"uint256","name":"collectionID","type":"uint256"}],"name":"royalTokenOfOwnerByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"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":"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":"bool","name":"_allowMetadataForAllReserved","type":"bool"}],"name":"setAllowMetadataForAllReserved","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":"_baseURI","type":"string"}],"name":"setBaseURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_blacklist","type":"address[]"},{"internalType":"uint256","name":"_count","type":"uint256"}],"name":"setBatchCameoBlacklist","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_whitelist","type":"address[]"},{"internalType":"uint256","name":"_count","type":"uint256"}],"name":"setBatchCameoWhitelist","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"leftBottomX","type":"uint256[]"},{"internalType":"uint256[]","name":"leftBottomY","type":"uint256[]"},{"internalType":"uint256[]","name":"rightTopX","type":"uint256[]"},{"internalType":"uint256[]","name":"rightTopY","type":"uint256[]"},{"internalType":"address[]","name":"collectionAddress","type":"address[]"},{"internalType":"uint256","name":"count","type":"uint256"}],"name":"setBatchCollectionRect","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_blacklist","type":"address[]"},{"internalType":"uint256","name":"_count","type":"uint256"}],"name":"setBatchHonoraryBlacklist","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_whitelist","type":"address[]"},{"internalType":"uint256","name":"_count","type":"uint256"}],"name":"setBatchHonoraryWhitelist","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_blacklist","type":"address[]"},{"internalType":"uint256","name":"_count","type":"uint256"}],"name":"setBatchMekakeyBlacklist","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_whitelist","type":"address[]"},{"internalType":"uint256","name":"_count","type":"uint256"}],"name":"setBatchMekakeyWhitelist","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"_contractURI_","type":"string"}],"name":"setContractURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_isPausedClaimingDerivative","type":"bool"}],"name":"setPauseClaimingDerivative","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_pauseClaimingLand","type":"bool"}],"name":"setPauseClaimingLand","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_pauseClaimingPainting","type":"bool"}],"name":"setPauseClaimingPainting","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_isPausedClaimingRoyal","type":"bool"}],"name":"setPauseClaimingRoyal","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_pauseClaimingStatteute","type":"bool"}],"name":"setPauseClaimingStatteute","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_pauseClaimingToy","type":"bool"}],"name":"setPauseClaimingToy","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":"index","type":"uint256"}],"name":"tokenByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenOfOwnerByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","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"},{"internalType":"uint256","name":"collectionID","type":"uint256"}],"name":"totalRoyalBalanceOf","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":"uint256","name":"x","type":"uint256"},{"internalType":"uint256","name":"y","type":"uint256"},{"internalType":"address","name":"collectionAddrsOfDerMetadata","type":"address"},{"internalType":"uint256","name":"tokenID","type":"uint256"}],"name":"updateLandDerivativeMetaData","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"x","type":"uint256"},{"internalType":"uint256","name":"y","type":"uint256"},{"internalType":"uint256","name":"collectionIDOfRoyalMetadata","type":"uint256"},{"internalType":"uint256","name":"tokenID","type":"uint256"}],"name":"updateLandRoyalMetaData","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
608060405234801561001057600080fd5b50615bad80620000216000396000f3fe6080604052600436106103ef5760003560e01c806381c7707311610208578063c31dbf9611610118578063d678a41f116100ab578063e8a3d4851161007a578063e8a3d48514610b73578063e985e9c514610b88578063eacc74b814610ba8578063edd57e3214610bc8578063f2fde38b14610be8576103ef565b8063d678a41f14610b09578063d6e7d67b14610b29578063e6031d1b14610b3e578063e7ce6c1814610b53576103ef565b8063c8d6ab56116100e7578063c8d6ab5614610a7b578063caa6626014610a9b578063cbc67d3a14610abb578063d15a271b14610ae9576103ef565b8063c31dbf9614610a08578063c349026314610a28578063c616fd4c14610a3b578063c87b56dd14610a5b576103ef565b8063a22cb4651161019b578063b607a0aa1161016a578063b607a0aa1461097e578063b88d4fde14610993578063b9bc6ead146109b3578063c0e72740146109d3578063c177273d146109e8576103ef565b8063a22cb46514610909578063ab531efd14610929578063b12df58e14610949578063b2bdfa7b14610969576103ef565b8063938e3d7b116101d7578063938e3d7b1461089457806395d89b41146108b45780639de4ff15146108c9578063a05672f1146108e9576103ef565b806381c770731461081f57806388f62c121461083f5780638a3ac44d1461085f57806391ead87314610874576103ef565b80633ccfd60b116103035780635bf0234d1161029657806370a082311161026557806370a082311461079557806374a9a21b146107b55780637e749897146107d55780637efa391a146107ea5780638129fc1c1461080a576103ef565b80635bf0234d1461072b57806360a6fb8f146107405780636352211e146107605780636c0360eb14610780576103ef565b80634d8980f1116102d25780634d8980f1146106b85780634f6ccce7146106d857806355f804b3146106f85780635669057d14610718576103ef565b80633ccfd60b1461064e57806342842e0e146106635780634587b3ee146106835780634874340014610698576103ef565b80631b1c9c231161038657806322751f871161035557806322751f87146105a0578063237abb89146105ce57806323b872dd146105ee578063283315951461060e5780632f745c591461062e576103ef565b80631b1c9c231461052b5780631c5822fe1461054b5780631f3221b41461056057806320940d7a14610580576103ef565b8063095ea7b3116103c2578063095ea7b31461049b5780630b394838146104bb57806314d44ea0146104e857806318160ddd14610516576103ef565b806301ffc9a7146103f457806306fdde031461042a57806307f0db251461044c578063081812fc1461046e575b600080fd5b34801561040057600080fd5b5061041461040f366004614cd1565b610c08565b6040516104219190615044565b60405180910390f35b34801561043657600080fd5b5061043f610c2b565b604051610421919061504f565b34801561045857600080fd5b5061046c610467366004614b02565b610cc2565b005b34801561047a57600080fd5b5061048e610489366004614e4e565b610d55565b6040516104219190614fbe565b3480156104a757600080fd5b5061046c6104b6366004614aa3565b610d98565b3480156104c757600080fd5b506104db6104d6366004614e4e565b610e30565b6040516104219190615a65565b3480156104f457600080fd5b50610508610503366004614e7e565b610e42565b60405161042192919061502b565b34801561052257600080fd5b506104db610e85565b34801561053757600080fd5b5061046c610546366004614b02565b610e96565b34801561055757600080fd5b50610414610f14565b34801561056c57600080fd5b5061046c61057b366004614cb1565b610f24565b34801561058c57600080fd5b5061046c61059b366004614b02565b610f6c565b3480156105ac57600080fd5b506105c06105bb366004614e4e565b610fea565b604051610421929190615a6e565b3480156105da57600080fd5b506104146105e9366004614e4e565b611003565b3480156105fa57600080fd5b5061046c610609366004614988565b611018565b34801561061a57600080fd5b5061046c610629366004614b02565b611050565b34801561063a57600080fd5b506104db610649366004614aa3565b6110d4565b34801561065a57600080fd5b5061046c611105565b34801561066f57600080fd5b5061046c61067e366004614988565b6111b3565b34801561068f57600080fd5b506104146111ce565b3480156106a457600080fd5b5061048e6106b3366004614e4e565b6111de565b3480156106c457600080fd5b5061046c6106d3366004614cb1565b61132e565b3480156106e457600080fd5b506104db6106f3366004614e4e565b611376565b34801561070457600080fd5b5061046c610713366004614d09565b611392565b61046c610726366004614edd565b6113ff565b34801561073757600080fd5b5061041461182f565b34801561074c57600080fd5b5061046c61075b366004614cb1565b61183f565b34801561076c57600080fd5b5061048e61077b366004614e4e565b61187c565b34801561078c57600080fd5b5061043f6118aa565b3480156107a157600080fd5b506104db6107b0366004614918565b61190b565b3480156107c157600080fd5b5061048e6107d0366004614e4e565b611954565b3480156107e157600080fd5b5061041461196f565b3480156107f657600080fd5b5061046c610805366004614b4b565b61197f565b34801561081657600080fd5b5061046c611aeb565b34801561082b57600080fd5b506104db61083a366004614aa3565b611bfe565b34801561084b57600080fd5b5061046c61085a366004614bbb565b611dd7565b34801561086b57600080fd5b50610414611fc0565b34801561088057600080fd5b5061046c61088f366004614b02565b611fc9565b3480156108a057600080fd5b5061046c6108af366004614d09565b612047565b3480156108c057600080fd5b5061043f61207d565b3480156108d557600080fd5b5061046c6108e4366004614cb1565b6120de565b3480156108f557600080fd5b50610414610904366004614de7565b612126565b34801561091557600080fd5b5061046c610924366004614a72565b612185565b34801561093557600080fd5b506104db610944366004614e7e565b612253565b34801561095557600080fd5b5061043f610964366004614e7e565b612263565b34801561097557600080fd5b5061048e6123fe565b34801561098a57600080fd5b5061041461240d565b34801561099f57600080fd5b5061046c6109ae3660046149c8565b61241d565b3480156109bf57600080fd5b5061046c6109ce366004614cb1565b612456565b3480156109df57600080fd5b5061043f61249e565b3480156109f457600080fd5b506104db610a03366004614aa3565b61252c565b348015610a1457600080fd5b5061046c610a23366004614b02565b61255a565b61046c610a36366004614e7e565b6125de565b348015610a4757600080fd5b506105c0610a56366004614ace565b6129db565b348015610a6757600080fd5b5061043f610a76366004614e4e565b612ceb565b348015610a8757600080fd5b506104db610a96366004614aa3565b612e31565b348015610aa757600080fd5b5061046c610ab6366004614cb1565b612ee2565b348015610ac757600080fd5b50610adb610ad6366004614e4e565b612f2a565b604051610421929190615a4a565b348015610af557600080fd5b5061046c610b04366004614f08565b612f70565b348015610b1557600080fd5b5061046c610b24366004614cb1565b613288565b348015610b3557600080fd5b506104146132d0565b348015610b4a57600080fd5b506104146132e0565b348015610b5f57600080fd5b506104db610b6e366004614e7e565b6132f0565b348015610b7f57600080fd5b5061043f61339b565b348015610b9457600080fd5b50610414610ba3366004614950565b6133fc565b348015610bb457600080fd5b5061046c610bc3366004614e9f565b61342a565b348015610bd457600080fd5b506105c0610be3366004614e4e565b61360d565b348015610bf457600080fd5b5061046c610c03366004614918565b61363f565b6001600160e01b0319811660009081526033602052604090205460ff165b919050565b606a8054604080516020601f6002600019610100600188161502019095169490940493840181900481028201810190925282815260609390929091830182828015610cb75780601f10610c8c57610100808354040283529160200191610cb7565b820191906000526020600020905b815481529060010190602001808311610c9a57829003601f168201915b505050505090505b90565b609d546001600160a01b03163314610cf55760405162461bcd60e51b8152600401610cec90615738565b60405180910390fd5b60005b81811015610d4f57600160b16000868685818110610d1257fe5b9050602002016020810190610d279190614918565b6001600160a01b03168152602081019190915260400160002080549091019055600101610cf8565b50505050565b6000610d60826136b1565b610d7c5760405162461bcd60e51b8152600401610cec906156a0565b506000908152606860205260409020546001600160a01b031690565b6000610da38261187c565b9050806001600160a01b0316836001600160a01b03161415610dd75760405162461bcd60e51b8152600401610cec90615894565b806001600160a01b0316610de96136c4565b6001600160a01b03161480610e055750610e0581610ba36136c4565b610e215760405162461bcd60e51b8152600401610cec90615484565b610e2b83836136c8565b505050565b60ad6020526000908152604090205481565b60ac6020528160005260406000208181548110610e5b57fe5b6000918252602090912060029091020180546001909101546001600160a01b039091169250905082565b6000610e916066613736565b905090565b609d546001600160a01b03163314610ec05760405162461bcd60e51b8152600401610cec90615738565b60005b81811015610d4f57600060b16000868685818110610edd57fe5b9050602002016020810190610ef29190614918565b6001600160a01b03168152602081019190915260400160002055600101610ec3565b609d54600160a81b900460ff1681565b609d546001600160a01b03163314610f4e5760405162461bcd60e51b8152600401610cec90615738565b609d8054911515600160b81b0260ff60b81b19909216919091179055565b609d546001600160a01b03163314610f965760405162461bcd60e51b8152600401610cec90615738565b60005b81811015610d4f57600060a36000868685818110610fb357fe5b9050602002016020810190610fc89190614918565b6001600160a01b03168152602081019190915260400160002055600101610f99565b60ab602052600090815260409020805460019091015482565b60a16020526000908152604090205460ff1681565b6110296110236136c4565b82613741565b6110455760405162461bcd60e51b8152600401610cec9061590c565b610e2b8383836137c6565b609d546001600160a01b0316331461107a5760405162461bcd60e51b8152600401610cec90615738565b60005b81811015610d4f57600160a2600086868581811061109757fe5b90506020020160208101906110ac9190614918565b6001600160a01b0316815260208101919091526040016000208054909101905560010161107d565b6001600160a01b03821660009081526065602052604081206110fc908363ffffffff6138e616565b90505b92915050565b609d546001600160a01b0316331461112f5760405162461bcd60e51b8152600401610cec90615738565b609d546040516000916001600160a01b031690479061114d90610cbf565b60006040518083038185875af1925050503d806000811461118a576040519150601f19603f3d011682016040523d82523d6000602084013e61118f565b606091505b50509050806111b05760405162461bcd60e51b8152600401610cec906159c4565b50565b610e2b8383836040518060200160405280600081525061241d565b609d54600160b81b900460ff1681565b6040516331a9108f60e11b815260009030908190636352211e90611206908690600401615a65565b60206040518083038186803b15801561121e57600080fd5b505afa92505050801561124e575060408051601f3d908101601f1916820190925261124b91810190614934565b60015b611325576040516000815260443d101561126a57506000611305565b60046000803e60005160e01c6308c379a0811461128b576000915050611305565b60043d036004833e81513d60248201116001600160401b03821117156112b657600092505050611305565b80830180516001600160401b038111156112d7576000945050505050611305565b8060208301013d86018111156112f557600095505050505050611305565b601f01601f191660405250925050505b80611310575061131b565b600092505050610c26565b3d6000803e3d6000fd5b9150610c269050565b609d546001600160a01b031633146113585760405162461bcd60e51b8152600401610cec90615738565b609d8054911515600160a81b0260ff60a81b19909216919091179055565b60008061138a60668463ffffffff6138f216565b509392505050565b609d546001600160a01b031633146113bc5760405162461bcd60e51b8152600401610cec90615738565b6113fb82828080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061391092505050565b5050565b60a554600160a01b900460ff16156114295760405162461bcd60e51b8152600401610cec906159ec565b600081815260b06020526040902054831180156114565750600081815260b0602052604090206001015482115b80156114735750600081815260b060205260409020600201548311155b80156114905750600081815260b060205260409020600301548211155b6114ac5760405162461bcd60e51b8152600401610cec90615a23565b600081815260ae60205260408120546001600160a01b031690600483108015906114d7575060068311155b156114f2575033600090815260b16020526040902054611676565b6001600160a01b0382167372541ad75e05bc77c7a92304225937a8f665337214156115ce5760038311611535575033600090815260a360205260409020546115c9565b6040516370a0823160e01b815282906001600160a01b038216906370a0823190611563903390600401614fbe565b60206040518083038186803b15801561157b57600080fd5b505afa15801561158f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115b39190614e66565b33600090815260a3602052604090205490039150505b611676565b34666a94d74f430000146115f45760405162461bcd60e51b8152600401610cec90615338565b6040516370a0823160e01b815282906001600160a01b038216906370a0823190611622903390600401614fbe565b60206040518083038186803b15801561163a57600080fd5b505afa15801561164e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116729190614e66565b9150505b600081116116965760405162461bcd60e51b8152600401610cec906150db565b33600090815260a96020908152604080832086845290915290205481116116cf5760405162461bcd60e51b8152600401610cec906158d5565b60006116db8686612253565b90506116eb338261271001613923565b61170161271082016116fc8161393d565b613a14565b83158061170e5750836001145b806117195750836002145b806117245750836003145b156117655760005b600481101561175f5733600090815260a9602090815260408083208484529091529020805460019081019091550161172c565b50611827565b6001600160a01b038316600090815260af60209081526040918290208054835181840281018401909452808452606093928301828280156117c557602002820191906000526020600020905b8154815260200190600101908083116117b1575b50939450600093505050505b81518110156118245733600090815260a96020526040812083519091908490849081106117fa57fe5b602090810291909101810151825281019190915260400160002080546001908101909155016117d1565b50505b505050505050565b609d54600160b01b900460ff1681565b609d546001600160a01b031633146118695760405162461bcd60e51b8152600401610cec90615738565b60a7805460ff1916911515919091179055565b60006110ff82604051806060016040528060298152602001615b4f602991396066919063ffffffff613a5816565b606d8054604080516020601f6002600019610100600188161502019095169490940493840181900481028201810190925282815260609390929091830182828015610cb75780601f10610c8c57610100808354040283529160200191610cb7565b60006001600160a01b0382166119335760405162461bcd60e51b8152600401610cec906154e1565b6001600160a01b03821660009081526065602052604090206110ff90613736565b60ae602052600090815260409020546001600160a01b031681565b60a554600160b01b900460ff1681565b609d546001600160a01b031633146119a95760405162461bcd60e51b8152600401610cec90615738565b60005b818110156118275760af600060ae60008989868181106119c857fe5b602090810292909201358352508181019290925260409081016000908120546001600160a01b031684529183019390935291018120611a06916146e0565b838382818110611a1257fe5b9050602002016020810190611a279190614918565b60ae6000888885818110611a3757fe5b90506020020135815260200190815260200160002060006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060af6000858584818110611a8057fe5b9050602002016020810190611a959190614918565b6001600160a01b03166001600160a01b03168152602001908152602001600020868683818110611ac157fe5b835460018082018655600095865260209586902092909502939093013592019190915550016119ac565b600054610100900460ff1680611b045750611b04613a6f565b80611b12575060005460ff16155b611b2e5760405162461bcd60e51b8152600401610cec9061552b565b600054610100900460ff16158015611b59576000805460ff1961ff0019909116610100171660011790555b611ba560405180604001604052806009815260200168135e5411941b185b9960ba1b81525060405180604001604052806009815260200168135e5411941b185b9960ba1b815250613a80565b609d80546001600160a01b031990811633179091556000609a5561012c609b55610190609c5560a580549091167372541ad75e05bc77c7a92304225937a8f665337217905580156111b0576000805461ff001916905550565b60a75460009060ff1680611c555750600782108015611c5557506001600160a01b038316600090815260a36020526040902054151580611c5557506001600160a01b038316600090815260b1602052604090205415155b15611d3d57600080805b60a854811015611d3257600081815260ae60205260409020546001600160a01b03908116908316811415611c935750611d2a565b8092506007821015611ca55750611d2a565b6040516370a0823160e01b815281906001600160a01b038216906370a0823190611cd3908b90600401614fbe565b60206040518083038186803b158015611ceb57600080fd5b505afa158015611cff573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d239190614e66565b8501945050505b600101611c5f565b5081925050506110ff565b600082815260ae6020526040908190205490516370a0823160e01b81526001600160a01b0390911690819081906370a0823190611d7e908890600401614fbe565b60206040518083038186803b158015611d9657600080fd5b505afa158015611daa573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611dce9190614e66565b925050506110ff565b609d546001600160a01b03163314611e015760405162461bcd60e51b8152600401610cec90615738565b611e096146fe565b60005b82811015611fb1578c8c82818110611e2057fe5b845160209091029290920135909152508a8a82818110611e3c57fe5b9050602002013582600001516020018181525050888882818110611e5c57fe5b6020858101519102929092013590915250868682818110611e7957fe5b6020858101805192820294909401359181019190915260a854600090815260b08252604090208551805182558201516001820155925180516002850155015160039092019190915550848482818110611ece57fe5b9050602002016020810190611ee39190614918565b60a88054600090815260ae6020526040902080546001600160a01b0319166001600160a01b0393909316929092179091555415801590611f26575060a854600114155b8015611f35575060a854600214155b8015611f44575060a854600314155b15611f9f5760af6000868684818110611f5957fe5b9050602002016020810190611f6e9190614918565b6001600160a01b03168152602080820192909252604001600090812060a85481546001810183559183529290912001555b60a88054600190810190915501611e0c565b50505050505050505050505050565b60a75460ff1681565b609d546001600160a01b03163314611ff35760405162461bcd60e51b8152600401610cec90615738565b60005b81811015610d4f57600060a2600086868581811061201057fe5b90506020020160208101906120259190614918565b6001600160a01b03168152602081019190915260400160002055600101611ff6565b609d546001600160a01b031633146120715760405162461bcd60e51b8152600401610cec90615738565b610e2b60a68383614723565b606b8054604080516020601f6002600019610100600188161502019095169490940493840181900481028201810190925282815260609390929091830182828015610cb75780601f10610c8c57610100808354040283529160200191610cb7565b609d546001600160a01b031633146121085760405162461bcd60e51b8152600401610cec90615738565b609d8054911515600160b01b0260ff60b01b19909216919091179055565b805151825160009110801561214657508160000151602001518360200151115b80156121585750602082015151835111155b80156121705750816020015160200151836020015111155b1561217d575060016110ff565b5060006110ff565b61218d6136c4565b6001600160a01b0316826001600160a01b031614156121be5760405162461bcd60e51b8152600401610cec906153a4565b80606960006121cb6136c4565b6001600160a01b03908116825260208083019390935260409182016000908120918716808252919093529120805460ff19169215159290921790915561220f6136c4565b6001600160a01b03167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31836040516122479190615044565b60405180910390a35050565b6000198201606402810192915050565b600082815260ae60205260409020546060906001600160a01b0316600784101561229d5750506040805160208101909152600081526110ff565b60405163c87b56dd60e01b815281906001600160a01b0382169063c87b56dd906122cb908790600401615a65565b60006040518083038186803b1580156122e357600080fd5b505afa92505050801561231857506040513d6000823e601f3d908101601f191682016040526123159190810190614d72565b60015b6123f4576040516000815260443d1015612334575060006123cf565b60046000803e60005160e01c6308c379a081146123555760009150506123cf565b60043d036004833e81513d60248201116001600160401b0382111715612380576000925050506123cf565b80830180516001600160401b038111156123a15760009450505050506123cf565b8060208301013d86018111156123bf576000955050505050506123cf565b601f01601f191660405250925050505b806123da575061131b565b6040518060200160405280600081525093505050506110ff565b92506110ff915050565b609d546001600160a01b031681565b60a554600160a81b900460ff1681565b61242e6124286136c4565b83613741565b61244a5760405162461bcd60e51b8152600401610cec9061590c565b610d4f84848484613b1e565b609d546001600160a01b031633146124805760405162461bcd60e51b8152600401610cec90615738565b60a58054911515600160a81b0260ff60a81b19909216919091179055565b60a6805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156125245780601f106124f957610100808354040283529160200191612524565b820191906000526020600020905b81548152906001019060200180831161250757829003601f168201915b505050505081565b60af602052816000526040600020818154811061254557fe5b90600052602060002001600091509150505481565b609d546001600160a01b031633146125845760405162461bcd60e51b8152600401610cec90615738565b60005b81811015610d4f57600160a360008686858181106125a157fe5b90506020020160208101906125b69190614918565b6001600160a01b03168152602081019190915260400160002080549091019055600101612587565b60018210156125ff5760405162461bcd60e51b8152600401610cec906153db565b60038211156126205760405162461bcd60e51b8152600401610cec906153db565b816001141561265357609d54600160a81b900460ff16156126535760405162461bcd60e51b8152600401610cec90615994565b816002141561268657609d54600160b01b900460ff16156126865760405162461bcd60e51b8152600401610cec90615669565b81600314156126b957609d54600160b81b900460ff16156126b95760405162461bcd60e51b8152600401610cec9061511f565b60006126c53384613b51565b905082600114156126e65733600090815260a2602052604090205401612701565b82600214156127015733600090815260a36020526040902054015b6000600184141561274257336000908152609e6020526040902054830182101561273d5760405162461bcd60e51b8152600401610cec90615579565b6127a5565b836002141561277c57336000908152609f6020526040902054830182101561273d5760405162461bcd60e51b8152600401610cec906150a4565b83600314156127a557828210156127a55760405162461bcd60e51b8152600401610cec906152ca565b60005b838160ff16101561283e5784600114156127db576127c66097613d8e565b609a546127d36097613d97565b01915061281f565b84600214156127fb576127ee6098613d8e565b609b546127d36098613d97565b846003141561281f5761280e6099613d8e565b609c5461281b6099613d97565b0191505b6128293383613923565b612836826116fc8461393d565b6001016127a8565b50836001141561286257336000908152609e60205260409020805484019055612881565b836002141561288157336000908152609f602052604090208054840190555b6000821180156128915750836003145b15610d4f5760005b60a5546040516370a0823160e01b81526001600160a01b03909116906370a08231906128c9903390600401614fbe565b60206040518083038186803b1580156128e157600080fd5b505afa1580156128f5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129199190614e66565b8160ff1610156129d45760a554604051632f745c5960e01b81526000916001600160a01b031690632f745c5990612956903390869060040161500f565b60206040518083038186803b15801561296e57600080fd5b505afa158015612982573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129a69190614e66565b90506105cc81116129cb57600081815260a160205260409020805460ff191660011790555b50600101612899565b5050505050565b60a7546000908190819060ff1680612a365750600784108015612a3657506001600160a01b038616600090815260a36020526040902054151580612a3657506001600160a01b038616600090815260b1602052604090205415155b15612c4057600080805b60a854811015612c3857600081815260ae60205260409020546001600160a01b03908116908316811415612a745750612c30565b8092506007821015612a865750612c30565b6040516370a0823160e01b815281906001600160a01b038216906370a0823190612ab4908e90600401614fbe565b60206040518083038186803b158015612acc57600080fd5b505afa158015612ae0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b049190614e66565b8501945089600186031015612b1a575050612c30565b6040516370a0823160e01b81526000906001600160a01b038316906370a0823190612b49908f90600401614fbe565b60206040518083038186803b158015612b6157600080fd5b505afa158015612b75573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b999190614e66565b604051632f745c5960e01b81529087038c0391506001600160a01b03831690632f745c5990612bce908f90859060040161502b565b60206040518083038186803b158015612be657600080fd5b505afa158015612bfa573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c1e9190614e66565b939850929650612ce395505050505050565b600101612a40565b505050612ce1565b600084815260ae602052604090819020549051632f745c5960e01b81526001600160a01b039091169081908190632f745c5990612c83908b908b9060040161502b565b60206040518083038186803b158015612c9b57600080fd5b505afa158015612caf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612cd39190614e66565b8695509350612ce392505050565b505b935093915050565b6060612cf6826136b1565b612d125760405162461bcd60e51b8152600401610cec906157b6565b6000828152606c602090815260409182902080548351601f6002600019610100600186161502019093169290920491820184900484028101840190945280845260609392830182828015612da75780601f10612d7c57610100808354040283529160200191612da7565b820191906000526020600020905b815481529060010190602001808311612d8a57829003601f168201915b505050505090506060612db86118aa565b9050805160001415612dcc57509050610c26565b815115612dfe578082604051602001612de6929190614f90565b60405160208183030381529060405292505050610c26565b80612e0885613d9b565b604051602001612e19929190614f90565b60405160208183030381529060405292505050919050565b6000806001831080612e435750600383115b15612e4f5790506110ff565b6000612e5b8585613b51565b90508360011415612e97576001600160a01b038516600090815260a26020908152604080832054609e909252909120549101908103915061138a565b8360021415612ed1576001600160a01b038516600090815260a36020908152604080832054609f909252909120549101908103915061138a565b836003141561138a57949350505050565b609d546001600160a01b03163314612f0c5760405162461bcd60e51b8152600401610cec90615738565b60a58054911515600160a01b0260ff60a01b19909216919091179055565b60b0602090815260009182526040918290208251808401845281548152600182015481840152835180850190945260028201548452600390910154918301919091529082565b60a554600160a81b900460ff1615612f9a5760405162461bcd60e51b8152600401610cec90615301565b6000612fa68585612253565b905033612fb6612710830161187c565b6001600160a01b031614612fdc5760405162461bcd60e51b8152600401610cec906155b0565b60a75460ff16158015612ffc575033600090815260a36020526040902054155b8015613015575033600090815260b16020526040902054155b1561309d57600083815260b06020526040902054851180156130475750600083815260b0602052604090206001015484115b80156130645750600083815260b060205260409020600201548511155b80156130815750600083815260b060205260409020600301548411155b61309d5760405162461bcd60e51b8152600401610cec90615a23565b600083815260ae60205260409020546001600160a01b031660078410156130d65760405162461bcd60e51b8152600401610cec9061584a565b6040516331a9108f60e11b8152819033906001600160a01b03831690636352211e90613106908890600401615a65565b60206040518083038186803b15801561311e57600080fd5b505afa158015613132573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131569190614934565b6001600160a01b03161461317c5760405162461bcd60e51b8152600401610cec90615805565b6001600160a01b038216600090815260aa6020908152604080832087845290915290205460ff16156131c05760405162461bcd60e51b8152600401610cec9061525c565b6127108301600090815260ab60209081526040808320805480855260ae8452828520546001600160a01b03908116865260aa80865284872060019485015488528652848720805460ff19908116909155918916875285528386208a875290945291909320805490921690921790556132366147a1565b86815260208082018781526127108701600090815260ab8352604080822085518155925160019093019290925560ad835281812081905560ac909252812061327d916147bb565b505050505050505050565b609d546001600160a01b031633146132b25760405162461bcd60e51b8152600401610cec90615738565b60a58054911515600160b01b0260ff60b01b19909216919091179055565b60a554600160a01b900460ff1681565b609d54600160a01b900460ff1681565b6000806132fb6146fe565b6133036147a1565b8581526020810185905260005b60a85481101561338c57600081815260b0602090815260409182902082516080810184528154818501908152600183015460608301528152835180850190945260028201548452600390910154838301529081019190915292506133748284612126565b156133845793506110ff92505050565b600101613310565b50620186a09695505050505050565b60a68054604080516020601f6002600019610100600188161502019095169490940493840181900481028201810190925282815260609390929091830182828015610cb75780601f10610c8c57610100808354040283529160200191610cb7565b6001600160a01b03918216600090815260696020908152604080832093909416825291909152205460ff1690565b60a554600160b01b900460ff16156134545760405162461bcd60e51b8152600401610cec9061544d565b60006134608585612253565b905033613470612710830161187c565b6001600160a01b0316146134965760405162461bcd60e51b8152600401610cec906155b0565b6127108101600090815260ab60205260409020541515806134cc57506127108101600090815260ab602052604090206001015415155b6134e85760405162461bcd60e51b8152600401610cec90615293565b6040516331a9108f60e11b8152839033906001600160a01b03831690636352211e90613518908790600401615a65565b60206040518083038186803b15801561353057600080fd5b505afa158015613544573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906135689190614934565b6001600160a01b03161461358e5760405162461bcd60e51b8152600401610cec90615805565b6135966147dc565b6001600160a01b039485168152602080820194855261271093909301600081815260ac855260408082208054600180820183559184528784209551600290910290950180546001600160a01b03191695909916949094178855955196830196909655855260ad909252509120805490910190555050565b6000806064830460010191506064838161362357fe5b0661362f576001820391505b5091600019830160640290910390565b609d546001600160a01b031633146136695760405162461bcd60e51b8152600401610cec90615738565b6001600160a01b03811661368f5760405162461bcd60e51b8152600401610cec906151a8565b609d80546001600160a01b0319166001600160a01b0392909216919091179055565b60006110ff60668363ffffffff613e6c16565b3390565b600081815260686020526040902080546001600160a01b0319166001600160a01b03841690811790915581906136fd8261187c565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b60006110ff82613d97565b600061374c826136b1565b6137685760405162461bcd60e51b8152600401610cec90615401565b60006137738361187c565b9050806001600160a01b0316846001600160a01b031614806137ae5750836001600160a01b03166137a384610d55565b6001600160a01b0316145b806137be57506137be81856133fc565b949350505050565b826001600160a01b03166137d98261187c565b6001600160a01b0316146137ff5760405162461bcd60e51b8152600401610cec9061576d565b6001600160a01b0382166138255760405162461bcd60e51b8152600401610cec90615360565b613830838383613e78565b61383b6000826136c8565b6001600160a01b0383166000908152606560205260409020613863908263ffffffff613f1516565b506001600160a01b038216600090815260656020526040902061388c908263ffffffff613f2116565b5061389f6066828463ffffffff613f2d16565b5080826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b60006110fc8383613f43565b60008080806139018686613f88565b909450925050505b9250929050565b80516113fb90606d9060208401906147f3565b6113fb828260405180602001604052806000815250613fe4565b60608161396257506040805180820190915260018152600360fc1b6020820152610c26565b8160005b811561397a57600101600a82049150613966565b6060816001600160401b038111801561399257600080fd5b506040519080825280601f01601f1916602001820160405280156139bd576020820181803683370190505b50905060001982015b8515613a0b57600a860660300160f81b828280600190039350815181106139e957fe5b60200101906001600160f81b031916908160001a905350600a860495506139c6565b50949350505050565b613a1d826136b1565b613a395760405162461bcd60e51b8152600401610cec906156ec565b6000828152606c602090815260409091208251610e2b928401906147f3565b6000613a65848484614017565b90505b9392505050565b6000613a7a30614076565b15905090565b600054610100900460ff1680613a995750613a99613a6f565b80613aa7575060005460ff16155b613ac35760405162461bcd60e51b8152600401610cec9061552b565b600054610100900460ff16158015613aee576000805460ff1961ff0019909116610100171660011790555b613af661407c565b613afe6140fe565b613b08838361417c565b8015610e2b576000805461ff0019169055505050565b613b298484846137c6565b613b3584848484614242565b610d4f5760405162461bcd60e51b8152600401610cec90615156565b60a5546040516370a0823160e01b815260009182916001600160a01b03909116906370a0823190613b86908790600401614fbe565b60206040518083038186803b158015613b9e57600080fd5b505afa158015613bb2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613bd69190614e66565b613be15790506110ff565b6000808460011415613bfb57506112b69050611362613c24565b8460021415613c1257506113639050611388613c24565b8460031415613c245750600190506105cc5b60005b60a5546040516370a0823160e01b81526001600160a01b03909116906370a0823190613c57908a90600401614fbe565b60206040518083038186803b158015613c6f57600080fd5b505afa158015613c83573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613ca79190614e66565b811015613d835760a554604051632f745c5960e01b81526000916001600160a01b031690632f745c5990613ce1908b90869060040161502b565b60206040518083038186803b158015613cf957600080fd5b505afa158015613d0d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613d319190614e66565b9050838110158015613d435750828111155b15613d7a578660031415613d7357600081815260a1602052604090205460ff16613d6e576001909401935b613d7a565b6001909401935b50600101613c27565b509195945050505050565b80546001019055565b5490565b606081613dc057506040805180820190915260018152600360fc1b6020820152610c26565b8160005b8115613dd857600101600a82049150613dc4565b6060816001600160401b0381118015613df057600080fd5b506040519080825280601f01601f191660200182016040528015613e1b576020820181803683370190505b50859350905060001982015b8315613a0b57600a840660300160f81b82828060019003935081518110613e4a57fe5b60200101906001600160f81b031916908160001a905350600a84049350613e27565b60006110fc8383614327565b612710811115613f0a57613e8a6147a1565b6000808252602080830182815284835260ab8083526040808520805480875260ae8652828720546001600160a01b0316875260aa86528287206001830180548952908752838820805460ff191690558988529386528751909155925190915560ad835280842084905560ac9092529082209091613f0791906147bb565b50505b610e2b838383610e2b565b60006110fc838361433f565b60006110fc8383614405565b6000613a6584846001600160a01b038516614447565b81546000908210613f665760405162461bcd60e51b8152600401610cec90615062565b826000018281548110613f7557fe5b9060005260206000200154905092915050565b815460009081908310613fad5760405162461bcd60e51b8152600401610cec906155f2565b6000846000018481548110613fbe57fe5b906000526020600020906002020190508060000154816001015492509250509250929050565b613fee83836144de565b613ffb6000848484614242565b610e2b5760405162461bcd60e51b8152600401610cec90615156565b600082815260018401602052604081205482816140475760405162461bcd60e51b8152600401610cec919061504f565b5084600001600182038154811061405a57fe5b9060005260206000209060020201600101549150509392505050565b3b151590565b600054610100900460ff16806140955750614095613a6f565b806140a3575060005460ff16155b6140bf5760405162461bcd60e51b8152600401610cec9061552b565b600054610100900460ff161580156140ea576000805460ff1961ff0019909116610100171660011790555b80156111b0576000805461ff001916905550565b600054610100900460ff16806141175750614117613a6f565b80614125575060005460ff16155b6141415760405162461bcd60e51b8152600401610cec9061552b565b600054610100900460ff1615801561416c576000805460ff1961ff0019909116610100171660011790555b6140ea6301ffc9a760e01b6145ae565b600054610100900460ff16806141955750614195613a6f565b806141a3575060005460ff16155b6141bf5760405162461bcd60e51b8152600401610cec9061552b565b600054610100900460ff161580156141ea576000805460ff1961ff0019909116610100171660011790555b82516141fd90606a9060208601906147f3565b50815161421190606b9060208501906147f3565b506142226380ac58cd60e01b6145ae565b614232635b5e139f60e01b6145ae565b613b0863780e9d6360e01b6145ae565b6000614256846001600160a01b0316614076565b614262575060016137be565b60606142f0630a85bd0160e11b6142776136c4565b88878760405160240161428d9493929190614fd2565b604051602081830303815290604052906001600160e01b0319166020820180516001600160e01b038381831617835250505050604051806060016040528060328152602001615b1d603291396001600160a01b038816919063ffffffff6145fd16565b90506000818060200190518101906143089190614ced565b6001600160e01b031916630a85bd0160e11b1492505050949350505050565b60009081526001919091016020526040902054151590565b600081815260018301602052604081205480156143fb578354600019808301919081019060009087908390811061437257fe5b906000526020600020015490508087600001848154811061438f57fe5b6000918252602080832090910192909255828152600189810190925260409020908401905586548790806143bf57fe5b600190038181906000526020600020016000905590558660010160008781526020019081526020016000206000905560019450505050506110ff565b60009150506110ff565b60006144118383614327565b61217d575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556110ff565b6000828152600184016020526040812054806144ac575050604080518082018252838152602080820184815286546001818101895560008981528481209551600290930290950191825591519082015586548684528188019092529290912055613a68565b828560000160018303815481106144bf57fe5b9060005260206000209060020201600101819055506000915050613a68565b6001600160a01b0382166145045760405162461bcd60e51b8152600401610cec90615634565b61450d816136b1565b1561452a5760405162461bcd60e51b8152600401610cec90615225565b61453660008383613e78565b6001600160a01b038216600090815260656020526040902061455e908263ffffffff613f2116565b506145716066828463ffffffff613f2d16565b5060405181906001600160a01b038416906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b6001600160e01b031980821614156145d85760405162461bcd60e51b8152600401610cec906151ee565b6001600160e01b0319166000908152603360205260409020805460ff19166001179055565b6060613a6584846000858561461185614076565b61462d5760405162461bcd60e51b8152600401610cec9061595d565b60006060866001600160a01b0316858760405161464a9190614f74565b60006040518083038185875af1925050503d8060008114614687576040519150601f19603f3d011682016040523d82523d6000602084013e61468c565b606091505b509150915061469c8282866146a7565b979650505050505050565b606083156146b6575081613a68565b8251156146c65782518084602001fd5b8160405162461bcd60e51b8152600401610cec919061504f565b50805460008255906000526020600020908101906111b09190614861565b60405180604001604052806147116147a1565b815260200161471e6147a1565b905290565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106147645782800160ff19823516178555614791565b82800160010185558215614791579182015b82811115614791578235825591602001919060010190614776565b5061479d929150614861565b5090565b604051806040016040528060008152602001600081525090565b50805460008255600202906000526020600020908101906111b0919061487b565b604080518082019091526000808252602082015290565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061483457805160ff1916838001178555614791565b82800160010185558215614791579182015b82811115614791578251825591602001919060010190614846565b610cbf91905b8082111561479d5760008155600101614867565b610cbf91905b8082111561479d5780546001600160a01b031916815560006001820155600201614881565b60008083601f8401126148b7578182fd5b5081356001600160401b038111156148cd578182fd5b602083019150836020808302850101111561390957600080fd5b6000604082840312156148f8578081fd5b6149026040615a7c565b9050813581526020820135602082015292915050565b600060208284031215614929578081fd5b8135613a6881615af1565b600060208284031215614945578081fd5b8151613a6881615af1565b60008060408385031215614962578081fd5b823561496d81615af1565b9150602083013561497d81615af1565b809150509250929050565b60008060006060848603121561499c578081fd5b83356149a781615af1565b925060208401356149b781615af1565b929592945050506040919091013590565b600080600080608085870312156149dd578081fd5b84356149e881615af1565b935060208501356149f881615af1565b92506040850135915060608501356001600160401b03811115614a19578182fd5b80860187601f820112614a2a578283fd5b80359150614a3f614a3a83615aa2565b615a7c565b828152886020848401011115614a53578384fd5b8260208301602083013791820160200192909252939692955090935050565b60008060408385031215614a84578182fd5b8235614a8f81615af1565b91506020830135801515811461497d578182fd5b60008060408385031215614ab5578182fd5b8235614ac081615af1565b946020939093013593505050565b600080600060608486031215614ae2578283fd5b8335614aed81615af1565b95602085013595506040909401359392505050565b600080600060408486031215614b16578283fd5b83356001600160401b03811115614b2b578384fd5b614b37868287016148a6565b909790965060209590950135949350505050565b600080600080600060608688031215614b62578283fd5b85356001600160401b0380821115614b78578485fd5b614b8489838a016148a6565b90975095506020880135915080821115614b9c578485fd5b50614ba9888289016148a6565b96999598509660400135949350505050565b600080600080600080600080600080600060c08c8e031215614bdb578889fd5b6001600160401b03808d351115614bf057898afd5b614bfd8e8e358f016148a6565b909c509a5060208d0135811015614c1257898afd5b614c228e60208f01358f016148a6565b909a50985060408d0135811015614c37578687fd5b614c478e60408f01358f016148a6565b909850965060608d0135811015614c5c578586fd5b614c6c8e60608f01358f016148a6565b909650945060808d0135811015614c81578384fd5b50614c928d60808e01358e016148a6565b819450809350505060a08c013590509295989b509295989b9093969950565b600060208284031215614cc2578081fd5b81358015158114613a68578182fd5b600060208284031215614ce2578081fd5b8135613a6881615b06565b600060208284031215614cfe578081fd5b8151613a6881615b06565b60008060208385031215614d1b578182fd5b82356001600160401b0380821115614d31578384fd5b81850186601f820112614d42578485fd5b8035925081831115614d52578485fd5b866020848301011115614d63578485fd5b60200196919550909350505050565b600060208284031215614d83578081fd5b81516001600160401b03811115614d98578182fd5b80830184601f820112614da9578283fd5b80519150614db9614a3a83615aa2565b828152856020848401011115614dcd578384fd5b614dde836020830160208501615ac5565b95945050505050565b60008082840360c0811215614dfa578283fd5b614e0485856148e7565b92506080603f1982011215614e17578182fd5b50614e226040615a7c565b614e2f85604086016148e7565b8152614e3e85608086016148e7565b6020820152809150509250929050565b600060208284031215614e5f578081fd5b5035919050565b600060208284031215614e77578081fd5b5051919050565b60008060408385031215614e90578182fd5b50508035926020909101359150565b60008060008060808587031215614eb4578182fd5b84359350602085013592506040850135614ecd81615af1565b9396929550929360600135925050565b600080600060608486031215614ef1578081fd5b505081359360208301359350604090920135919050565b60008060008060808587031215614f1d578182fd5b5050823594602084013594506040840135936060013592509050565b60008151808452614f51816020860160208601615ac5565b601f01601f19169290920160200192915050565b80518252602090810151910152565b60008251614f86818460208701615ac5565b9190910192915050565b60008351614fa2818460208801615ac5565b8351908301614fb5828260208801615ac5565b01949350505050565b6001600160a01b0391909116815260200190565b6001600160a01b038581168252841660208201526040810183905260806060820181905260009061500590830184614f39565b9695505050505050565b6001600160a01b0392909216825260ff16602082015260400190565b6001600160a01b03929092168252602082015260400190565b901515815260200190565b6000602082526110fc6020830184614f39565b60208082526022908201527f456e756d657261626c655365743a20696e646578206f7574206f6620626f756e604082015261647360f01b606082015260800190565b6020808252601d908201527f616c726561647920636c61696d656420616c6c207061696e74696e6773000000604082015260600190565b60208082526024908201527f446f6e2774206f776e20616e79204e465420696e207468697320636f6c6c65636040820152633a34b7b760e11b606082015260800190565b6020808252601c908201527f73746174746575746520636c61696d696e672069732070617573656400000000604082015260600190565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b60208082526026908201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160408201526564647265737360d01b606082015260800190565b6020808252601c908201527f4552433136353a20696e76616c696420696e7465726661636520696400000000604082015260600190565b6020808252601c908201527f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000604082015260600190565b6020808252601e908201527f5468697320726f79616c204e465420697320616c726561647920757365640000604082015260600190565b6020808252601b908201527f4e65656420746f2073657420726f79616c204e46542066697273740000000000604082015260600190565b6020808252601e908201527f616c726561647920636c61696d656420616c6c20737461747465757465730000604082015260600190565b60208082526018908201527f726f79616c20636c61696d696e67206973207061757365640000000000000000604082015260600190565b6020808252600e908201526d1a5b9d985b1a5908185b5bdd5b9d60921b604082015260600190565b60208082526024908201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646040820152637265737360e01b606082015260800190565b60208082526019908201527f4552433732313a20617070726f766520746f2063616c6c657200000000000000604082015260600190565b6020808252600c908201526b6f7574206f662072616e676560a01b604082015260600190565b6020808252602c908201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860408201526b34b9ba32b73a103a37b5b2b760a11b606082015260800190565b6020808252601d908201527f6465726976617469766520636c61696d696e6720697320706175736564000000604082015260600190565b60208082526038908201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760408201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000606082015260800190565b6020808252602a908201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604082015269726f206164647265737360b01b606082015260800190565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b60208082526018908201527f616c726561647920636c61696d656420616c6c20746f79730000000000000000604082015260600190565b60208082526022908201527f596f7520617265206e6f7420746865206f776e6572206f662074686973206c616040820152611b9960f21b606082015260800190565b60208082526022908201527f456e756d657261626c654d61703a20696e646578206f7574206f6620626f756e604082015261647360f01b606082015260800190565b6020808252818101527f4552433732313a206d696e7420746f20746865207a65726f2061646472657373604082015260600190565b6020808252601b908201527f7061696e74696e6720636c61696d696e67206973207061757365640000000000604082015260600190565b6020808252602c908201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860408201526b34b9ba32b73a103a37b5b2b760a11b606082015260800190565b6020808252602c908201527f4552433732314d657461646174613a2055524920736574206f66206e6f6e657860408201526b34b9ba32b73a103a37b5b2b760a11b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526029908201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960408201526839903737ba1037bbb760b91b606082015260800190565b6020808252602f908201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60408201526e3732bc34b9ba32b73a103a37b5b2b760891b606082015260800190565b60208082526025908201527f596f7520617265206e6f7420746865206f776e6572206f66207468697320746f6040820152641ad95b925160da1b606082015260800190565b6020808252602a908201527f496e76616c696420636f6c6c656374696f6e2069642c20686f6e6f72617279206040820152696f72206d6574616b657960b01b606082015260800190565b60208082526021908201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656040820152603960f91b606082015260800190565b60208082526019908201527f416c726561647920636c61696d656420616c6c206c616e647300000000000000604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b6020808252601d908201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604082015260600190565b6020808252601690820152751d1bde4818db185a5b5a5b99c81a5cc81c185d5cd95960521b604082015260600190565b6020808252600e908201526d11985a5b1959081d1bc81cd95b9960921b604082015260600190565b60208082526017908201527f6c616e6420636c61696d696e6720697320706175736564000000000000000000604082015260600190565b6020808252600d908201526c1b9bdd0818dbdb9d185a5b9959609a1b604082015260600190565b60808101615a588285614f65565b613a686040830184614f65565b90815260200190565b918252602082015260400190565b6040518181016001600160401b0381118282101715615a9a57600080fd5b604052919050565b60006001600160401b03821115615ab7578081fd5b50601f01601f191660200190565b60005b83811015615ae0578181015183820152602001615ac8565b83811115610d4f5750506000910152565b6001600160a01b03811681146111b057600080fd5b6001600160e01b0319811681146111b057600080fdfe4552433732313a207472616e7366657220746f206e6f6e20455243373231526563656976657220696d706c656d656e7465724552433732313a206f776e657220717565727920666f72206e6f6e6578697374656e7420746f6b656ea26469706673582212202852ce51a7adde673029dbb4ff51b7054313944c7b178e7ab19bc8e440f0b07164736f6c63430006050033
Deployed Bytecode
0x6080604052600436106103ef5760003560e01c806381c7707311610208578063c31dbf9611610118578063d678a41f116100ab578063e8a3d4851161007a578063e8a3d48514610b73578063e985e9c514610b88578063eacc74b814610ba8578063edd57e3214610bc8578063f2fde38b14610be8576103ef565b8063d678a41f14610b09578063d6e7d67b14610b29578063e6031d1b14610b3e578063e7ce6c1814610b53576103ef565b8063c8d6ab56116100e7578063c8d6ab5614610a7b578063caa6626014610a9b578063cbc67d3a14610abb578063d15a271b14610ae9576103ef565b8063c31dbf9614610a08578063c349026314610a28578063c616fd4c14610a3b578063c87b56dd14610a5b576103ef565b8063a22cb4651161019b578063b607a0aa1161016a578063b607a0aa1461097e578063b88d4fde14610993578063b9bc6ead146109b3578063c0e72740146109d3578063c177273d146109e8576103ef565b8063a22cb46514610909578063ab531efd14610929578063b12df58e14610949578063b2bdfa7b14610969576103ef565b8063938e3d7b116101d7578063938e3d7b1461089457806395d89b41146108b45780639de4ff15146108c9578063a05672f1146108e9576103ef565b806381c770731461081f57806388f62c121461083f5780638a3ac44d1461085f57806391ead87314610874576103ef565b80633ccfd60b116103035780635bf0234d1161029657806370a082311161026557806370a082311461079557806374a9a21b146107b55780637e749897146107d55780637efa391a146107ea5780638129fc1c1461080a576103ef565b80635bf0234d1461072b57806360a6fb8f146107405780636352211e146107605780636c0360eb14610780576103ef565b80634d8980f1116102d25780634d8980f1146106b85780634f6ccce7146106d857806355f804b3146106f85780635669057d14610718576103ef565b80633ccfd60b1461064e57806342842e0e146106635780634587b3ee146106835780634874340014610698576103ef565b80631b1c9c231161038657806322751f871161035557806322751f87146105a0578063237abb89146105ce57806323b872dd146105ee578063283315951461060e5780632f745c591461062e576103ef565b80631b1c9c231461052b5780631c5822fe1461054b5780631f3221b41461056057806320940d7a14610580576103ef565b8063095ea7b3116103c2578063095ea7b31461049b5780630b394838146104bb57806314d44ea0146104e857806318160ddd14610516576103ef565b806301ffc9a7146103f457806306fdde031461042a57806307f0db251461044c578063081812fc1461046e575b600080fd5b34801561040057600080fd5b5061041461040f366004614cd1565b610c08565b6040516104219190615044565b60405180910390f35b34801561043657600080fd5b5061043f610c2b565b604051610421919061504f565b34801561045857600080fd5b5061046c610467366004614b02565b610cc2565b005b34801561047a57600080fd5b5061048e610489366004614e4e565b610d55565b6040516104219190614fbe565b3480156104a757600080fd5b5061046c6104b6366004614aa3565b610d98565b3480156104c757600080fd5b506104db6104d6366004614e4e565b610e30565b6040516104219190615a65565b3480156104f457600080fd5b50610508610503366004614e7e565b610e42565b60405161042192919061502b565b34801561052257600080fd5b506104db610e85565b34801561053757600080fd5b5061046c610546366004614b02565b610e96565b34801561055757600080fd5b50610414610f14565b34801561056c57600080fd5b5061046c61057b366004614cb1565b610f24565b34801561058c57600080fd5b5061046c61059b366004614b02565b610f6c565b3480156105ac57600080fd5b506105c06105bb366004614e4e565b610fea565b604051610421929190615a6e565b3480156105da57600080fd5b506104146105e9366004614e4e565b611003565b3480156105fa57600080fd5b5061046c610609366004614988565b611018565b34801561061a57600080fd5b5061046c610629366004614b02565b611050565b34801561063a57600080fd5b506104db610649366004614aa3565b6110d4565b34801561065a57600080fd5b5061046c611105565b34801561066f57600080fd5b5061046c61067e366004614988565b6111b3565b34801561068f57600080fd5b506104146111ce565b3480156106a457600080fd5b5061048e6106b3366004614e4e565b6111de565b3480156106c457600080fd5b5061046c6106d3366004614cb1565b61132e565b3480156106e457600080fd5b506104db6106f3366004614e4e565b611376565b34801561070457600080fd5b5061046c610713366004614d09565b611392565b61046c610726366004614edd565b6113ff565b34801561073757600080fd5b5061041461182f565b34801561074c57600080fd5b5061046c61075b366004614cb1565b61183f565b34801561076c57600080fd5b5061048e61077b366004614e4e565b61187c565b34801561078c57600080fd5b5061043f6118aa565b3480156107a157600080fd5b506104db6107b0366004614918565b61190b565b3480156107c157600080fd5b5061048e6107d0366004614e4e565b611954565b3480156107e157600080fd5b5061041461196f565b3480156107f657600080fd5b5061046c610805366004614b4b565b61197f565b34801561081657600080fd5b5061046c611aeb565b34801561082b57600080fd5b506104db61083a366004614aa3565b611bfe565b34801561084b57600080fd5b5061046c61085a366004614bbb565b611dd7565b34801561086b57600080fd5b50610414611fc0565b34801561088057600080fd5b5061046c61088f366004614b02565b611fc9565b3480156108a057600080fd5b5061046c6108af366004614d09565b612047565b3480156108c057600080fd5b5061043f61207d565b3480156108d557600080fd5b5061046c6108e4366004614cb1565b6120de565b3480156108f557600080fd5b50610414610904366004614de7565b612126565b34801561091557600080fd5b5061046c610924366004614a72565b612185565b34801561093557600080fd5b506104db610944366004614e7e565b612253565b34801561095557600080fd5b5061043f610964366004614e7e565b612263565b34801561097557600080fd5b5061048e6123fe565b34801561098a57600080fd5b5061041461240d565b34801561099f57600080fd5b5061046c6109ae3660046149c8565b61241d565b3480156109bf57600080fd5b5061046c6109ce366004614cb1565b612456565b3480156109df57600080fd5b5061043f61249e565b3480156109f457600080fd5b506104db610a03366004614aa3565b61252c565b348015610a1457600080fd5b5061046c610a23366004614b02565b61255a565b61046c610a36366004614e7e565b6125de565b348015610a4757600080fd5b506105c0610a56366004614ace565b6129db565b348015610a6757600080fd5b5061043f610a76366004614e4e565b612ceb565b348015610a8757600080fd5b506104db610a96366004614aa3565b612e31565b348015610aa757600080fd5b5061046c610ab6366004614cb1565b612ee2565b348015610ac757600080fd5b50610adb610ad6366004614e4e565b612f2a565b604051610421929190615a4a565b348015610af557600080fd5b5061046c610b04366004614f08565b612f70565b348015610b1557600080fd5b5061046c610b24366004614cb1565b613288565b348015610b3557600080fd5b506104146132d0565b348015610b4a57600080fd5b506104146132e0565b348015610b5f57600080fd5b506104db610b6e366004614e7e565b6132f0565b348015610b7f57600080fd5b5061043f61339b565b348015610b9457600080fd5b50610414610ba3366004614950565b6133fc565b348015610bb457600080fd5b5061046c610bc3366004614e9f565b61342a565b348015610bd457600080fd5b506105c0610be3366004614e4e565b61360d565b348015610bf457600080fd5b5061046c610c03366004614918565b61363f565b6001600160e01b0319811660009081526033602052604090205460ff165b919050565b606a8054604080516020601f6002600019610100600188161502019095169490940493840181900481028201810190925282815260609390929091830182828015610cb75780601f10610c8c57610100808354040283529160200191610cb7565b820191906000526020600020905b815481529060010190602001808311610c9a57829003601f168201915b505050505090505b90565b609d546001600160a01b03163314610cf55760405162461bcd60e51b8152600401610cec90615738565b60405180910390fd5b60005b81811015610d4f57600160b16000868685818110610d1257fe5b9050602002016020810190610d279190614918565b6001600160a01b03168152602081019190915260400160002080549091019055600101610cf8565b50505050565b6000610d60826136b1565b610d7c5760405162461bcd60e51b8152600401610cec906156a0565b506000908152606860205260409020546001600160a01b031690565b6000610da38261187c565b9050806001600160a01b0316836001600160a01b03161415610dd75760405162461bcd60e51b8152600401610cec90615894565b806001600160a01b0316610de96136c4565b6001600160a01b03161480610e055750610e0581610ba36136c4565b610e215760405162461bcd60e51b8152600401610cec90615484565b610e2b83836136c8565b505050565b60ad6020526000908152604090205481565b60ac6020528160005260406000208181548110610e5b57fe5b6000918252602090912060029091020180546001909101546001600160a01b039091169250905082565b6000610e916066613736565b905090565b609d546001600160a01b03163314610ec05760405162461bcd60e51b8152600401610cec90615738565b60005b81811015610d4f57600060b16000868685818110610edd57fe5b9050602002016020810190610ef29190614918565b6001600160a01b03168152602081019190915260400160002055600101610ec3565b609d54600160a81b900460ff1681565b609d546001600160a01b03163314610f4e5760405162461bcd60e51b8152600401610cec90615738565b609d8054911515600160b81b0260ff60b81b19909216919091179055565b609d546001600160a01b03163314610f965760405162461bcd60e51b8152600401610cec90615738565b60005b81811015610d4f57600060a36000868685818110610fb357fe5b9050602002016020810190610fc89190614918565b6001600160a01b03168152602081019190915260400160002055600101610f99565b60ab602052600090815260409020805460019091015482565b60a16020526000908152604090205460ff1681565b6110296110236136c4565b82613741565b6110455760405162461bcd60e51b8152600401610cec9061590c565b610e2b8383836137c6565b609d546001600160a01b0316331461107a5760405162461bcd60e51b8152600401610cec90615738565b60005b81811015610d4f57600160a2600086868581811061109757fe5b90506020020160208101906110ac9190614918565b6001600160a01b0316815260208101919091526040016000208054909101905560010161107d565b6001600160a01b03821660009081526065602052604081206110fc908363ffffffff6138e616565b90505b92915050565b609d546001600160a01b0316331461112f5760405162461bcd60e51b8152600401610cec90615738565b609d546040516000916001600160a01b031690479061114d90610cbf565b60006040518083038185875af1925050503d806000811461118a576040519150601f19603f3d011682016040523d82523d6000602084013e61118f565b606091505b50509050806111b05760405162461bcd60e51b8152600401610cec906159c4565b50565b610e2b8383836040518060200160405280600081525061241d565b609d54600160b81b900460ff1681565b6040516331a9108f60e11b815260009030908190636352211e90611206908690600401615a65565b60206040518083038186803b15801561121e57600080fd5b505afa92505050801561124e575060408051601f3d908101601f1916820190925261124b91810190614934565b60015b611325576040516000815260443d101561126a57506000611305565b60046000803e60005160e01c6308c379a0811461128b576000915050611305565b60043d036004833e81513d60248201116001600160401b03821117156112b657600092505050611305565b80830180516001600160401b038111156112d7576000945050505050611305565b8060208301013d86018111156112f557600095505050505050611305565b601f01601f191660405250925050505b80611310575061131b565b600092505050610c26565b3d6000803e3d6000fd5b9150610c269050565b609d546001600160a01b031633146113585760405162461bcd60e51b8152600401610cec90615738565b609d8054911515600160a81b0260ff60a81b19909216919091179055565b60008061138a60668463ffffffff6138f216565b509392505050565b609d546001600160a01b031633146113bc5760405162461bcd60e51b8152600401610cec90615738565b6113fb82828080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061391092505050565b5050565b60a554600160a01b900460ff16156114295760405162461bcd60e51b8152600401610cec906159ec565b600081815260b06020526040902054831180156114565750600081815260b0602052604090206001015482115b80156114735750600081815260b060205260409020600201548311155b80156114905750600081815260b060205260409020600301548211155b6114ac5760405162461bcd60e51b8152600401610cec90615a23565b600081815260ae60205260408120546001600160a01b031690600483108015906114d7575060068311155b156114f2575033600090815260b16020526040902054611676565b6001600160a01b0382167372541ad75e05bc77c7a92304225937a8f665337214156115ce5760038311611535575033600090815260a360205260409020546115c9565b6040516370a0823160e01b815282906001600160a01b038216906370a0823190611563903390600401614fbe565b60206040518083038186803b15801561157b57600080fd5b505afa15801561158f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115b39190614e66565b33600090815260a3602052604090205490039150505b611676565b34666a94d74f430000146115f45760405162461bcd60e51b8152600401610cec90615338565b6040516370a0823160e01b815282906001600160a01b038216906370a0823190611622903390600401614fbe565b60206040518083038186803b15801561163a57600080fd5b505afa15801561164e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116729190614e66565b9150505b600081116116965760405162461bcd60e51b8152600401610cec906150db565b33600090815260a96020908152604080832086845290915290205481116116cf5760405162461bcd60e51b8152600401610cec906158d5565b60006116db8686612253565b90506116eb338261271001613923565b61170161271082016116fc8161393d565b613a14565b83158061170e5750836001145b806117195750836002145b806117245750836003145b156117655760005b600481101561175f5733600090815260a9602090815260408083208484529091529020805460019081019091550161172c565b50611827565b6001600160a01b038316600090815260af60209081526040918290208054835181840281018401909452808452606093928301828280156117c557602002820191906000526020600020905b8154815260200190600101908083116117b1575b50939450600093505050505b81518110156118245733600090815260a96020526040812083519091908490849081106117fa57fe5b602090810291909101810151825281019190915260400160002080546001908101909155016117d1565b50505b505050505050565b609d54600160b01b900460ff1681565b609d546001600160a01b031633146118695760405162461bcd60e51b8152600401610cec90615738565b60a7805460ff1916911515919091179055565b60006110ff82604051806060016040528060298152602001615b4f602991396066919063ffffffff613a5816565b606d8054604080516020601f6002600019610100600188161502019095169490940493840181900481028201810190925282815260609390929091830182828015610cb75780601f10610c8c57610100808354040283529160200191610cb7565b60006001600160a01b0382166119335760405162461bcd60e51b8152600401610cec906154e1565b6001600160a01b03821660009081526065602052604090206110ff90613736565b60ae602052600090815260409020546001600160a01b031681565b60a554600160b01b900460ff1681565b609d546001600160a01b031633146119a95760405162461bcd60e51b8152600401610cec90615738565b60005b818110156118275760af600060ae60008989868181106119c857fe5b602090810292909201358352508181019290925260409081016000908120546001600160a01b031684529183019390935291018120611a06916146e0565b838382818110611a1257fe5b9050602002016020810190611a279190614918565b60ae6000888885818110611a3757fe5b90506020020135815260200190815260200160002060006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060af6000858584818110611a8057fe5b9050602002016020810190611a959190614918565b6001600160a01b03166001600160a01b03168152602001908152602001600020868683818110611ac157fe5b835460018082018655600095865260209586902092909502939093013592019190915550016119ac565b600054610100900460ff1680611b045750611b04613a6f565b80611b12575060005460ff16155b611b2e5760405162461bcd60e51b8152600401610cec9061552b565b600054610100900460ff16158015611b59576000805460ff1961ff0019909116610100171660011790555b611ba560405180604001604052806009815260200168135e5411941b185b9960ba1b81525060405180604001604052806009815260200168135e5411941b185b9960ba1b815250613a80565b609d80546001600160a01b031990811633179091556000609a5561012c609b55610190609c5560a580549091167372541ad75e05bc77c7a92304225937a8f665337217905580156111b0576000805461ff001916905550565b60a75460009060ff1680611c555750600782108015611c5557506001600160a01b038316600090815260a36020526040902054151580611c5557506001600160a01b038316600090815260b1602052604090205415155b15611d3d57600080805b60a854811015611d3257600081815260ae60205260409020546001600160a01b03908116908316811415611c935750611d2a565b8092506007821015611ca55750611d2a565b6040516370a0823160e01b815281906001600160a01b038216906370a0823190611cd3908b90600401614fbe565b60206040518083038186803b158015611ceb57600080fd5b505afa158015611cff573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d239190614e66565b8501945050505b600101611c5f565b5081925050506110ff565b600082815260ae6020526040908190205490516370a0823160e01b81526001600160a01b0390911690819081906370a0823190611d7e908890600401614fbe565b60206040518083038186803b158015611d9657600080fd5b505afa158015611daa573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611dce9190614e66565b925050506110ff565b609d546001600160a01b03163314611e015760405162461bcd60e51b8152600401610cec90615738565b611e096146fe565b60005b82811015611fb1578c8c82818110611e2057fe5b845160209091029290920135909152508a8a82818110611e3c57fe5b9050602002013582600001516020018181525050888882818110611e5c57fe5b6020858101519102929092013590915250868682818110611e7957fe5b6020858101805192820294909401359181019190915260a854600090815260b08252604090208551805182558201516001820155925180516002850155015160039092019190915550848482818110611ece57fe5b9050602002016020810190611ee39190614918565b60a88054600090815260ae6020526040902080546001600160a01b0319166001600160a01b0393909316929092179091555415801590611f26575060a854600114155b8015611f35575060a854600214155b8015611f44575060a854600314155b15611f9f5760af6000868684818110611f5957fe5b9050602002016020810190611f6e9190614918565b6001600160a01b03168152602080820192909252604001600090812060a85481546001810183559183529290912001555b60a88054600190810190915501611e0c565b50505050505050505050505050565b60a75460ff1681565b609d546001600160a01b03163314611ff35760405162461bcd60e51b8152600401610cec90615738565b60005b81811015610d4f57600060a2600086868581811061201057fe5b90506020020160208101906120259190614918565b6001600160a01b03168152602081019190915260400160002055600101611ff6565b609d546001600160a01b031633146120715760405162461bcd60e51b8152600401610cec90615738565b610e2b60a68383614723565b606b8054604080516020601f6002600019610100600188161502019095169490940493840181900481028201810190925282815260609390929091830182828015610cb75780601f10610c8c57610100808354040283529160200191610cb7565b609d546001600160a01b031633146121085760405162461bcd60e51b8152600401610cec90615738565b609d8054911515600160b01b0260ff60b01b19909216919091179055565b805151825160009110801561214657508160000151602001518360200151115b80156121585750602082015151835111155b80156121705750816020015160200151836020015111155b1561217d575060016110ff565b5060006110ff565b61218d6136c4565b6001600160a01b0316826001600160a01b031614156121be5760405162461bcd60e51b8152600401610cec906153a4565b80606960006121cb6136c4565b6001600160a01b03908116825260208083019390935260409182016000908120918716808252919093529120805460ff19169215159290921790915561220f6136c4565b6001600160a01b03167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31836040516122479190615044565b60405180910390a35050565b6000198201606402810192915050565b600082815260ae60205260409020546060906001600160a01b0316600784101561229d5750506040805160208101909152600081526110ff565b60405163c87b56dd60e01b815281906001600160a01b0382169063c87b56dd906122cb908790600401615a65565b60006040518083038186803b1580156122e357600080fd5b505afa92505050801561231857506040513d6000823e601f3d908101601f191682016040526123159190810190614d72565b60015b6123f4576040516000815260443d1015612334575060006123cf565b60046000803e60005160e01c6308c379a081146123555760009150506123cf565b60043d036004833e81513d60248201116001600160401b0382111715612380576000925050506123cf565b80830180516001600160401b038111156123a15760009450505050506123cf565b8060208301013d86018111156123bf576000955050505050506123cf565b601f01601f191660405250925050505b806123da575061131b565b6040518060200160405280600081525093505050506110ff565b92506110ff915050565b609d546001600160a01b031681565b60a554600160a81b900460ff1681565b61242e6124286136c4565b83613741565b61244a5760405162461bcd60e51b8152600401610cec9061590c565b610d4f84848484613b1e565b609d546001600160a01b031633146124805760405162461bcd60e51b8152600401610cec90615738565b60a58054911515600160a81b0260ff60a81b19909216919091179055565b60a6805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156125245780601f106124f957610100808354040283529160200191612524565b820191906000526020600020905b81548152906001019060200180831161250757829003601f168201915b505050505081565b60af602052816000526040600020818154811061254557fe5b90600052602060002001600091509150505481565b609d546001600160a01b031633146125845760405162461bcd60e51b8152600401610cec90615738565b60005b81811015610d4f57600160a360008686858181106125a157fe5b90506020020160208101906125b69190614918565b6001600160a01b03168152602081019190915260400160002080549091019055600101612587565b60018210156125ff5760405162461bcd60e51b8152600401610cec906153db565b60038211156126205760405162461bcd60e51b8152600401610cec906153db565b816001141561265357609d54600160a81b900460ff16156126535760405162461bcd60e51b8152600401610cec90615994565b816002141561268657609d54600160b01b900460ff16156126865760405162461bcd60e51b8152600401610cec90615669565b81600314156126b957609d54600160b81b900460ff16156126b95760405162461bcd60e51b8152600401610cec9061511f565b60006126c53384613b51565b905082600114156126e65733600090815260a2602052604090205401612701565b82600214156127015733600090815260a36020526040902054015b6000600184141561274257336000908152609e6020526040902054830182101561273d5760405162461bcd60e51b8152600401610cec90615579565b6127a5565b836002141561277c57336000908152609f6020526040902054830182101561273d5760405162461bcd60e51b8152600401610cec906150a4565b83600314156127a557828210156127a55760405162461bcd60e51b8152600401610cec906152ca565b60005b838160ff16101561283e5784600114156127db576127c66097613d8e565b609a546127d36097613d97565b01915061281f565b84600214156127fb576127ee6098613d8e565b609b546127d36098613d97565b846003141561281f5761280e6099613d8e565b609c5461281b6099613d97565b0191505b6128293383613923565b612836826116fc8461393d565b6001016127a8565b50836001141561286257336000908152609e60205260409020805484019055612881565b836002141561288157336000908152609f602052604090208054840190555b6000821180156128915750836003145b15610d4f5760005b60a5546040516370a0823160e01b81526001600160a01b03909116906370a08231906128c9903390600401614fbe565b60206040518083038186803b1580156128e157600080fd5b505afa1580156128f5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129199190614e66565b8160ff1610156129d45760a554604051632f745c5960e01b81526000916001600160a01b031690632f745c5990612956903390869060040161500f565b60206040518083038186803b15801561296e57600080fd5b505afa158015612982573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129a69190614e66565b90506105cc81116129cb57600081815260a160205260409020805460ff191660011790555b50600101612899565b5050505050565b60a7546000908190819060ff1680612a365750600784108015612a3657506001600160a01b038616600090815260a36020526040902054151580612a3657506001600160a01b038616600090815260b1602052604090205415155b15612c4057600080805b60a854811015612c3857600081815260ae60205260409020546001600160a01b03908116908316811415612a745750612c30565b8092506007821015612a865750612c30565b6040516370a0823160e01b815281906001600160a01b038216906370a0823190612ab4908e90600401614fbe565b60206040518083038186803b158015612acc57600080fd5b505afa158015612ae0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b049190614e66565b8501945089600186031015612b1a575050612c30565b6040516370a0823160e01b81526000906001600160a01b038316906370a0823190612b49908f90600401614fbe565b60206040518083038186803b158015612b6157600080fd5b505afa158015612b75573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b999190614e66565b604051632f745c5960e01b81529087038c0391506001600160a01b03831690632f745c5990612bce908f90859060040161502b565b60206040518083038186803b158015612be657600080fd5b505afa158015612bfa573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c1e9190614e66565b939850929650612ce395505050505050565b600101612a40565b505050612ce1565b600084815260ae602052604090819020549051632f745c5960e01b81526001600160a01b039091169081908190632f745c5990612c83908b908b9060040161502b565b60206040518083038186803b158015612c9b57600080fd5b505afa158015612caf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612cd39190614e66565b8695509350612ce392505050565b505b935093915050565b6060612cf6826136b1565b612d125760405162461bcd60e51b8152600401610cec906157b6565b6000828152606c602090815260409182902080548351601f6002600019610100600186161502019093169290920491820184900484028101840190945280845260609392830182828015612da75780601f10612d7c57610100808354040283529160200191612da7565b820191906000526020600020905b815481529060010190602001808311612d8a57829003601f168201915b505050505090506060612db86118aa565b9050805160001415612dcc57509050610c26565b815115612dfe578082604051602001612de6929190614f90565b60405160208183030381529060405292505050610c26565b80612e0885613d9b565b604051602001612e19929190614f90565b60405160208183030381529060405292505050919050565b6000806001831080612e435750600383115b15612e4f5790506110ff565b6000612e5b8585613b51565b90508360011415612e97576001600160a01b038516600090815260a26020908152604080832054609e909252909120549101908103915061138a565b8360021415612ed1576001600160a01b038516600090815260a36020908152604080832054609f909252909120549101908103915061138a565b836003141561138a57949350505050565b609d546001600160a01b03163314612f0c5760405162461bcd60e51b8152600401610cec90615738565b60a58054911515600160a01b0260ff60a01b19909216919091179055565b60b0602090815260009182526040918290208251808401845281548152600182015481840152835180850190945260028201548452600390910154918301919091529082565b60a554600160a81b900460ff1615612f9a5760405162461bcd60e51b8152600401610cec90615301565b6000612fa68585612253565b905033612fb6612710830161187c565b6001600160a01b031614612fdc5760405162461bcd60e51b8152600401610cec906155b0565b60a75460ff16158015612ffc575033600090815260a36020526040902054155b8015613015575033600090815260b16020526040902054155b1561309d57600083815260b06020526040902054851180156130475750600083815260b0602052604090206001015484115b80156130645750600083815260b060205260409020600201548511155b80156130815750600083815260b060205260409020600301548411155b61309d5760405162461bcd60e51b8152600401610cec90615a23565b600083815260ae60205260409020546001600160a01b031660078410156130d65760405162461bcd60e51b8152600401610cec9061584a565b6040516331a9108f60e11b8152819033906001600160a01b03831690636352211e90613106908890600401615a65565b60206040518083038186803b15801561311e57600080fd5b505afa158015613132573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131569190614934565b6001600160a01b03161461317c5760405162461bcd60e51b8152600401610cec90615805565b6001600160a01b038216600090815260aa6020908152604080832087845290915290205460ff16156131c05760405162461bcd60e51b8152600401610cec9061525c565b6127108301600090815260ab60209081526040808320805480855260ae8452828520546001600160a01b03908116865260aa80865284872060019485015488528652848720805460ff19908116909155918916875285528386208a875290945291909320805490921690921790556132366147a1565b86815260208082018781526127108701600090815260ab8352604080822085518155925160019093019290925560ad835281812081905560ac909252812061327d916147bb565b505050505050505050565b609d546001600160a01b031633146132b25760405162461bcd60e51b8152600401610cec90615738565b60a58054911515600160b01b0260ff60b01b19909216919091179055565b60a554600160a01b900460ff1681565b609d54600160a01b900460ff1681565b6000806132fb6146fe565b6133036147a1565b8581526020810185905260005b60a85481101561338c57600081815260b0602090815260409182902082516080810184528154818501908152600183015460608301528152835180850190945260028201548452600390910154838301529081019190915292506133748284612126565b156133845793506110ff92505050565b600101613310565b50620186a09695505050505050565b60a68054604080516020601f6002600019610100600188161502019095169490940493840181900481028201810190925282815260609390929091830182828015610cb75780601f10610c8c57610100808354040283529160200191610cb7565b6001600160a01b03918216600090815260696020908152604080832093909416825291909152205460ff1690565b60a554600160b01b900460ff16156134545760405162461bcd60e51b8152600401610cec9061544d565b60006134608585612253565b905033613470612710830161187c565b6001600160a01b0316146134965760405162461bcd60e51b8152600401610cec906155b0565b6127108101600090815260ab60205260409020541515806134cc57506127108101600090815260ab602052604090206001015415155b6134e85760405162461bcd60e51b8152600401610cec90615293565b6040516331a9108f60e11b8152839033906001600160a01b03831690636352211e90613518908790600401615a65565b60206040518083038186803b15801561353057600080fd5b505afa158015613544573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906135689190614934565b6001600160a01b03161461358e5760405162461bcd60e51b8152600401610cec90615805565b6135966147dc565b6001600160a01b039485168152602080820194855261271093909301600081815260ac855260408082208054600180820183559184528784209551600290910290950180546001600160a01b03191695909916949094178855955196830196909655855260ad909252509120805490910190555050565b6000806064830460010191506064838161362357fe5b0661362f576001820391505b5091600019830160640290910390565b609d546001600160a01b031633146136695760405162461bcd60e51b8152600401610cec90615738565b6001600160a01b03811661368f5760405162461bcd60e51b8152600401610cec906151a8565b609d80546001600160a01b0319166001600160a01b0392909216919091179055565b60006110ff60668363ffffffff613e6c16565b3390565b600081815260686020526040902080546001600160a01b0319166001600160a01b03841690811790915581906136fd8261187c565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b60006110ff82613d97565b600061374c826136b1565b6137685760405162461bcd60e51b8152600401610cec90615401565b60006137738361187c565b9050806001600160a01b0316846001600160a01b031614806137ae5750836001600160a01b03166137a384610d55565b6001600160a01b0316145b806137be57506137be81856133fc565b949350505050565b826001600160a01b03166137d98261187c565b6001600160a01b0316146137ff5760405162461bcd60e51b8152600401610cec9061576d565b6001600160a01b0382166138255760405162461bcd60e51b8152600401610cec90615360565b613830838383613e78565b61383b6000826136c8565b6001600160a01b0383166000908152606560205260409020613863908263ffffffff613f1516565b506001600160a01b038216600090815260656020526040902061388c908263ffffffff613f2116565b5061389f6066828463ffffffff613f2d16565b5080826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b60006110fc8383613f43565b60008080806139018686613f88565b909450925050505b9250929050565b80516113fb90606d9060208401906147f3565b6113fb828260405180602001604052806000815250613fe4565b60608161396257506040805180820190915260018152600360fc1b6020820152610c26565b8160005b811561397a57600101600a82049150613966565b6060816001600160401b038111801561399257600080fd5b506040519080825280601f01601f1916602001820160405280156139bd576020820181803683370190505b50905060001982015b8515613a0b57600a860660300160f81b828280600190039350815181106139e957fe5b60200101906001600160f81b031916908160001a905350600a860495506139c6565b50949350505050565b613a1d826136b1565b613a395760405162461bcd60e51b8152600401610cec906156ec565b6000828152606c602090815260409091208251610e2b928401906147f3565b6000613a65848484614017565b90505b9392505050565b6000613a7a30614076565b15905090565b600054610100900460ff1680613a995750613a99613a6f565b80613aa7575060005460ff16155b613ac35760405162461bcd60e51b8152600401610cec9061552b565b600054610100900460ff16158015613aee576000805460ff1961ff0019909116610100171660011790555b613af661407c565b613afe6140fe565b613b08838361417c565b8015610e2b576000805461ff0019169055505050565b613b298484846137c6565b613b3584848484614242565b610d4f5760405162461bcd60e51b8152600401610cec90615156565b60a5546040516370a0823160e01b815260009182916001600160a01b03909116906370a0823190613b86908790600401614fbe565b60206040518083038186803b158015613b9e57600080fd5b505afa158015613bb2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613bd69190614e66565b613be15790506110ff565b6000808460011415613bfb57506112b69050611362613c24565b8460021415613c1257506113639050611388613c24565b8460031415613c245750600190506105cc5b60005b60a5546040516370a0823160e01b81526001600160a01b03909116906370a0823190613c57908a90600401614fbe565b60206040518083038186803b158015613c6f57600080fd5b505afa158015613c83573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613ca79190614e66565b811015613d835760a554604051632f745c5960e01b81526000916001600160a01b031690632f745c5990613ce1908b90869060040161502b565b60206040518083038186803b158015613cf957600080fd5b505afa158015613d0d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613d319190614e66565b9050838110158015613d435750828111155b15613d7a578660031415613d7357600081815260a1602052604090205460ff16613d6e576001909401935b613d7a565b6001909401935b50600101613c27565b509195945050505050565b80546001019055565b5490565b606081613dc057506040805180820190915260018152600360fc1b6020820152610c26565b8160005b8115613dd857600101600a82049150613dc4565b6060816001600160401b0381118015613df057600080fd5b506040519080825280601f01601f191660200182016040528015613e1b576020820181803683370190505b50859350905060001982015b8315613a0b57600a840660300160f81b82828060019003935081518110613e4a57fe5b60200101906001600160f81b031916908160001a905350600a84049350613e27565b60006110fc8383614327565b612710811115613f0a57613e8a6147a1565b6000808252602080830182815284835260ab8083526040808520805480875260ae8652828720546001600160a01b0316875260aa86528287206001830180548952908752838820805460ff191690558988529386528751909155925190915560ad835280842084905560ac9092529082209091613f0791906147bb565b50505b610e2b838383610e2b565b60006110fc838361433f565b60006110fc8383614405565b6000613a6584846001600160a01b038516614447565b81546000908210613f665760405162461bcd60e51b8152600401610cec90615062565b826000018281548110613f7557fe5b9060005260206000200154905092915050565b815460009081908310613fad5760405162461bcd60e51b8152600401610cec906155f2565b6000846000018481548110613fbe57fe5b906000526020600020906002020190508060000154816001015492509250509250929050565b613fee83836144de565b613ffb6000848484614242565b610e2b5760405162461bcd60e51b8152600401610cec90615156565b600082815260018401602052604081205482816140475760405162461bcd60e51b8152600401610cec919061504f565b5084600001600182038154811061405a57fe5b9060005260206000209060020201600101549150509392505050565b3b151590565b600054610100900460ff16806140955750614095613a6f565b806140a3575060005460ff16155b6140bf5760405162461bcd60e51b8152600401610cec9061552b565b600054610100900460ff161580156140ea576000805460ff1961ff0019909116610100171660011790555b80156111b0576000805461ff001916905550565b600054610100900460ff16806141175750614117613a6f565b80614125575060005460ff16155b6141415760405162461bcd60e51b8152600401610cec9061552b565b600054610100900460ff1615801561416c576000805460ff1961ff0019909116610100171660011790555b6140ea6301ffc9a760e01b6145ae565b600054610100900460ff16806141955750614195613a6f565b806141a3575060005460ff16155b6141bf5760405162461bcd60e51b8152600401610cec9061552b565b600054610100900460ff161580156141ea576000805460ff1961ff0019909116610100171660011790555b82516141fd90606a9060208601906147f3565b50815161421190606b9060208501906147f3565b506142226380ac58cd60e01b6145ae565b614232635b5e139f60e01b6145ae565b613b0863780e9d6360e01b6145ae565b6000614256846001600160a01b0316614076565b614262575060016137be565b60606142f0630a85bd0160e11b6142776136c4565b88878760405160240161428d9493929190614fd2565b604051602081830303815290604052906001600160e01b0319166020820180516001600160e01b038381831617835250505050604051806060016040528060328152602001615b1d603291396001600160a01b038816919063ffffffff6145fd16565b90506000818060200190518101906143089190614ced565b6001600160e01b031916630a85bd0160e11b1492505050949350505050565b60009081526001919091016020526040902054151590565b600081815260018301602052604081205480156143fb578354600019808301919081019060009087908390811061437257fe5b906000526020600020015490508087600001848154811061438f57fe5b6000918252602080832090910192909255828152600189810190925260409020908401905586548790806143bf57fe5b600190038181906000526020600020016000905590558660010160008781526020019081526020016000206000905560019450505050506110ff565b60009150506110ff565b60006144118383614327565b61217d575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556110ff565b6000828152600184016020526040812054806144ac575050604080518082018252838152602080820184815286546001818101895560008981528481209551600290930290950191825591519082015586548684528188019092529290912055613a68565b828560000160018303815481106144bf57fe5b9060005260206000209060020201600101819055506000915050613a68565b6001600160a01b0382166145045760405162461bcd60e51b8152600401610cec90615634565b61450d816136b1565b1561452a5760405162461bcd60e51b8152600401610cec90615225565b61453660008383613e78565b6001600160a01b038216600090815260656020526040902061455e908263ffffffff613f2116565b506145716066828463ffffffff613f2d16565b5060405181906001600160a01b038416906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b6001600160e01b031980821614156145d85760405162461bcd60e51b8152600401610cec906151ee565b6001600160e01b0319166000908152603360205260409020805460ff19166001179055565b6060613a6584846000858561461185614076565b61462d5760405162461bcd60e51b8152600401610cec9061595d565b60006060866001600160a01b0316858760405161464a9190614f74565b60006040518083038185875af1925050503d8060008114614687576040519150601f19603f3d011682016040523d82523d6000602084013e61468c565b606091505b509150915061469c8282866146a7565b979650505050505050565b606083156146b6575081613a68565b8251156146c65782518084602001fd5b8160405162461bcd60e51b8152600401610cec919061504f565b50805460008255906000526020600020908101906111b09190614861565b60405180604001604052806147116147a1565b815260200161471e6147a1565b905290565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106147645782800160ff19823516178555614791565b82800160010185558215614791579182015b82811115614791578235825591602001919060010190614776565b5061479d929150614861565b5090565b604051806040016040528060008152602001600081525090565b50805460008255600202906000526020600020908101906111b0919061487b565b604080518082019091526000808252602082015290565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061483457805160ff1916838001178555614791565b82800160010185558215614791579182015b82811115614791578251825591602001919060010190614846565b610cbf91905b8082111561479d5760008155600101614867565b610cbf91905b8082111561479d5780546001600160a01b031916815560006001820155600201614881565b60008083601f8401126148b7578182fd5b5081356001600160401b038111156148cd578182fd5b602083019150836020808302850101111561390957600080fd5b6000604082840312156148f8578081fd5b6149026040615a7c565b9050813581526020820135602082015292915050565b600060208284031215614929578081fd5b8135613a6881615af1565b600060208284031215614945578081fd5b8151613a6881615af1565b60008060408385031215614962578081fd5b823561496d81615af1565b9150602083013561497d81615af1565b809150509250929050565b60008060006060848603121561499c578081fd5b83356149a781615af1565b925060208401356149b781615af1565b929592945050506040919091013590565b600080600080608085870312156149dd578081fd5b84356149e881615af1565b935060208501356149f881615af1565b92506040850135915060608501356001600160401b03811115614a19578182fd5b80860187601f820112614a2a578283fd5b80359150614a3f614a3a83615aa2565b615a7c565b828152886020848401011115614a53578384fd5b8260208301602083013791820160200192909252939692955090935050565b60008060408385031215614a84578182fd5b8235614a8f81615af1565b91506020830135801515811461497d578182fd5b60008060408385031215614ab5578182fd5b8235614ac081615af1565b946020939093013593505050565b600080600060608486031215614ae2578283fd5b8335614aed81615af1565b95602085013595506040909401359392505050565b600080600060408486031215614b16578283fd5b83356001600160401b03811115614b2b578384fd5b614b37868287016148a6565b909790965060209590950135949350505050565b600080600080600060608688031215614b62578283fd5b85356001600160401b0380821115614b78578485fd5b614b8489838a016148a6565b90975095506020880135915080821115614b9c578485fd5b50614ba9888289016148a6565b96999598509660400135949350505050565b600080600080600080600080600080600060c08c8e031215614bdb578889fd5b6001600160401b03808d351115614bf057898afd5b614bfd8e8e358f016148a6565b909c509a5060208d0135811015614c1257898afd5b614c228e60208f01358f016148a6565b909a50985060408d0135811015614c37578687fd5b614c478e60408f01358f016148a6565b909850965060608d0135811015614c5c578586fd5b614c6c8e60608f01358f016148a6565b909650945060808d0135811015614c81578384fd5b50614c928d60808e01358e016148a6565b819450809350505060a08c013590509295989b509295989b9093969950565b600060208284031215614cc2578081fd5b81358015158114613a68578182fd5b600060208284031215614ce2578081fd5b8135613a6881615b06565b600060208284031215614cfe578081fd5b8151613a6881615b06565b60008060208385031215614d1b578182fd5b82356001600160401b0380821115614d31578384fd5b81850186601f820112614d42578485fd5b8035925081831115614d52578485fd5b866020848301011115614d63578485fd5b60200196919550909350505050565b600060208284031215614d83578081fd5b81516001600160401b03811115614d98578182fd5b80830184601f820112614da9578283fd5b80519150614db9614a3a83615aa2565b828152856020848401011115614dcd578384fd5b614dde836020830160208501615ac5565b95945050505050565b60008082840360c0811215614dfa578283fd5b614e0485856148e7565b92506080603f1982011215614e17578182fd5b50614e226040615a7c565b614e2f85604086016148e7565b8152614e3e85608086016148e7565b6020820152809150509250929050565b600060208284031215614e5f578081fd5b5035919050565b600060208284031215614e77578081fd5b5051919050565b60008060408385031215614e90578182fd5b50508035926020909101359150565b60008060008060808587031215614eb4578182fd5b84359350602085013592506040850135614ecd81615af1565b9396929550929360600135925050565b600080600060608486031215614ef1578081fd5b505081359360208301359350604090920135919050565b60008060008060808587031215614f1d578182fd5b5050823594602084013594506040840135936060013592509050565b60008151808452614f51816020860160208601615ac5565b601f01601f19169290920160200192915050565b80518252602090810151910152565b60008251614f86818460208701615ac5565b9190910192915050565b60008351614fa2818460208801615ac5565b8351908301614fb5828260208801615ac5565b01949350505050565b6001600160a01b0391909116815260200190565b6001600160a01b038581168252841660208201526040810183905260806060820181905260009061500590830184614f39565b9695505050505050565b6001600160a01b0392909216825260ff16602082015260400190565b6001600160a01b03929092168252602082015260400190565b901515815260200190565b6000602082526110fc6020830184614f39565b60208082526022908201527f456e756d657261626c655365743a20696e646578206f7574206f6620626f756e604082015261647360f01b606082015260800190565b6020808252601d908201527f616c726561647920636c61696d656420616c6c207061696e74696e6773000000604082015260600190565b60208082526024908201527f446f6e2774206f776e20616e79204e465420696e207468697320636f6c6c65636040820152633a34b7b760e11b606082015260800190565b6020808252601c908201527f73746174746575746520636c61696d696e672069732070617573656400000000604082015260600190565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b60208082526026908201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160408201526564647265737360d01b606082015260800190565b6020808252601c908201527f4552433136353a20696e76616c696420696e7465726661636520696400000000604082015260600190565b6020808252601c908201527f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000604082015260600190565b6020808252601e908201527f5468697320726f79616c204e465420697320616c726561647920757365640000604082015260600190565b6020808252601b908201527f4e65656420746f2073657420726f79616c204e46542066697273740000000000604082015260600190565b6020808252601e908201527f616c726561647920636c61696d656420616c6c20737461747465757465730000604082015260600190565b60208082526018908201527f726f79616c20636c61696d696e67206973207061757365640000000000000000604082015260600190565b6020808252600e908201526d1a5b9d985b1a5908185b5bdd5b9d60921b604082015260600190565b60208082526024908201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646040820152637265737360e01b606082015260800190565b60208082526019908201527f4552433732313a20617070726f766520746f2063616c6c657200000000000000604082015260600190565b6020808252600c908201526b6f7574206f662072616e676560a01b604082015260600190565b6020808252602c908201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860408201526b34b9ba32b73a103a37b5b2b760a11b606082015260800190565b6020808252601d908201527f6465726976617469766520636c61696d696e6720697320706175736564000000604082015260600190565b60208082526038908201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760408201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000606082015260800190565b6020808252602a908201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604082015269726f206164647265737360b01b606082015260800190565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b60208082526018908201527f616c726561647920636c61696d656420616c6c20746f79730000000000000000604082015260600190565b60208082526022908201527f596f7520617265206e6f7420746865206f776e6572206f662074686973206c616040820152611b9960f21b606082015260800190565b60208082526022908201527f456e756d657261626c654d61703a20696e646578206f7574206f6620626f756e604082015261647360f01b606082015260800190565b6020808252818101527f4552433732313a206d696e7420746f20746865207a65726f2061646472657373604082015260600190565b6020808252601b908201527f7061696e74696e6720636c61696d696e67206973207061757365640000000000604082015260600190565b6020808252602c908201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860408201526b34b9ba32b73a103a37b5b2b760a11b606082015260800190565b6020808252602c908201527f4552433732314d657461646174613a2055524920736574206f66206e6f6e657860408201526b34b9ba32b73a103a37b5b2b760a11b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526029908201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960408201526839903737ba1037bbb760b91b606082015260800190565b6020808252602f908201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60408201526e3732bc34b9ba32b73a103a37b5b2b760891b606082015260800190565b60208082526025908201527f596f7520617265206e6f7420746865206f776e6572206f66207468697320746f6040820152641ad95b925160da1b606082015260800190565b6020808252602a908201527f496e76616c696420636f6c6c656374696f6e2069642c20686f6e6f72617279206040820152696f72206d6574616b657960b01b606082015260800190565b60208082526021908201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656040820152603960f91b606082015260800190565b60208082526019908201527f416c726561647920636c61696d656420616c6c206c616e647300000000000000604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b6020808252601d908201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604082015260600190565b6020808252601690820152751d1bde4818db185a5b5a5b99c81a5cc81c185d5cd95960521b604082015260600190565b6020808252600e908201526d11985a5b1959081d1bc81cd95b9960921b604082015260600190565b60208082526017908201527f6c616e6420636c61696d696e6720697320706175736564000000000000000000604082015260600190565b6020808252600d908201526c1b9bdd0818dbdb9d185a5b9959609a1b604082015260600190565b60808101615a588285614f65565b613a686040830184614f65565b90815260200190565b918252602082015260400190565b6040518181016001600160401b0381118282101715615a9a57600080fd5b604052919050565b60006001600160401b03821115615ab7578081fd5b50601f01601f191660200190565b60005b83811015615ae0578181015183820152602001615ac8565b83811115610d4f5750506000910152565b6001600160a01b03811681146111b057600080fd5b6001600160e01b0319811681146111b057600080fdfe4552433732313a207472616e7366657220746f206e6f6e20455243373231526563656976657220696d706c656d656e7465724552433732313a206f776e657220717565727920666f72206e6f6e6578697374656e7420746f6b656ea26469706673582212202852ce51a7adde673029dbb4ff51b7054313944c7b178e7ab19bc8e440f0b07164736f6c63430006050033
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 26 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
Loading...
Loading
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.