Feature Tip: Add private address tag to any address under My Name Tag !
Overview
TokenID
6801
Total Transfers
-
Market
Onchain Market Cap
$0.00
Circulating Supply Market Cap
-
Other Info
Token Contract
Loading...
Loading
Loading...
Loading
Loading...
Loading
# | Exchange | Pair | Price | 24H Volume | % Volume |
---|
Contract Name:
Main
Compiler Version
v0.8.19+commit.7dd6d404
Optimization Enabled:
Yes with 1 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: CC0-1.0 /* @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@ @@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@ @@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@ @@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@ @@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ */ // solhint-disable no-global-import // solhint-disable quotes pragma solidity ^0.8.19; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/utils/Base64.sol"; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; import "@divergencetech/ethier/contracts/erc721/ERC721ACommon.sol"; import "@divergencetech/ethier/contracts/random/NextShuffler.sol"; import "@divergencetech/ethier/contracts/utils/BMP.sol"; import "@divergencetech/ethier/contracts/utils/DynamicBuffer.sol"; import "@divergencetech/ethier/contracts/utils/Image.sol"; import "./ethiers/ArbitraryPriceSeller.sol"; import "./ITokenURI.sol"; import "./ITokenURIBuilder.sol"; import "./ITraits.sol"; import "./IRender.sol"; import "./ISVGWrapper.sol"; import "./MetadataStrings.sol"; contract Main is ERC721ACommon, ArbitraryPriceSeller { using DynamicBuffer for bytes; using PRNG for PRNG.Source; bytes private constant _BMP_URI_PREFIX = "data:image/bmp;base64,"; uint256 internal constant _BMP_URI_PREFIX_LENGTH = 22; uint32 internal constant _NATIVE_RES = 54; constructor( string memory name_, string memory symbol_, uint256 maxSupply_, uint256 maxPerAddress_, uint256 maxPerTransaction_, address salesRecipient_, address royaltyRecipient_, uint96 royaltyBasisPoints_ ) ERC721ACommon( _msgSender(), // admin _msgSender(), // steerer name_, symbol_, payable(royaltyRecipient_), royaltyBasisPoints_ ) ArbitraryPriceSeller( Seller.SellerConfig({ totalInventory: maxSupply_, maxPerAddress: maxPerAddress_, maxPerTx: maxPerTransaction_, freeQuota: 0, reserveFreeQuota: false, lockFreeQuota: false, lockTotalInventory: false }), payable(salesRecipient_) ) { _name = super.name(); _symbol = super.symbol(); description = "DESCRIPTION"; externalUrl = "EXTERNAL_URL"; prefix = string(abi.encodePacked(_name, " #")); scaleFactor = 10; /* istanbul ignore next */ require( getSlot(SLOT_1) == 0 && getSlot(SLOT_2) == 0 && getSlot(SLOT_3) == 0, "Main:invalid-slot-state" ); } // ============================================================= // IERC721 // ============================================================= function tokenURI( uint256 tokenId ) public view override tokenExists(tokenId) returns (string memory tokenUri) { if (tokenURIOverride != address(0)) { return ITokenURI(tokenURIOverride).tokenURI(tokenId); } uint256 seed = _seeds[tokenId]; PRNG.Source src = PRNG.newSource(keccak256(abi.encodePacked(seed))); uint256 range = sellerConfig.totalInventory; uint256 noneCount = (range * 25) / 100; uint72 encoded; encoded = encodeTrait(encoded, range, noneCount, src, 0, 64, false); encoded = encodeTrait(encoded, range, noneCount, src, 1, 56, false); encoded = encodeTrait(encoded, range, noneCount, src, 2, 48, true); encoded = encodeTrait(encoded, range, noneCount, src, 3, 40, true); encoded = encodeTrait(encoded, range, noneCount, src, 4, 32, true); encoded = encodeTrait(encoded, range, noneCount, src, 5, 16, true); encoded = encodeTrait(encoded, range, noneCount, src, 6, 8, true); encoded = encodeTrait(encoded, range, noneCount, src, 7, 0, true); bytes memory artwork = IRender(_render).render( RenderInfo( encoded, revealed, _traitCounts, tokenId, getSlot(SLOT_1), getSlot(SLOT_2), getSlot(SLOT_3) ) ); (, uint256 paddedLengthScaled) = BMP.computePadding( _NATIVE_RES * scaleFactor, _NATIVE_RES * scaleFactor ); bytes memory imageUri = DynamicBuffer.allocate( _BMP_URI_PREFIX_LENGTH + (4 * (BMP._BMP_HEADER_SIZE + paddedLengthScaled + 2)) / 3 ); imageUri.appendSafe(_BMP_URI_PREFIX); if (svgWrapped || scaleFactor == 1) { imageUri.appendSafeBase64( BMP.bmp(artwork, _NATIVE_RES, _NATIVE_RES), false, false ); } else { imageUri.appendSafeBase64( BMP.header( _NATIVE_RES * scaleFactor, _NATIVE_RES * scaleFactor ), false, false ); Image.appendSafeScaled( imageUri, bytes(Base64.encode(artwork)), _NATIVE_RES, 4, scaleFactor ); } TokenURIOptions memory options = TokenURIOptions( imageUri, _getTraits(encoded), tokenStart + tokenId, description, externalUrl, prefix ); ITokenURIBuilder builder = ITokenURIBuilder(tokenURIBuilder); if (svgWrapped) { tokenUri = string( builder.encodeSVGWrapped( options, ISVGWrapper(_svgWrapper), _svgWrapperTarget, _NATIVE_RES, _NATIVE_RES ) ); } else { tokenUri = string(builder.encode(options)); } } function encodeTrait( uint72 encoded, uint256 range, uint256 noneCount, PRNG.Source src, uint256 index, uint72 bits, bool includeNone ) private view returns (uint72) { uint256 traitCount = _traitCounts[index]; uint256 next = PRNG.readLessThan(src, range); if (includeNone) { encoded |= uint72((next < noneCount ? traitCount : next % traitCount)) << bits; } else { encoded |= uint72((next % traitCount)) << bits; } return encoded; } address public tokenURIBuilder; function setTokenURIBuilder(address tokenURIBuilder_) external onlyOwner { tokenURIBuilder = tokenURIBuilder_; _refreshAllMetadata(); } address public tokenURIOverride; function setTokenURIOverride(address tokenURIOverride_) external onlyOwner { tokenURIOverride = tokenURIOverride_; _refreshAllMetadata(); } address public traitsOverride; function setTraitsOverride(address traitsOverride_) external onlyOwner { traitsOverride = traitsOverride_; _refreshAllMetadata(); } // ============================================================= // IERC721Metadata // ============================================================= string private _name; string private _symbol; /** * @notice Returns the token collection name. */ function name() public view override returns (string memory) { return _name; } function setName(string calldata name_) external onlyOwner { _name = name_; _refreshAllMetadata(); } /** * @notice Returns the token collection symbol. */ function symbol() public view override returns (string memory) { return _symbol; } function setSymbol(string calldata symbol_) external onlyOwner { _symbol = symbol_; _refreshAllMetadata(); } string public description; string public externalUrl; string public prefix; struct ExtendedData { string description; string externalUrl; string prefix; } function extendedData() external view returns (ExtendedData memory data) { data.description = description; data.externalUrl = externalUrl; data.prefix = prefix; } function setExtendedData( ExtendedData calldata extendedData_ ) external onlyOwner { description = extendedData_.description; externalUrl = extendedData_.externalUrl; prefix = extendedData_.prefix; _refreshAllMetadata(); } // ============================================================= // Sales // ============================================================= function maxSupply() external view returns (uint256) { return sellerConfig.totalInventory; } function soldOut() external view returns (bool) { return totalSupply() == sellerConfig.totalInventory; } uint256 public price; function setPrice(uint256 price_) external onlyOwner { price = price_; } // ============================================================= // Minting // ============================================================= error MintNotOpen(); function mint(address to, uint256 quantity) external payable { if (!mintOpen) revert MintNotOpen(); _purchase(to, quantity, price); } bool public mintOpen; function openMint() external onlyOwner { mintOpen = true; } function closeMint() external onlyOwner { mintOpen = false; } mapping(uint256 => uint256) private _seeds; /** @notice Override of the Seller purchasing logic to mint the required number of tokens. @dev The freeOfCharge boolean flag is deliberately ignored. */ function _handlePurchase( address to, uint256 quantity, bool ) internal override { uint256 start = _nextTokenId(); uint256 end = start + quantity; _safeMint(to, quantity); for (; start < end; ++start) { _seeds[start] = uint256( keccak256( abi.encodePacked( address(this), block.coinbase, block.number, block.prevrandao, start ) ) ); } } uint256[] private _traitCounts; function setTraitCounts( uint256[] calldata traitCounts_ ) external onlyOwner { _traitCounts = traitCounts_; _refreshAllMetadata(); } bytes[] private _traitNames; function setTraitNames(string[] calldata traitNames_) external onlyOwner { _traitNames = new bytes[](traitNames_.length); for (uint256 i; i < traitNames_.length; i++) { _traitNames[i] = bytes(traitNames_[i]); } _refreshAllMetadata(); } uint8 public scaleFactor; function setScaleFactor(uint8 scaleFactor_) external onlyOwner { scaleFactor = scaleFactor_; _refreshAllMetadata(); } bool public revealed; function setRevealed() external onlyOwner { revealed = true; _refreshAllMetadata(); } function setUnrevealed() external onlyOwner { revealed = false; _refreshAllMetadata(); } // ============================================================= // TokenURI // ============================================================= uint256 public tokenStart; function setTokenStart(uint256 tokenStart_) external onlyOwner { tokenStart = tokenStart_; _refreshAllMetadata(); } function _getTraits( uint72 encoded ) private view returns (bytes memory attributes) { if (traitsOverride != address(0)) { return ITraits(traitsOverride).getTraits(encoded); } attributes = DynamicBuffer.allocate(1000); attributes.appendUnchecked('"attributes":['); uint8 numberOfTraits; if (revealed) { numberOfTraits = _appendTrait( attributes, _traitNames[0], _strings.getString(0, uint8(encoded >> 64)), numberOfTraits ); numberOfTraits = _appendTrait( attributes, _traitNames[1], _strings.getString(1, uint8((encoded >> 56) & 0xFF)), numberOfTraits ); numberOfTraits = _appendTrait( attributes, _traitNames[2], _strings.getString(2, uint8((encoded >> 48) & 0xFF)), numberOfTraits ); numberOfTraits = _appendTrait( attributes, _traitNames[3], _strings.getString(3, uint8((encoded >> 40) & 0xFF)), numberOfTraits ); numberOfTraits = _appendTrait( attributes, _traitNames[4], _strings.getString(4, uint8((encoded >> 32) & 0xFF)), numberOfTraits ); numberOfTraits = _appendTrait( attributes, _traitNames[5], _strings.getString(5, uint16((encoded >> 16) & 0xFFFF)), numberOfTraits ); numberOfTraits = _appendTrait( attributes, _traitNames[6], _strings.getString(6, uint8((encoded >> 8) & 0xFF)), numberOfTraits ); numberOfTraits = _appendTrait( attributes, _traitNames[7], _strings.getString(7, uint8(encoded & 0xFF)), numberOfTraits ); } else { numberOfTraits = _appendTrait( attributes, "revealed", "false", numberOfTraits ); } attributes.appendUnchecked("]"); } function _appendTrait( bytes memory attributes, bytes memory traitType, bytes memory value, uint8 numberOfTraits ) private pure returns (uint8) { /* istanbul ignore else */ if (bytes(value).length > 0) { numberOfTraits++; attributes.appendUnchecked(bytes(numberOfTraits > 1 ? "," : "")); attributes.appendUnchecked('{"trait_type":"'); attributes.appendUnchecked(traitType); attributes.appendUnchecked('","value":"'); attributes.appendUnchecked(value); attributes.appendUnchecked('"}'); } return numberOfTraits; } // ============================================================= // Dependencies // ============================================================= MetadataStrings private _strings; function setStrings(address strings_) external onlyOwner { _strings = MetadataStrings(strings_); _refreshAllMetadata(); } address private _svgWrapper; bool public svgWrapped; function setSVGWrapper(address svgWrapper_) external onlyOwner { _svgWrapper = svgWrapper_; _refreshAllMetadata(); } function enableSVGWrapper() external onlyOwner { svgWrapped = true; _refreshAllMetadata(); } function disableSVGWrapper() external onlyOwner { svgWrapped = false; _refreshAllMetadata(); } SVGWrapperTarget private _svgWrapperTarget; function setSVGWrapperTarget( SVGWrapperTarget svgWrapperTarget_ ) external onlyOwner { _svgWrapperTarget = svgWrapperTarget_; _refreshAllMetadata(); } address private _render; function setRender(address render_) external onlyOwner { _render = render_; _refreshAllMetadata(); } // ============================================================= // Slots // ============================================================= uint256 private constant SLOT_1 = 2 ** 250; uint256 private constant SLOT_2 = 2 ** 251; uint256 private constant SLOT_3 = 2 ** 252; error InvalidSlot(); function setSlot(uint256 slot, uint256 value) external onlyOwner { if(slot != SLOT_1 && slot != SLOT_2 && slot != SLOT_3) { revert InvalidSlot(); } assembly { sstore(slot, value) } _refreshAllMetadata(); } function getSlot(uint256 slot) public view returns (uint256 result) { if(slot != SLOT_1 && slot != SLOT_2 && slot != SLOT_3) { revert InvalidSlot(); } assembly { result := sload(slot) } } // ============================================================= // IERC4906 // ============================================================= function _refreshAllMetadata() private { _refreshMetadata(0, totalSupply()); } // ============================================================= // IERC165 // ============================================================= function supportsInterface( bytes4 interfaceId ) public view override(ERC721ACommon, AccessControlEnumerable) returns (bool) { return super.supportsInterface(interfaceId); } }
// SPDX-License-Identifier: CC0-1.0 pragma solidity ^0.8.0; import {IERC165, ERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol"; interface IERC4906Events { /// @dev This event emits when the metadata of a token is changed. /// So that the third-party platforms such as NFT market could /// timely update the images and related attributes of the NFT. event MetadataUpdate(uint256 _tokenId); /// @dev This event emits when the metadata of a range of tokens is changed. /// So that the third-party platforms such as NFT market could /// timely update the images and related attributes of the NFTs. event BatchMetadataUpdate(uint256 _fromTokenId, uint256 _toTokenId); } /// @title EIP-721 Metadata Update Extension // solhint-disable-next-line no-empty-blocks interface IERC4906 is IERC165, IERC4906Events { } contract ERC4906 is IERC4906, ERC165 { function _refreshMetadata(uint256 tokenId) internal { emit MetadataUpdate(tokenId); } function _refreshMetadata(uint256 fromTokenId, uint256 toTokenId) internal { emit BatchMetadataUpdate(fromTokenId, toTokenId); } /// @dev See {IERC165-supportsInterface}. function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == bytes4(0x49064906) || ERC165.supportsInterface(interfaceId); } }
// SPDX-License-Identifier: MIT // Copyright (c) 2022 the ethier authors (github.com/divergencetech/ethier) pragma solidity >=0.8.0 <0.9.0; import {ERC721A} from "erc721a/contracts/ERC721A.sol"; import {ERC2981} from "@openzeppelin/contracts/token/common/ERC2981.sol"; import {AccessControlEnumerable} from "../utils/AccessControlEnumerable.sol"; import {AccessControlPausable} from "../utils/AccessControlPausable.sol"; import {ERC4906} from "./ERC4906.sol"; /** @notice An ERC721A contract with common functionality: - Pausable with toggling functions exposed to Owner only - ERC2981 royalties */ contract ERC721ACommon is ERC721A, AccessControlPausable, ERC2981, ERC4906 { constructor( address admin, address steerer, string memory name, string memory symbol, address payable royaltyReciever, uint96 royaltyBasisPoints ) ERC721A(name, symbol) { _setDefaultRoyalty(royaltyReciever, royaltyBasisPoints); _grantRole(DEFAULT_ADMIN_ROLE, admin); _grantRole(DEFAULT_STEERING_ROLE, steerer); } /// @notice Requires that the token exists. modifier tokenExists(uint256 tokenId) { require(ERC721A._exists(tokenId), "ERC721ACommon: Token doesn't exist"); _; } /// @notice Requires that msg.sender owns or is approved for the token. modifier onlyApprovedOrOwner(uint256 tokenId) { require( _ownershipOf(tokenId).addr == _msgSender() || getApproved(tokenId) == _msgSender(), "ERC721ACommon: Not approved nor owner" ); _; } function _beforeTokenTransfers( address from, address to, uint256 startTokenId, uint256 quantity ) internal virtual override { require(!paused(), "ERC721ACommon: paused"); super._beforeTokenTransfers(from, to, startTokenId, quantity); } /// @notice Overrides supportsInterface as required by inheritance. function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721A, AccessControlEnumerable, ERC2981, ERC4906) returns (bool) { return ERC721A.supportsInterface(interfaceId) || ERC2981.supportsInterface(interfaceId) || AccessControlEnumerable.supportsInterface(interfaceId) || ERC4906.supportsInterface(interfaceId); } /// @notice Sets the royalty receiver and percentage (in units of basis /// points = 0.01%). function setDefaultRoyalty(address receiver, uint96 basisPoints) public virtual onlyRole(DEFAULT_STEERING_ROLE) { _setDefaultRoyalty(receiver, basisPoints); } function emitMetadataUpdateForAll() external onlyRole(DEFAULT_STEERING_ROLE) { // EIP4906 is unfortunately quite vague on whether the `toTokenId` in // the following event is included or not. We hence use `totalSupply()` // to ensure that the last actual `tokenId` is included in any case. _refreshMetadata(0, totalSupply()); } }
// SPDX-License-Identifier: MIT // Copyright (c) 2021 the ethier authors (github.com/divergencetech/ethier) pragma solidity >=0.8.9 <0.9.0; import "./PRNG.sol"; /** * @notice Returns the next value in a shuffled list [0,n), amortising the * shuffle across all calls to _next(). Can be used for randomly allocating a * set of tokens but the caveats in `dev` docs MUST be noted. * @dev Although the final shuffle is uniformly random, it is entirely * deterministic if the seed to the PRNG.Source is known. This MUST NOT be used * for applications that require secure (i.e. can't be manipulated) allocation * unless parties who stand to gain from malicious use have no control over nor * knowledge of the seed at the time that their transaction results in a call to * next(). */ library NextShuffler { using PRNG for PRNG.Source; struct State { // Number of items already shuffled. // This is the equivalent of `i` in the Wikipedia description of the // Fisher–Yates algorithm. uint256 shuffled; // The number of items that will be shuffled. uint256 numToShuffle; // A sparse representation of the shuffled list [0,n). List items that // have been shuffled are stored with their original index as the key // and their new index + 1 as their value. Note that mappings with // numerical values return 0 for non-existent keys so we MUST increment // the new index to differentiate between a default value and a new // index of 0. See _get() and _set(). mapping(uint256 => uint256) permutation; } /** * @notice Initialises a shuffler at a given location in storage. */ function init(State storage state, uint256 numToShuffle) internal { state.numToShuffle = numToShuffle; } /** * @notice Returns the current value stored in list index `i`, accounting * for all historical shuffling. */ function _get(State storage state, uint256 i) private view returns (uint256) { uint256 val = state.permutation[i]; return val == 0 ? i : val - 1; } /** * @notice Sets the list index `i` to `val`, equivalent `arr[i] = val` in a * standard Fisher–Yates shuffle. */ function _set( State storage state, uint256 i, uint256 val ) private { state.permutation[i] = i == val ? 0 : val + 1; } /** * @notice Returns the next value in the shuffle list in O(1) time and * memory. * @dev NB: See the `dev` documentation of this contract re security (or * lack thereof) of deterministic shuffling. * @param rand Uniformly distributed random number in * [0, state.numToShuffle - state.shuffled) */ function next(State storage state, uint256 rand) internal returns (uint256) { uint256 shuffled = state.shuffled; require(!finished(state), "NextShuffler: finished"); unchecked { // Cannot overflow if rand is supplied as specified. rand += shuffled; } uint256 chosen = _get(state, rand); // Even though a full swap of the elements in the list is not needed for // the algoritm to work, we do it anyway because it allows us to restart // the shuffling. _set(state, rand, _get(state, shuffled)); _set(state, shuffled, chosen); unchecked { ++state.shuffled; } return chosen; } /** * @notice Returns the next value in the shuffle list in O(1) time and * memory together with the random number that was used for the drawing. * @dev NB: See the `dev` documentation of this contract re security (or * lack thereof) of deterministic shuffling. * @dev This is intended to be used if the random number drawn from `src` * that was used for shuffling needs to be reused for something else, e.g. * to thoroughly test the algorithm. */ function nextAndRand(State storage state, PRNG.Source src) internal returns (uint256 choice, uint256 rand) { rand = src.readLessThan(state.numToShuffle - state.shuffled); choice = next(state, rand); } /** * @notice Returns the next value in the shuffle list in O(1) time and * memory. * @dev NB: See the `dev` documentation of this contract re security (or * lack thereof) of deterministic shuffling. */ function next(State storage state, PRNG.Source src) internal returns (uint256) { (uint256 choice, ) = nextAndRand(state, src); return choice; } /** * @notice Returns a flag that indicates if the entire list has been * shuffled. */ function finished(State storage state) internal view returns (bool) { return state.shuffled >= state.numToShuffle; } /** * @notice Restarts the shuffler, such that all elements can be drawn again. * @dev Restarting does not clear the internal permutation. Running the * shuffle again with same seed after restarting might, therefore, * yield different results. */ function restart(State storage state) internal { state.shuffled = 0; } /** * @notice Resets the shuffler. */ function reset(State storage state) internal { uint256 shuffled = state.shuffled; for (uint256 i; i < shuffled; ++i) { state.permutation[i] = 0; } restart(state); } }
// SPDX-License-Identifier: MIT // Copyright (c) 2021 the ethier authors (github.com/divergencetech/ethier) pragma solidity >=0.8.9 <0.9.0; library PRNG { /** @notice A source of random numbers. @dev Pointer to a 2-word buffer of {carry || number, remaining unread bits}. however, note that this is abstracted away by the API and SHOULD NOT be used. This layout MUST NOT be considered part of the public API and therefore not relied upon even within stable versions. */ type Source is uint256; /// @notice The biggest safe prime for modulus 2**128 uint256 private constant MWC_FACTOR = 2**128 - 10408; /// @notice Layout within the buffer. 0x00 is the current (carry || number) uint256 private constant REMAIN = 0x20; /// @notice Mask for the 128 least significant bits uint256 private constant MASK_128_BITS = 0xffffffffffffffffffffffffffffffff; /** @notice Returns a new deterministic Source, differentiated only by the seed. @dev Use of PRNG.Source does NOT provide any unpredictability as generated numbers are entirely deterministic. Either a verifiable source of randomness such as Chainlink VRF, or a commit-and-reveal protocol MUST be used if unpredictability is required. The latter is only appropriate if the contract owner can be trusted within the specified threat model. @dev The 256bit seed is used to initialize carry || number */ function newSource(bytes32 seed) internal pure returns (Source src) { assembly { src := mload(0x40) mstore(0x40, add(src, 0x40)) mstore(src, seed) mstore(add(src, REMAIN), 128) } // DO NOT call _refill() on the new Source as newSource() is also used // by loadSource(), which implements its own state modifications. The // first call to read() on a fresh Source will induce a call to // _refill(). } /** @dev Computes the next PRN in entropy using a lag-1 multiply-with-carry algorithm and resets the remaining bits to 128. `nextNumber = (factor * number + carry) mod 2**128` `nextCarry = (factor * number + carry) // 2**128` */ function _refill(Source src) private pure { assembly { let carryAndNumber := mload(src) let rand := and(carryAndNumber, MASK_128_BITS) let carry := shr(128, carryAndNumber) mstore(src, add(mul(MWC_FACTOR, rand), carry)) mstore(add(src, REMAIN), 128) } } /** @notice Returns the specified number of bits <= 128 from the Source. @dev It is safe to cast the returned value to a uint<bits>. */ function read(Source src, uint256 bits) internal pure returns (uint256 sample) { require(bits <= 128, "PRNG: max 128 bits"); uint256 remain; assembly { remain := mload(add(src, REMAIN)) } if (remain > bits) { return readWithSufficient(src, bits); } uint256 extra = bits - remain; sample = readWithSufficient(src, remain); assembly { sample := shl(extra, sample) } _refill(src); sample = sample | readWithSufficient(src, extra); } /** @notice Returns the specified number of bits, assuming that there is sufficient entropy remaining. See read() for usage. */ function readWithSufficient(Source src, uint256 bits) private pure returns (uint256 sample) { assembly { let ent := mload(src) let rem := add(src, REMAIN) let remain := mload(rem) sample := shr(sub(256, bits), shl(sub(256, remain), ent)) mstore(rem, sub(remain, bits)) } } /// @notice Returns a random boolean. function readBool(Source src) internal pure returns (bool) { return read(src, 1) == 1; } /** @notice Returns the number of bits needed to encode n. @dev Useful for calling readLessThan() multiple times with the same upper bound. */ function bitLength(uint256 n) internal pure returns (uint16 bits) { assembly { for { let _n := n } gt(_n, 0) { _n := shr(1, _n) } { bits := add(bits, 1) } } } /** @notice Returns a uniformly random value in [0,n) with rejection sampling. @dev If the size of n is known, prefer readLessThan(Source, uint, uint16) as it skips the bit counting performed by this version; see bitLength(). */ function readLessThan(Source src, uint256 n) internal pure returns (uint256) { return readLessThan(src, n, bitLength(n)); } /** @notice Returns a uniformly random value in [0,n) with rejection sampling from the range [0,2^bits). @dev For greatest efficiency, the value of bits should be the smallest number of bits required to capture n; if this is not known, use readLessThan(Source, uint) or bitLength(). Although rejections are reduced by using twice the number of bits, this increases the rate at which the entropy pool must be refreshed with a call to `_refill`. TODO: benchmark higher number of bits for rejection vs hashing gas cost. */ function readLessThan( Source src, uint256 n, uint16 bits ) internal pure returns (uint256 result) { // Discard results >= n and try again because using % will bias towards // lower values; e.g. if n = 13 and we read 4 bits then {13, 14, 15}%13 // will select {0, 1, 2} twice as often as the other values. // solhint-disable-next-line no-empty-blocks for (result = n; result >= n; result = read(src, bits)) {} } /** @notice Returns the internal state of the Source. @dev MUST NOT be considered part of the API and is subject to change without deprecation nor warning. Only exposed for testing. */ function state(Source src) internal pure returns (uint256 entropy, uint256 remain) { assembly { entropy := mload(src) remain := mload(add(src, REMAIN)) } } /** @notice Stores the state of the Source in a 2-word buffer. See loadSource(). @dev The layout of the stored state MUST NOT be considered part of the public API, and is subject to change without warning. It is therefore only safe to rely on stored Sources _within_ contracts, but not _between_ them. */ function store(Source src, uint256[2] storage stored) internal { uint256 carryAndNumber; uint256 remain; assembly { carryAndNumber := mload(src) remain := mload(add(src, REMAIN)) } stored[0] = carryAndNumber; stored[1] = remain; } /** @notice Recreates a Source from the state stored with store(). */ function loadSource(uint256[2] storage stored) internal view returns (Source) { Source src = newSource(bytes32(stored[0])); uint256 carryAndNumber = stored[0]; uint256 remain = stored[1]; assembly { mstore(src, carryAndNumber) mstore(add(src, REMAIN), remain) } return src; } }
// SPDX-License-Identifier: MIT // Copyright (c) 2023 the ethier authors (github.com/divergencetech/ethier) pragma solidity >=0.8.0 <0.9.0; import {AccessControlEnumerable as ACE} from "@openzeppelin/contracts/access/AccessControlEnumerable.sol"; contract AccessControlEnumerable is ACE { /// @notice The default role intended to perform access-restricted actions. /// @dev We are using this instead of DEFAULT_ADMIN_ROLE because the latter /// is intended to grant/revoke roles and will be secured differently. bytes32 public constant DEFAULT_STEERING_ROLE = keccak256("DEFAULT_STEERING_ROLE"); /// @dev Overrides supportsInterface so that inheriting contracts can /// reference this contract instead of OZ's version for further overrides. function supportsInterface(bytes4 interfaceId) public view virtual override(ACE) returns (bool) { return ACE.supportsInterface(interfaceId); } }
// SPDX-License-Identifier: MIT // Copyright (c) 2021 the ethier authors (github.com/divergencetech/ethier) pragma solidity ^0.8.18; import {Pausable} from "@openzeppelin/contracts/security/Pausable.sol"; import {AccessControlEnumerable} from "./AccessControlEnumerable.sol"; /// @notice A Pausable contract that can only be toggled by a member of the /// STEERING role. contract AccessControlPausable is AccessControlEnumerable, Pausable { /// @notice Pauses the contract. function pause() public onlyRole(DEFAULT_STEERING_ROLE) { Pausable._pause(); } /// @notice Unpauses the contract. function unpause() public onlyRole(DEFAULT_STEERING_ROLE) { Pausable._unpause(); } }
// SPDX-License-Identifier: MIT // Copyright (c) 2022 the ethier authors (github.com/divergencetech/ethier) pragma solidity >=0.8.16 <0.9.0; import {DynamicBuffer} from "./DynamicBuffer.sol"; import {RawData} from "./RawData.sol"; /** * @notice Packs raw pixel data into the BMP format. * @dev The library assumes row-major, 24-bit BGR pixel encoding. */ library BMP { using DynamicBuffer for bytes; using RawData for bytes; error InvalidDimensions(uint256 expected, uint256 actual); error InvalidWidth(); uint8 internal constant _BMP_HEADER_SIZE = 54; /** * @notice Returns an 24-bit BMP encoding of the pixels. * @param pixels BGR tuples * @param width Number of horizontal pixels in the image * @param height Number of vertical pixels in the image */ function bmp( bytes memory pixels, uint32 width, uint32 height ) internal pure returns (bytes memory) { (, uint256 paddedLength) = computePadding(width, height); bytes memory buf = DynamicBuffer.allocate( _BMP_HEADER_SIZE + paddedLength ); appendBMP(buf, pixels, width, height); return buf; } /** * @notice Appends the 24-bit BMP encoding of the pixels to a given buffer. * @param pixels BGR tuples * @param width Number of horizontal pixels in the image * @param height Number of vertical pixels in the image */ function appendBMP( bytes memory buf, bytes memory pixels, uint32 width, uint32 height ) internal pure returns (bytes memory) { if (width * height * 3 != pixels.length) { revert InvalidDimensions(width * height * 3, pixels.length); } buf.appendSafe(header(width, height)); appendPixelsSafe(buf, pixels, width, height); return buf; } /** * @notice Returns the header for a 24-bit BMP encoded images * @param width Number of horizontal pixels in the image * @param height Number of vertical pixels in the image * @dev Spec: https://www.digicamsoft.com/bmp/bmp.html * * Layout description with offsets: * http://www.ece.ualberta.ca/~elliott/ee552/studentAppNotes/2003_w/misc/bmp_file_format/bmp_file_format.htm * * N.B. Everything is little-endian, hence the assembly for masking and * shifting. */ function header(uint32 width, uint32 height) internal pure returns (bytes memory) { // Each row of the pixel array must be padded to a multiple of 4 bytes. (, uint256 paddedLength) = computePadding(width, height); // 14 bytes for BITMAPFILEHEADER + 40 for BITMAPINFOHEADER bytes memory buf = new bytes(_BMP_HEADER_SIZE); // BITMAPFILEHEADER buf[0x00] = 0x42; buf[0x01] = 0x4d; // bfType = BM // bfSize; bytes in the entire buffer uint32 bfSize = _BMP_HEADER_SIZE + uint32(paddedLength); buf.writeUint32LE(0x02, bfSize); // Next 4 bytes are bfReserved1 & 2; both = 0 = initial value // bfOffBits; bytes from beginning of file to pixels = 14 + 40 // (see size above) buf.writeUint32LE(0x0a, _BMP_HEADER_SIZE); // BITMAPINFOHEADER // biSize; bytes in this struct = 40 buf.writeUint32LE(0x0e, 40); // biWidth / biHeight buf.writeUint32LE(0x12, width); buf.writeUint32LE(0x16, height); // biPlanes (must be 1) buf.writeUint16LE(0x1a, 0x01); // biBitCount: 24 bits per pixel (full BGR) buf.writeUint16LE(0x1c, 0x18); // biXPelsPerMeter buf.writeUint32LE(0x26, 0x01); // biYPelsPerMeter buf.writeUint32LE(0x2a, 0x01); // We use raw pixels instead of run-length encoding for compression // as these aren't being stored. It's therefore simpler to // avoid the extra computation. Therefore biSize can be 0. Similarly // there's no point checking exactly which colours are used, so // biClrUsed and biClrImportant can be 0 to indicate all colours. This // is therefore the end of BITMAPINFOHEADER. Simples. // Further we use full 24 bit BGR color values instead of an indexed // palette. RGBQUAD is hence left empty. // return abi.encodePacked(buf, pixels); return buf; } /** * @notice Appends the pixels with BMP-conform padding to a given buffer. * @dev This can be used together with `header` to build a full BMP. * @param pixels BGR tuples * @param width Number of horizontal pixels in the image * @param height Number of vertical pixels in the image */ function appendPixelsSafe( bytes memory buffer, bytes memory pixels, uint32 width, uint32 height ) internal pure { (, uint256 paddedLength) = computePadding(width, height); buffer.checkOverflow(paddedLength); appendPixelsUnchecked(buffer, pixels, width, height); } /** * @notice Appends the pixels with BMP-conform padding to a given buffer. * @dev This can be used together with `header` to build a full BMP. * @dev Does not check for out-of-bound writes. * @param pixels BGR tuples * @param width Number of horizontal pixels in the image * @param height Number of vertical pixels in the image */ function appendPixelsUnchecked( bytes memory buf, bytes memory pixels, uint32 width, uint32 height ) internal pure { // pixel data layout // // | word | word | .. | tail | // | word | word | .. | tail | // | word | word | .. | tail | // // buf data layout: // // | word | word | .. | tail | padding | // | word | word | .. | tail | padding | // | word | word | .. | tail | padding | // // Number of full words in a scan line uint256 rowWords = (width * 3) / 32; // Number of bytes remaining in a line uint256 rowTailBytes = (width * 3) % 32; // If a scan row can be divided into words without rest, move a full // word to the tail to simplify looping. if (rowTailBytes == 0) { rowWords -= 1; rowTailBytes = 32; } (uint256 padding, ) = computePadding(width, height); // If we load a full word at the tail, we can only use the first // `rowTailBytes` bytes. The rest needs to be masked uint256 tailMaskInv = ((1 << ((32 - rowTailBytes) * 8)) - 1); uint256 tailMask = 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff - tailMaskInv; assembly { let bufPtr := add(add(buf, 0x20), mload(buf)) // Loop over all rows for { let y := 0 let pixelPtr := add(pixels, 0x20) } lt(y, height) { y := add(y, 1) } { // Loop over the words in a row for { let iWord := 0 } lt(iWord, rowWords) { iWord := add(iWord, 1) pixelPtr := add(pixelPtr, 0x20) bufPtr := add(bufPtr, 0x20) } { mstore(bufPtr, mload(pixelPtr)) } // Tail mstore( bufPtr, or( and(mload(pixelPtr), tailMask), // We need to account for the fact that we potentially // write outside the buffer range here. We therefore // load the current data in the remaining bits // and set them again as they are. and(mload(bufPtr), tailMaskInv) ) ) pixelPtr := add(pixelPtr, rowTailBytes) bufPtr := add(bufPtr, add(rowTailBytes, padding)) } // Update buffer length mstore(buf, sub(bufPtr, add(buf, 0x20))) } } /** * @notice Computes the BMP-conform padding of a pixel frame. * @param width Number of horizontal pixels in the image * @param height Number of vertical pixels in the image * @return padding Number of bytes added to each row * @return paddedLength Length of the padded data */ function computePadding(uint256 width, uint256 height) internal pure returns (uint256, uint256) { uint256 stride = width * 3; uint256 padding = (4 - (stride - (((stride) >> 2) << 2))) % 4; uint256 paddedLength = height * (stride + padding); return (padding, paddedLength); } }
// SPDX-License-Identifier: MIT // Copyright (c) 2021 the ethier authors (github.com/divergencetech/ethier) pragma solidity >=0.8.0; /// @title DynamicBuffer /// @author David Huber (@cxkoda) and Simon Fremaux (@dievardump). See also /// https://raw.githubusercontent.com/dievardump/solidity-dynamic-buffer /// @notice This library is used to allocate a big amount of container memory // which will be subsequently filled without needing to reallocate /// memory. /// @dev First, allocate memory. /// Then use `buffer.appendUnchecked(theBytes)` or `appendSafe()` if /// bounds checking is required. library DynamicBuffer { /// @notice Allocates container space for the DynamicBuffer /// @param capacity_ The intended max amount of bytes in the buffer /// @return buffer The memory location of the buffer /// @dev Allocates `capacity_ + 0x60` bytes of space /// The buffer array starts at the first container data position, /// (i.e. `buffer = container + 0x20`) function allocate(uint256 capacity_) internal pure returns (bytes memory buffer) { assembly { // Get next-free memory address let container := mload(0x40) // Allocate memory by setting a new next-free address { // Add 2 x 32 bytes in size for the two length fields // Add 32 bytes safety space for 32B chunked copy let size := add(capacity_, 0x60) let newNextFree := add(container, size) mstore(0x40, newNextFree) } // Set the correct container length { let length := add(capacity_, 0x40) mstore(container, length) } // The buffer starts at idx 1 in the container (0 is length) buffer := add(container, 0x20) // Init content with length 0 mstore(buffer, 0) } return buffer; } /// @notice Appends data to buffer, and update buffer length /// @param buffer the buffer to append the data to /// @param data the data to append /// @dev Does not perform out-of-bound checks (container capacity) /// for efficiency. function appendUnchecked(bytes memory buffer, bytes memory data) internal pure { assembly { let length := mload(data) for { data := add(data, 0x20) let dataEnd := add(data, length) let copyTo := add(buffer, add(mload(buffer), 0x20)) } lt(data, dataEnd) { data := add(data, 0x20) copyTo := add(copyTo, 0x20) } { // Copy 32B chunks from data to buffer. // This may read over data array boundaries and copy invalid // bytes, which doesn't matter in the end since we will // later set the correct buffer length, and have allocated an // additional word to avoid buffer overflow. mstore(copyTo, mload(data)) } // Update buffer length mstore(buffer, add(mload(buffer), length)) } } /// @notice Appends data to buffer, and update buffer length /// @param buffer the buffer to append the data to /// @param data the data to append /// @dev Performs out-of-bound checks and calls `appendUnchecked`. function appendSafe(bytes memory buffer, bytes memory data) internal pure { checkOverflow(buffer, data.length); appendUnchecked(buffer, data); } /// @notice Appends data encoded as Base64 to buffer. /// @param fileSafe Whether to replace '+' with '-' and '/' with '_'. /// @param noPadding Whether to strip away the padding. /// @dev Encodes `data` using the base64 encoding described in RFC 4648. /// See: https://datatracker.ietf.org/doc/html/rfc4648 /// Author: Modified from Solady (https://github.com/vectorized/solady/blob/main/src/utils/Base64.sol) /// Author: Modified from Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/Base64.sol) /// Author: Modified from (https://github.com/Brechtpd/base64/blob/main/base64.sol) by Brecht Devos. function appendSafeBase64( bytes memory buffer, bytes memory data, bool fileSafe, bool noPadding ) internal pure { uint256 dataLength = data.length; if (data.length == 0) { return; } uint256 encodedLength; uint256 r; assembly { // For each 3 bytes block, we will have 4 bytes in the base64 // encoding: `encodedLength = 4 * divCeil(dataLength, 3)`. // The `shl(2, ...)` is equivalent to multiplying by 4. encodedLength := shl(2, div(add(dataLength, 2), 3)) r := mod(dataLength, 3) if noPadding { // if r == 0 => no modification // if r == 1 => encodedLength -= 2 // if r == 2 => encodedLength -= 1 encodedLength := sub( encodedLength, add(iszero(iszero(r)), eq(r, 1)) ) } } checkOverflow(buffer, encodedLength); assembly { let nextFree := mload(0x40) // Store the table into the scratch space. // Offsetted by -1 byte so that the `mload` will load the character. // We will rewrite the free memory pointer at `0x40` later with // the allocated size. mstore(0x1f, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef") mstore( 0x3f, sub( "ghijklmnopqrstuvwxyz0123456789-_", // The magic constant 0x0230 will translate "-_" + "+/". mul(iszero(fileSafe), 0x0230) ) ) // Skip the first slot, which stores the length. let ptr := add(add(buffer, 0x20), mload(buffer)) let end := add(data, dataLength) // Run over the input, 3 bytes at a time. // prettier-ignore // solhint-disable-next-line no-empty-blocks for {} 1 {} { data := add(data, 3) // Advance 3 bytes. let input := mload(data) // Write 4 bytes. Optimized for fewer stack operations. mstore8( ptr , mload(and(shr(18, input), 0x3F))) mstore8(add(ptr, 1), mload(and(shr(12, input), 0x3F))) mstore8(add(ptr, 2), mload(and(shr( 6, input), 0x3F))) mstore8(add(ptr, 3), mload(and( input , 0x3F))) ptr := add(ptr, 4) // Advance 4 bytes. // prettier-ignore if iszero(lt(data, end)) { break } } if iszero(noPadding) { // Offset `ptr` and pad with '='. We can simply write over the end. mstore8(sub(ptr, iszero(iszero(r))), 0x3d) // Pad at `ptr - 1` if `r > 0`. mstore8(sub(ptr, shl(1, eq(r, 1))), 0x3d) // Pad at `ptr - 2` if `r == 1`. } mstore(buffer, add(mload(buffer), encodedLength)) mstore(0x40, nextFree) } } /// @notice Returns the capacity of a given buffer. function capacity(bytes memory buffer) internal pure returns (uint256) { uint256 cap; assembly { cap := sub(mload(sub(buffer, 0x20)), 0x40) } return cap; } /// @notice Reverts if the buffer will overflow after appending a given /// number of bytes. function checkOverflow(bytes memory buffer, uint256 addedLength) internal pure { uint256 cap = capacity(buffer); uint256 newLength = buffer.length + addedLength; if (cap < newLength) { revert("DynamicBuffer: Appending out of bounds."); } } }
// SPDX-License-Identifier: MIT // Copyright (c) 2022 the ethier authors (github.com/divergencetech/ethier) pragma solidity >=0.8.16 <0.9.0; import {DynamicBuffer} from "./DynamicBuffer.sol"; /** * @notice The rectangle defining a pixel frame in relation to a global * index coordinate system. */ struct Rectangle { uint8 xMin; uint8 yMin; uint8 xMax; uint8 yMax; } /** * @notice Utilities library to work with raw pixel data. * @dev The code assumes (32)24-bit (A)BGR pixel encoding. * @dev Frames without any explicit rectangle information are assumed to start * at the coordinate origin `xMin = yMin = 0`. */ //solhint-disable no-empty-blocks library Image { using DynamicBuffer for bytes; /** * @notice Fills a pixel buffer with a given RGB color. */ function fill(bytes memory bgrPixels, uint24 rgb) internal pure { assembly { let bgr := shl( // Pushing the BGR tripplet all the way to the left 256 - 24 232, or( and(0x00FF00, rgb), or(shl(16, and(0xFF, rgb)), and(0xFF, shr(16, rgb))) ) ) bgr := or(bgr, shr(24, bgr)) { let bgr2 := bgr bgr := or(bgr, shr(48, bgr)) bgr := or(bgr, shr(96, bgr)) bgr := or(bgr, shr(192, bgr2)) } let bufPtr := add(bgrPixels, 0x20) let bufPtrEnd := add(bufPtr, mload(bgrPixels)) for { } 1 { } { // Stopping if we reached the end of the block. if iszero(lt(add(bufPtr, 32), bufPtrEnd)) { break } mstore(bufPtr, bgr) bufPtr := add(bufPtr, 30) } let mask := shr( shl(3, sub(bufPtrEnd, bufPtr)), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ) mstore(bufPtr, or(and(bgr, not(mask)), and(mload(bufPtr), mask))) } } /** * @notice Mask the location of the vectorised BGR channels. */ uint256 private constant _VECTORISATION_MASK = 0xFF0000000000000000FF0000000000000000FF; /** * @notice Blends two pixels depending on the alpha channel of the latter. * @dev An accuracy-focused algorithm that removes bias across color * channels. See also https://stackoverflow.com/a/1230272 * @param bgr BGR encoded pixel. * @param abgr ABGR encoded pixel with alpha channel. */ function alphaBlend(uint24 bgr, uint32 abgr) internal pure returns (uint24 res) { assembly { let a := shr(24, abgr) let na := sub(0xff, a) // Spacing the color channel values across the 256 bit word. // | 0 (13B) | R (1B) | 0 (8B) | G (1B) | 0 (8B) | R (1B) | // This allows all channels to be blended in a single operation. bgr := and( or(or(shl(128, bgr), shl(64, bgr)), bgr), _VECTORISATION_MASK ) abgr := and( or(or(shl(128, abgr), shl(64, abgr)), abgr), _VECTORISATION_MASK ) // h = alpha * fg + (255 - alpha) * bg + 128 let h := add( add(mul(a, abgr), mul(na, bgr)), // Adds 0x80 to each value 0x80000000000000000080000000000000000080 ) // h = ((h >> 8) + h) >> 8 h := and( shr(8, add(shr(8, h), h)), // Bit cleaning _VECTORISATION_MASK ) res := or(or(shr(128, h), shr(64, h)), h) } } /** * @notice Blends a background frame with foreground one depending on the * alpha channel of the latter. * @param backBgr BGR encoded pixel frame (background) * @param foreAbgr ABGR encoded pixel frame with alpha channel * (foreground) * @param width of the background frame * @param rect The frame rectangle (coordinates) of the foreground */ function alphaBlend( bytes memory backBgr, bytes memory foreAbgr, uint256 width, Rectangle memory rect ) internal pure { uint256 fgStride = (rect.xMax - rect.xMin) * 4; uint256 bgStride = width * 3; uint256 fgCursor; uint256 bgCursor; assembly { fgCursor := add(foreAbgr, 0x20) bgCursor := add(backBgr, 0x20) } // Adding the offset to the lower left corner of the foreground frame bgCursor += rect.xMin * 3 + rect.yMin * bgStride; // The background pointer jump going from the end of one row in the // foreground frame to the start of the next one. uint256 rowJump = bgStride - (rect.xMax - rect.xMin) * 3; assembly { // This computation kernel has been taken and inlined from // `alphaBlend(uint24 bgr, uint32 abgr)` for efficiency. function alphaBlend(bgrPtr, abgrPtr) { let buf := mload(bgrPtr) let bgr := shr(232, buf) let abgr := shr(224, mload(abgrPtr)) let a := shr(24, abgr) let na := sub(0xff, a) // Spacing the color channel values across the 256 bit word. // | 0 (13B) | R (1B) | 0 (8B) | G (1B) | 0 (8B) | R (1B) | // This allows all channels to be blended in a single operation. bgr := and( or(or(shl(128, bgr), shl(64, bgr)), bgr), _VECTORISATION_MASK ) abgr := and( or(or(shl(128, abgr), shl(64, abgr)), abgr), _VECTORISATION_MASK ) // h = alpha * fg + (255 - alpha) * bg + 128 let h := add( add(mul(a, abgr), mul(na, bgr)), // Adds 0x80 to each value 0x80000000000000000080000000000000000080 ) // h = ((h >> 8) + h) >> 8 h := and( shr(8, add(shr(8, h), h)), // Bit cleaning _VECTORISATION_MASK ) let res := or(or(shr(128, h), shr(64, h)), h) mstore( bgrPtr, or( shl(232, res), and( buf, 0x000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ) ) ) } // Looping over the foreground frame let fgEnd := add(fgCursor, mload(foreAbgr)) let fgIdx := 0 for { } 1 { } { // Stopping if we reached the end of the foreground frame. if iszero(lt(fgCursor, fgEnd)) { break } alphaBlend(bgCursor, fgCursor) fgIdx := add(fgIdx, 4) fgCursor := add(fgCursor, 4) bgCursor := add(bgCursor, 3) // If we are switching rows in the foreground frame, we have to // make a larger jump for the background cursor. if iszero(mod(fgIdx, fgStride)) { bgCursor := add(bgCursor, rowJump) } } } } /** * @notice Scales a pixel frame. * @param bgr BGR encoded pixel frame. * @param width of the frame. * @param pixelSize The number of bytes in a pixel. e.g. 4 for ABGR. * @param scalingFactor The scaling factor. */ function scale( bytes memory bgr, uint256 width, uint256 pixelSize, uint256 scalingFactor ) internal pure returns (bytes memory) { bytes memory buffer = DynamicBuffer.allocate( bgr.length * scalingFactor * scalingFactor ); appendSafeScaled(buffer, bgr, width, pixelSize, scalingFactor); return buffer; } /** * @notice Scales a pixel frame and appends the rescaled data to a given * buffer. * @dev This routine is compatible with ethier's `DynamicBuffer`. * @param bgr BGR encoded pixel frame. * @param width of the frame. * @param pixelSize The number of bytes in a pixel. e.g. 4 for ABGR. * @param scalingFactor The scaling factor. */ function appendSafeScaled( bytes memory buffer, bytes memory bgr, uint256 width, uint256 pixelSize, uint256 scalingFactor ) internal pure { buffer.checkOverflow(bgr.length * scalingFactor * scalingFactor); assembly { /** * @notice Fills a 2D block in memory by repeating linear chunks * e.g. * | ..................................| * | .... | chunk | chunk | tail | ... | * | .... | chunk | chunk | tail | ... | * | .... | chunk | chunk | tail | ... | * | ..................................| * where tail is a broken chunk * @param bufPtr The memory pointer to the upper left corner of the * block * @param bufStride The buffer stride, i.e. the number of bytes that * need to be added to get from one row of the buffer to the next * without changing the column (aka. the buffer width) * @param blockWidth The number of columns covered by the block * @param blockHeight The number of rows covered by the block * @param chunk The bytes that will be used to fill the block * (single word, i.e. max 32 bytes). Big endian, i.e. * chunk[:chunkSize] will be used. * @param chunkSize The size of the chunk. See above. * @param tailMask Mask the bits of the chunk that have to be used * for the tail of the block. */ function writeBlock( bufPtr, bufStride, blockWidth, blockHeight, chunk, chunkSize, tailMask ) { // The pointer to the lower right corner of the block let bufPtrEnd := add(bufPtr, mul(bufStride, blockHeight)) // Row loop for { } 1 { } { // Stopping if we reached the end of the block. if iszero(lt(bufPtr, bufPtrEnd)) { break } let rowPtr := bufPtr // Column loop // We are going to write chunks as full words for efficiency. // This might result in out-of-bound writes at the row tail // which will thus need special treatment (masking). for { // Stopping a word before the end of the chunk row to // treat the tail separately. let rowEnd := sub(add(rowPtr, blockWidth), 0x20) } 1 { } { if lt(rowEnd, rowPtr) { break } mstore(rowPtr, chunk) rowPtr := add(rowPtr, chunkSize) } // Since writing a full word would affect memory outside of // the block we load the current content and mix it with the // tail data. mstore( rowPtr, or( and(chunk, not(tailMask)), and(mload(rowPtr), tailMask) ) ) bufPtr := add(bufPtr, bufStride) } } let dataPtr := add(bgr, 0x20) let dataPtrEnd := add(dataPtr, mload(bgr)) let dataIdx := sub(dataPtr, add(bgr, 0x20)) let dataStride := mul(width, pixelSize) let chunkSize := mul(div(32, pixelSize), pixelSize) let blockWidth := mul(pixelSize, scalingFactor) let bufPtr := add(add(buffer, 0x20), mload(buffer)) let bufStride := mul(dataStride, scalingFactor) let pixelMask := not( shr( shl(3, pixelSize), // * 8 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ) ) // Binary mask for the tail of the block (i.e. the last // chunk that will only be partially written) let tailMask := shr( shl(3, mod(blockWidth, chunkSize)), // * 8 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ) // Loop over all data pixels for { } 1 { } { if iszero(lt(dataPtr, dataPtrEnd)) { break } // Building the "chunk" by repeatedly appending the pixel data // until a 256bit stack word is full let chunk := 0 for { let pixel := and(mload(dataPtr), pixelMask) let size := 0 let shift := mul(pixelSize, 8) } 1 { } { if iszero(lt(size, chunkSize)) { break } chunk := or(chunk, pixel) pixel := shr(shift, pixel) size := add(size, pixelSize) } // Fill the block with pixel data writeBlock( bufPtr, bufStride, blockWidth, scalingFactor, chunk, chunkSize, tailMask ) dataIdx := add(dataIdx, pixelSize) dataPtr := add(dataPtr, pixelSize) bufPtr := add(bufPtr, blockWidth) // If we are switching rows in the block, we have to make a // larger jump for the buffer cursor. if iszero(mod(dataIdx, dataStride)) { bufPtr := add( bufPtr, mul(sub(bufStride, dataStride), scalingFactor) ) } } // Update the length of the buffer mstore( buffer, add( mload(buffer), mul(mload(bgr), mul(scalingFactor, scalingFactor)) ) ) } } } //solhint-enable no-empty-blocks
// SPDX-License-Identifier: MIT // Copyright (c) 2021 the ethier authors (github.com/divergencetech/ethier) pragma solidity >=0.8.0 <0.9.0; /** @notice Provides monotonic increasing and decreasing values, similar to OpenZeppelin's Counter but (a) limited in direction, and (b) allowing for steps > 1. */ library Monotonic { /** @notice Holds a value that can only increase. @dev The internal value MUST NOT be accessed directly. Instead use current() and add(). */ struct Increaser { uint256 value; } /// @notice Returns the current value of the Increaser. function current(Increaser storage incr) internal view returns (uint256) { return incr.value; } /// @notice Adds x to the Increaser's value. function add(Increaser storage incr, uint256 x) internal { incr.value += x; } /** @notice Holds a value that can only decrease. @dev The internal value MUST NOT be accessed directly. Instead use current() and subtract(). */ struct Decreaser { uint256 value; } /// @notice Returns the current value of the Decreaser. function current(Decreaser storage decr) internal view returns (uint256) { return decr.value; } /// @notice Subtracts x from the Decreaser's value. function subtract(Decreaser storage decr, uint256 x) internal { decr.value -= x; } }
// SPDX-License-Identifier: MIT // Copyright (c) 2022 the ethier authors (github.com/divergencetech/ethier) pragma solidity >=0.8.16 <0.9.0; /** * @notice Utility library to work with raw bytes data. */ library RawData { /** * @notice Return the byte at the given index interpreted as bool. * @dev Any non-zero value is interpreted as true. */ function getBool(bytes memory data, uint256 idx) internal pure returns (bool value) { return data[idx] != 0; } /** * @notice Clones a bytes array. */ function clone(bytes memory data) internal pure returns (bytes memory) { uint256 len = data.length; bytes memory buf = new bytes(len); uint256 nFullWords = (len - 1) / 32; // At the end of data we might still have a few bytes that don't make // up a full 32-bytes word. // ... [nTailBytes | 32 - nTailBytes -> dirty] // So if we again copied a full word for efficiency it would also // include some dirty bytes that need to be cleaned first. uint256 nTailBytes = len - nFullWords * 32; uint256 mask = 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff << ((32 - nTailBytes) * 8); assembly { let src := add(data, 0x20) let dst := add(buf, 0x20) for { let end := add(src, mul(0x20, nFullWords)) } lt(src, end) { src := add(src, 0x20) dst := add(dst, 0x20) } { mstore(dst, mload(src)) } mstore(dst, and(mload(src), mask)) } return buf; } /** * @notice Reads a big-endian-encoded, 16-bit, unsigned interger from a * given offset in a bytes array. * @param data The bytes array * @param offset The index of the byte in the array at which we start reading. * @dev Equivalent to `(uint(data[offset]) << 8) + uint(data[offset + 1])` */ function getUint16(bytes memory data, uint256 offset) internal pure returns (uint16 value) { assembly { value := shr(240, mload(add(data, add(0x20, offset)))) } } /** * @notice Removes and returns the first byte of an array. */ function popByteFront(bytes memory data) internal pure returns (bytes memory, bytes1) { bytes1 ret = data[0]; uint256 len = data.length - 1; assembly { data := add(data, 1) mstore(data, len) } return (data, ret); } /** * @notice Removes and returns the first DWORD (4bytes) of an array. */ function popDWORDFront(bytes memory data) internal pure returns (bytes memory, bytes4) { bytes4 ret; uint256 len = data.length - 4; assembly { ret := mload(add(data, 0x20)) data := add(data, 4) mstore(data, len) } return (data, ret); } /** * @notice Writes an uint32 in little-ending encoding to a given location in * bytes array. */ function writeUint32LE( bytes memory buf, uint256 pos, uint32 data ) internal pure { buf[pos] = bytes1(uint8(data)); buf[pos + 1] = bytes1(uint8(data >> 8)); buf[pos + 2] = bytes1(uint8(data >> 16)); buf[pos + 3] = bytes1(uint8(data >> 24)); } /** * @notice Writes an uint16 in little-ending encoding to a given location in * bytes array. */ function writeUint16LE( bytes memory buf, uint256 pos, uint16 data ) internal pure { buf[pos] = bytes1(uint8(data)); buf[pos + 1] = bytes1(uint8(data >> 8)); } /** * @notice Returns a slice of a bytes array. * @dev The old array can no longer be used. * Intended syntax: `data = data.slice(from, len)` */ function slice( bytes memory data, uint256 from, uint256 len ) internal pure returns (bytes memory) { assembly { data := add(data, from) mstore(data, len) } return data; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (access/AccessControl.sol) pragma solidity ^0.8.0; import "./IAccessControl.sol"; import "../utils/Context.sol"; import "../utils/Strings.sol"; import "../utils/introspection/ERC165.sol"; /** * @dev Contract module that allows children to implement role-based access * control mechanisms. This is a lightweight version that doesn't allow enumerating role * members except through off-chain means by accessing the contract event logs. Some * applications may benefit from on-chain enumerability, for those cases see * {AccessControlEnumerable}. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ``` * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ``` * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. */ abstract contract AccessControl is Context, IAccessControl, ERC165 { struct RoleData { mapping(address => bool) members; bytes32 adminRole; } mapping(bytes32 => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Modifier that checks that an account has a specific role. Reverts * with a standardized message including the required role. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ * * _Available since v4.1._ */ modifier onlyRole(bytes32 role) { _checkRole(role); _; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view virtual override returns (bool) { return _roles[role].members[account]; } /** * @dev Revert with a standard message if `_msgSender()` is missing `role`. * Overriding this function changes the behavior of the {onlyRole} modifier. * * Format of the revert message is described in {_checkRole}. * * _Available since v4.6._ */ function _checkRole(bytes32 role) internal view virtual { _checkRole(role, _msgSender()); } /** * @dev Revert with a standard message if `account` is missing `role`. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ */ function _checkRole(bytes32 role, address account) internal view virtual { if (!hasRole(role, account)) { revert( string( abi.encodePacked( "AccessControl: account ", Strings.toHexString(uint160(account), 20), " is missing role ", Strings.toHexString(uint256(role), 32) ) ) ); } } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) { return _roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. * * May emit a {RoleGranted} event. */ function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. * * May emit a {RoleRevoked} event. */ function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been revoked `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. * * May emit a {RoleRevoked} event. */ function renounceRole(bytes32 role, address account) public virtual override { require(account == _msgSender(), "AccessControl: can only renounce roles for self"); _revokeRole(role, account); } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. Note that unlike {grantRole}, this function doesn't perform any * checks on the calling account. * * May emit a {RoleGranted} event. * * [WARNING] * ==== * This function should only be called from the constructor when setting * up the initial roles for the system. * * Using this function in any other way is effectively circumventing the admin * system imposed by {AccessControl}. * ==== * * NOTE: This function is deprecated in favor of {_grantRole}. */ function _setupRole(bytes32 role, address account) internal virtual { _grantRole(role, account); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { bytes32 previousAdminRole = getRoleAdmin(role); _roles[role].adminRole = adminRole; emit RoleAdminChanged(role, previousAdminRole, adminRole); } /** * @dev Grants `role` to `account`. * * Internal function without access restriction. * * May emit a {RoleGranted} event. */ function _grantRole(bytes32 role, address account) internal virtual { if (!hasRole(role, account)) { _roles[role].members[account] = true; emit RoleGranted(role, account, _msgSender()); } } /** * @dev Revokes `role` from `account`. * * Internal function without access restriction. * * May emit a {RoleRevoked} event. */ function _revokeRole(bytes32 role, address account) internal virtual { if (hasRole(role, account)) { _roles[role].members[account] = false; emit RoleRevoked(role, account, _msgSender()); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (access/AccessControlEnumerable.sol) pragma solidity ^0.8.0; import "./IAccessControlEnumerable.sol"; import "./AccessControl.sol"; import "../utils/structs/EnumerableSet.sol"; /** * @dev Extension of {AccessControl} that allows enumerating the members of each role. */ abstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl { using EnumerableSet for EnumerableSet.AddressSet; mapping(bytes32 => EnumerableSet.AddressSet) private _roleMembers; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns one of the accounts that have `role`. `index` must be a * value between 0 and {getRoleMemberCount}, non-inclusive. * * Role bearers are not sorted in any particular way, and their ordering may * change at any point. * * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure * you perform all queries on the same block. See the following * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] * for more information. */ function getRoleMember(bytes32 role, uint256 index) public view virtual override returns (address) { return _roleMembers[role].at(index); } /** * @dev Returns the number of accounts that have `role`. Can be used * together with {getRoleMember} to enumerate all bearers of a role. */ function getRoleMemberCount(bytes32 role) public view virtual override returns (uint256) { return _roleMembers[role].length(); } /** * @dev Overload {_grantRole} to track enumerable memberships */ function _grantRole(bytes32 role, address account) internal virtual override { super._grantRole(role, account); _roleMembers[role].add(account); } /** * @dev Overload {_revokeRole} to track enumerable memberships */ function _revokeRole(bytes32 role, address account) internal virtual override { super._revokeRole(role, account); _roleMembers[role].remove(account); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol) pragma solidity ^0.8.0; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControl { /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {AccessControl-_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) external view returns (bool); /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {AccessControl-_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) external view returns (bytes32); /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) external; /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) external; /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/IAccessControlEnumerable.sol) pragma solidity ^0.8.0; import "./IAccessControl.sol"; /** * @dev External interface of AccessControlEnumerable declared to support ERC165 detection. */ interface IAccessControlEnumerable is IAccessControl { /** * @dev Returns one of the accounts that have `role`. `index` must be a * value between 0 and {getRoleMemberCount}, non-inclusive. * * Role bearers are not sorted in any particular way, and their ordering may * change at any point. * * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure * you perform all queries on the same block. See the following * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] * for more information. */ function getRoleMember(bytes32 role, uint256 index) external view returns (address); /** * @dev Returns the number of accounts that have `role`. Can be used * together with {getRoleMember} to enumerate all bearers of a role. */ function getRoleMemberCount(bytes32 role) external view returns (uint256); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { _checkOwner(); _; } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if the sender is not the owner. */ function _checkOwner() internal view virtual { require(owner() == _msgSender(), "Ownable: caller is not the owner"); } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (interfaces/IERC2981.sol) pragma solidity ^0.8.0; import "../utils/introspection/IERC165.sol"; /** * @dev Interface for the NFT Royalty Standard. * * A standardized way to retrieve royalty payment information for non-fungible tokens (NFTs) to enable universal * support for royalty payments across all NFT marketplaces and ecosystem participants. * * _Available since v4.5._ */ interface IERC2981 is IERC165 { /** * @dev Returns how much royalty is owed and to whom, based on a sale price that may be denominated in any unit of * exchange. The royalty amount is denominated and should be paid in that same unit of exchange. */ function royaltyInfo(uint256 tokenId, uint256 salePrice) external view returns (address receiver, uint256 royaltyAmount); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract Pausable is Context { /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. */ constructor() { _paused = false; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { _requireNotPaused(); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { _requirePaused(); _; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { return _paused; } /** * @dev Throws if the contract is paused. */ function _requireNotPaused() internal view virtual { require(!paused(), "Pausable: paused"); } /** * @dev Throws if the contract is not paused. */ function _requirePaused() internal view virtual { require(paused(), "Pausable: not paused"); } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol) pragma solidity ^0.8.0; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuard { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; constructor() { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and making it call a * `private` function that does the actual work. */ modifier nonReentrant() { // On the first call to nonReentrant, _notEntered will be true require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (token/common/ERC2981.sol) pragma solidity ^0.8.0; import "../../interfaces/IERC2981.sol"; import "../../utils/introspection/ERC165.sol"; /** * @dev Implementation of the NFT Royalty Standard, a standardized way to retrieve royalty payment information. * * Royalty information can be specified globally for all token ids via {_setDefaultRoyalty}, and/or individually for * specific token ids via {_setTokenRoyalty}. The latter takes precedence over the first. * * Royalty is specified as a fraction of sale price. {_feeDenominator} is overridable but defaults to 10000, meaning the * fee is specified in basis points by default. * * IMPORTANT: ERC-2981 only specifies a way to signal royalty information and does not enforce its payment. See * https://eips.ethereum.org/EIPS/eip-2981#optional-royalty-payments[Rationale] in the EIP. Marketplaces are expected to * voluntarily pay royalties together with sales, but note that this standard is not yet widely supported. * * _Available since v4.5._ */ abstract contract ERC2981 is IERC2981, ERC165 { struct RoyaltyInfo { address receiver; uint96 royaltyFraction; } RoyaltyInfo private _defaultRoyaltyInfo; mapping(uint256 => RoyaltyInfo) private _tokenRoyaltyInfo; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC165) returns (bool) { return interfaceId == type(IERC2981).interfaceId || super.supportsInterface(interfaceId); } /** * @inheritdoc IERC2981 */ function royaltyInfo(uint256 _tokenId, uint256 _salePrice) public view virtual override returns (address, uint256) { RoyaltyInfo memory royalty = _tokenRoyaltyInfo[_tokenId]; if (royalty.receiver == address(0)) { royalty = _defaultRoyaltyInfo; } uint256 royaltyAmount = (_salePrice * royalty.royaltyFraction) / _feeDenominator(); return (royalty.receiver, royaltyAmount); } /** * @dev The denominator with which to interpret the fee set in {_setTokenRoyalty} and {_setDefaultRoyalty} as a * fraction of the sale price. Defaults to 10000 so fees are expressed in basis points, but may be customized by an * override. */ function _feeDenominator() internal pure virtual returns (uint96) { return 10000; } /** * @dev Sets the royalty information that all ids in this contract will default to. * * Requirements: * * - `receiver` cannot be the zero address. * - `feeNumerator` cannot be greater than the fee denominator. */ function _setDefaultRoyalty(address receiver, uint96 feeNumerator) internal virtual { require(feeNumerator <= _feeDenominator(), "ERC2981: royalty fee will exceed salePrice"); require(receiver != address(0), "ERC2981: invalid receiver"); _defaultRoyaltyInfo = RoyaltyInfo(receiver, feeNumerator); } /** * @dev Removes default royalty information. */ function _deleteDefaultRoyalty() internal virtual { delete _defaultRoyaltyInfo; } /** * @dev Sets the royalty information for a specific token id, overriding the global default. * * Requirements: * * - `receiver` cannot be the zero address. * - `feeNumerator` cannot be greater than the fee denominator. */ function _setTokenRoyalty( uint256 tokenId, address receiver, uint96 feeNumerator ) internal virtual { require(feeNumerator <= _feeDenominator(), "ERC2981: royalty fee will exceed salePrice"); require(receiver != address(0), "ERC2981: Invalid parameters"); _tokenRoyaltyInfo[tokenId] = RoyaltyInfo(receiver, feeNumerator); } /** * @dev Resets royalty information for the token id back to the global default. */ function _resetTokenRoyalty(uint256 tokenId) internal virtual { delete _tokenRoyaltyInfo[tokenId]; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (utils/Base64.sol) pragma solidity ^0.8.0; /** * @dev Provides a set of functions to operate with Base64 strings. * * _Available since v4.5._ */ library Base64 { /** * @dev Base64 Encoding/Decoding Table */ string internal constant _TABLE = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; /** * @dev Converts a `bytes` to its Bytes64 `string` representation. */ function encode(bytes memory data) internal pure returns (string memory) { /** * Inspired by Brecht Devos (Brechtpd) implementation - MIT licence * https://github.com/Brechtpd/base64/blob/e78d9fd951e7b0977ddca77d92dc85183770daf4/base64.sol */ if (data.length == 0) return ""; // Loads the table into memory string memory table = _TABLE; // Encoding takes 3 bytes chunks of binary data from `bytes` data parameter // and split into 4 numbers of 6 bits. // The final Base64 length should be `bytes` data length multiplied by 4/3 rounded up // - `data.length + 2` -> Round up // - `/ 3` -> Number of 3-bytes chunks // - `4 *` -> 4 characters for each chunk string memory result = new string(4 * ((data.length + 2) / 3)); /// @solidity memory-safe-assembly assembly { // Prepare the lookup table (skip the first "length" byte) let tablePtr := add(table, 1) // Prepare result pointer, jump over length let resultPtr := add(result, 32) // Run over the input, 3 bytes at a time for { let dataPtr := data let endPtr := add(data, mload(data)) } lt(dataPtr, endPtr) { } { // Advance 3 bytes dataPtr := add(dataPtr, 3) let input := mload(dataPtr) // To write each character, shift the 3 bytes (18 bits) chunk // 4 times in blocks of 6 bits for each character (18, 12, 6, 0) // and apply logical AND with 0x3F which is the number of // the previous character in the ASCII table prior to the Base64 Table // The result is then added to the table to get the character to write, // and finally write it in the result pointer but with a left shift // of 256 (1 byte) - 8 (1 ASCII char) = 248 bits mstore8(resultPtr, mload(add(tablePtr, and(shr(18, input), 0x3F)))) resultPtr := add(resultPtr, 1) // Advance mstore8(resultPtr, mload(add(tablePtr, and(shr(12, input), 0x3F)))) resultPtr := add(resultPtr, 1) // Advance mstore8(resultPtr, mload(add(tablePtr, and(shr(6, input), 0x3F)))) resultPtr := add(resultPtr, 1) // Advance mstore8(resultPtr, mload(add(tablePtr, and(input, 0x3F)))) resultPtr := add(resultPtr, 1) // Advance } // When data `bytes` is not exactly 3 bytes long // it is padded with `=` characters at the end switch mod(mload(data), 3) case 1 { mstore8(sub(resultPtr, 1), 0x3d) mstore8(sub(resultPtr, 2), 0x3d) } case 2 { mstore8(sub(resultPtr, 1), 0x3d) } } return result; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (utils/math/Math.sol) pragma solidity ^0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { enum Rounding { Down, // Toward negative infinity Up, // Toward infinity Zero // Toward zero } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a >= b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds up instead * of rounding down. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b - 1) / b can overflow on addition, so we distribute. return a == 0 ? 0 : (a - 1) / b + 1; } /** * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) * with further edits by Uniswap Labs also under MIT license. */ function mulDiv( uint256 x, uint256 y, uint256 denominator ) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2^256 + prod0. uint256 prod0; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod0 := mul(x, y) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. require(denominator > prod1); /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. uint256 remainder; assembly { // Compute remainder using mulmod. remainder := mulmod(x, y, denominator) // Subtract 256 bit number from 512 bit number. prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1. // See https://cs.stackexchange.com/q/138556/92363. // Does not overflow because the denominator cannot be zero at this stage in the function. uint256 twos = denominator & (~denominator + 1); assembly { // Divide denominator by twos. denominator := div(denominator, twos) // Divide [prod1 prod0] by twos. prod0 := div(prod0, twos) // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one. twos := add(div(sub(0, twos), twos), 1) } // Shift in bits from prod1 into prod0. prod0 |= prod1 * twos; // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv = 1 mod 2^4. uint256 inverse = (3 * denominator) ^ 2; // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works // in modular arithmetic, doubling the correct bits in each step. inverse *= 2 - denominator * inverse; // inverse mod 2^8 inverse *= 2 - denominator * inverse; // inverse mod 2^16 inverse *= 2 - denominator * inverse; // inverse mod 2^32 inverse *= 2 - denominator * inverse; // inverse mod 2^64 inverse *= 2 - denominator * inverse; // inverse mod 2^128 inverse *= 2 - denominator * inverse; // inverse mod 2^256 // Because the division is now exact we can divide by multiplying with the modular inverse of denominator. // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inverse; return result; } } /** * @notice Calculates x * y / denominator with full precision, following the selected rounding direction. */ function mulDiv( uint256 x, uint256 y, uint256 denominator, Rounding rounding ) internal pure returns (uint256) { uint256 result = mulDiv(x, y, denominator); if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) { result += 1; } return result; } /** * @dev Returns the square root of a number. It the number is not a perfect square, the value is rounded down. * * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11). */ function sqrt(uint256 a) internal pure returns (uint256) { if (a == 0) { return 0; } // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target. // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have // `msb(a) <= a < 2*msb(a)`. // We also know that `k`, the position of the most significant bit, is such that `msb(a) = 2**k`. // This gives `2**k < a <= 2**(k+1)` → `2**(k/2) <= sqrt(a) < 2 ** (k/2+1)`. // Using an algorithm similar to the msb conmputation, we are able to compute `result = 2**(k/2)` which is a // good first aproximation of `sqrt(a)` with at least 1 correct bit. uint256 result = 1; uint256 x = a; if (x >> 128 > 0) { x >>= 128; result <<= 64; } if (x >> 64 > 0) { x >>= 64; result <<= 32; } if (x >> 32 > 0) { x >>= 32; result <<= 16; } if (x >> 16 > 0) { x >>= 16; result <<= 8; } if (x >> 8 > 0) { x >>= 8; result <<= 4; } if (x >> 4 > 0) { x >>= 4; result <<= 2; } if (x >> 2 > 0) { result <<= 1; } // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128, // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision // into the expected uint128 result. unchecked { result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; return min(result, a / result); } } /** * @notice Calculates sqrt(a), following the selected rounding direction. */ function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) { uint256 result = sqrt(a); if (rounding == Rounding.Up && result * result < a) { result += 1; } return result; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol) pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; uint8 private constant _ADDRESS_LENGTH = 20; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } /** * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation. */ function toHexString(address addr) internal pure returns (string memory) { return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (utils/structs/EnumerableSet.sol) pragma solidity ^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. * * [WARNING] * ==== * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure unusable. * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info. * * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an array of EnumerableSet. * ==== */ 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; if (lastIndex != toDeleteIndex) { 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] = valueIndex; // Replace lastValue's index to valueIndex } // 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) { return set._values[index]; } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function _values(Set storage set) private view returns (bytes32[] memory) { return set._values; } // 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); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(Bytes32Set storage set) internal view returns (bytes32[] memory) { return _values(set._inner); } // 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)))); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(AddressSet storage set) internal view returns (address[] memory) { bytes32[] memory store = _values(set._inner); address[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } // 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)); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(UintSet storage set) internal view returns (uint256[] memory) { bytes32[] memory store = _values(set._inner); uint256[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } }
// solhint-disable no-global-import // SPDX-License-Identifier: MIT // Copyright (c) 2022 the ethier authors (github.com/divergencetech/ethier) pragma solidity ^0.8.19; import "./Seller.sol"; /** @dev The Seller base contract has a convenience function _purchase(to,n) that calls the standard function as _purchase(to,n,0). This would result in a free purchase, to the convenience variant is overriden and always reverts with this error. */ error ImplicitFreePurchase(); /** @notice A Seller with an arbitrary price passed in externally. */ abstract contract ArbitraryPriceSeller is Seller { constructor( Seller.SellerConfig memory sellerConfig, address payable _beneficiary ) Seller(sellerConfig, _beneficiary) {} // solhint-disable-line no-empty-blocks /** @notice Block accidental usage of the convenience function that would default to a free sale. */ function _purchase(address, uint256) internal pure override { revert ImplicitFreePurchase(); } /** @notice Override of Seller.cost() with price passed via metadata. @return n*costEach; */ function cost(uint256 n, uint256 costEach) public pure override returns (uint256) { return n * costEach; } }
// solhint-disable no-global-import // SPDX-License-Identifier: MIT // Copyright (c) 2021 the ethier authors (github.com/divergencetech/ethier) pragma solidity ^0.8.19; import "@divergencetech/ethier/contracts/utils/Monotonic.sol"; import "@divergencetech/ethier/contracts/utils/AccessControlPausable.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; import "@openzeppelin/contracts/utils/Address.sol"; import "@openzeppelin/contracts/utils/Context.sol"; import "@openzeppelin/contracts/utils/math/Math.sol"; import "@openzeppelin/contracts/utils/Strings.sol"; /** @notice An abstract contract providing the _purchase() function to: - Enforce per-wallet / per-transaction limits - Calculate required cost, forwarding to a beneficiary, and refunding extra */ abstract contract Seller is Ownable, AccessControlPausable, ReentrancyGuard { using Address for address payable; using Monotonic for Monotonic.Increaser; using Strings for uint256; /** @dev Note that the address limits are vulnerable to wallet farming. @param maxPerAddress Unlimited if zero. @param maxPerTex Unlimited if zero. @param freeQuota Maximum number that can be purchased free of charge by the contract owner. @param reserveFreeQuota Whether to excplitly reserve the freeQuota amount and not let it be eroded by regular purchases. @param lockFreeQuota If true, calls to setSellerConfig() will ignore changes to freeQuota. Can be locked after initial setting, but not unlocked. This allows a contract owner to commit to a maximum number of reserved items. @param lockTotalInventory Similar to lockFreeQuota but applied to totalInventory. */ struct SellerConfig { uint256 totalInventory; uint256 maxPerAddress; uint256 maxPerTx; uint248 freeQuota; bool reserveFreeQuota; bool lockFreeQuota; bool lockTotalInventory; } constructor(SellerConfig memory config, address payable _beneficiary) { setSellerConfig(config); setBeneficiary(_beneficiary); } /// @notice Configuration of purchase limits. SellerConfig public sellerConfig; /// @notice Sets the seller config. function setSellerConfig(SellerConfig memory config) public onlyOwner { require( config.totalInventory >= config.freeQuota, "Seller: excessive free quota" ); require( config.totalInventory >= _totalSold.current(), "Seller: inventory < already sold" ); require( config.freeQuota >= purchasedFreeOfCharge.current(), "Seller: free quota < already used" ); // Overriding the in-memory fields before copying the whole struct, as // against writing individual fields, gives a greater guarantee of // correctness as the code is simpler to read. if (sellerConfig.lockTotalInventory) { config.lockTotalInventory = true; config.totalInventory = sellerConfig.totalInventory; } if (sellerConfig.lockFreeQuota) { config.lockFreeQuota = true; config.freeQuota = sellerConfig.freeQuota; } sellerConfig = config; } /// @notice Recipient of revenues. address payable public beneficiary; /// @notice Sets the recipient of revenues. function setBeneficiary(address payable _beneficiary) public onlyOwner { beneficiary = _beneficiary; } /** @dev Must return the current cost of a batch of items. This may be constant or, for example, decreasing for a Dutch auction or increasing for a bonding curve. @param n The number of items being purchased. @param metadata Arbitrary data, propagated by the call to _purchase() that can be used to charge different prices. This value is a uint256 instead of bytes as this allows simple passing of a set cost (see ArbitraryPriceSeller). */ function cost(uint256 n, uint256 metadata) public view virtual returns (uint256); /** @dev Called by both _purchase() and purchaseFreeOfCharge() after all limits have been put in place; must perform all contract-specific sale logic, e.g. ERC721 minting. When _handlePurchase() is called, the value returned by Seller.totalSold() will be the POST-purchase amount to allow for the checks-effects-interactions (ECI) pattern as _handlePurchase() may include an interaction. _handlePurchase() MUST itself implement the CEI pattern. @param to The recipient of the item(s). @param n The number of items allowed to be purchased, which MAY be less than to the number passed to _purchase() but SHALL be greater than zero. @param freeOfCharge Indicates that the call originated from purchaseFreeOfCharge() and not _purchase(). */ function _handlePurchase( address to, uint256 n, bool freeOfCharge ) internal virtual; /** @notice Tracks total number of items sold by this contract, including those purchased free of charge by the contract owner. */ Monotonic.Increaser private _totalSold; /// @notice Returns the total number of items sold by this contract. function totalSold() public view returns (uint256) { return _totalSold.current(); } /** @notice Tracks the number of items already bought by an address, regardless of transferring out (in the case of ERC721). @dev This isn't public as it may be skewed due to differences in msg.sender and tx.origin, which it treats in the same way such that sum(_bought)>=totalSold(). */ mapping(address => uint256) private _bought; /** @notice Returns min(n, max(extra items addr can purchase)) and reverts if 0. @param zeroMsg The message with which to revert on 0 extra. */ function _capExtra( uint256 n, address addr, string memory zeroMsg ) internal view returns (uint256) { uint256 extra = sellerConfig.maxPerAddress - _bought[addr]; if (extra == 0) { revert(string(abi.encodePacked("Seller: ", zeroMsg))); } return Math.min(n, extra); } /// @notice Emitted when a buyer is refunded. event Refund(address indexed buyer, uint256 amount); /// @notice Emitted on all purchases of non-zero amount. event Revenue( address indexed beneficiary, uint256 numPurchased, uint256 amount ); /// @notice Tracks number of items purchased free of charge. Monotonic.Increaser private purchasedFreeOfCharge; /** @notice Allows the contract owner to purchase without payment, within the quota enforced by the SellerConfig. */ function purchaseFreeOfCharge(address to, uint256 n) public onlyOwner whenNotPaused { /** * ##### CHECKS */ uint256 freeQuota = sellerConfig.freeQuota; n = Math.min(n, freeQuota - purchasedFreeOfCharge.current()); require(n > 0, "Seller: Free quota exceeded"); uint256 totalInventory = sellerConfig.totalInventory; n = Math.min(n, totalInventory - _totalSold.current()); require(n > 0, "Seller: Sold out"); /** * ##### EFFECTS */ _totalSold.add(n); purchasedFreeOfCharge.add(n); /** * ##### INTERACTIONS */ _handlePurchase(to, n, true); assert(_totalSold.current() <= totalInventory); assert(purchasedFreeOfCharge.current() <= freeQuota); } /** @notice Convenience function for calling _purchase() with empty costMetadata when unneeded. */ function _purchase(address to, uint256 requested) internal virtual { _purchase(to, requested, 0); } /** @notice Enforces all purchase limits (counts and costs) before calling _handlePurchase(), after which the received funds are disbursed to the beneficiary, less any required refunds. @param to The final recipient of the item(s). @param requested The number of items requested for purchase, which MAY be reduced when passed to _handlePurchase(). @param costMetadata Arbitrary data, propagated in the call to cost(), to be optionally used in determining the price. */ function _purchase( address to, uint256 requested, uint256 costMetadata ) internal nonReentrant whenNotPaused { /** * ##### CHECKS */ SellerConfig memory config = sellerConfig; uint256 n = config.maxPerTx == 0 ? requested : Math.min(requested, config.maxPerTx); uint256 maxAvailable; uint256 sold; if (config.reserveFreeQuota) { maxAvailable = config.totalInventory - config.freeQuota; sold = _totalSold.current() - purchasedFreeOfCharge.current(); } else { maxAvailable = config.totalInventory; sold = _totalSold.current(); } n = Math.min(n, maxAvailable - sold); require(n > 0, "Seller: Sold out"); if (config.maxPerAddress > 0) { bool alsoLimitSender = _msgSender() != to; // solhint-disable-next-line avoid-tx-origin bool alsoLimitOrigin = tx.origin != _msgSender() && tx.origin != to; n = _capExtra(n, to, "Buyer limit"); if (alsoLimitSender) { n = _capExtra(n, _msgSender(), "Sender limit"); } if (alsoLimitOrigin) { // solhint-disable-next-line avoid-tx-origin n = _capExtra(n, tx.origin, "Origin limit"); } _bought[to] += n; if (alsoLimitSender) { _bought[_msgSender()] += n; } if (alsoLimitOrigin) { // solhint-disable-next-line avoid-tx-origin _bought[tx.origin] += n; } } uint256 _cost = cost(n, costMetadata); if (msg.value < _cost) { revert( string( abi.encodePacked( "Seller: Costs ", (_cost / 1e9).toString(), " GWei" ) ) ); } /** * ##### EFFECTS */ _totalSold.add(n); assert(_totalSold.current() <= config.totalInventory); /** * ##### INTERACTIONS */ // As _handlePurchase() is often an ERC721 safeMint(), it constitutes an // interaction. _handlePurchase(to, n, false); // Ideally we'd be using a PullPayment here, but the user experience is // poor when there's a variable cost or the number of items purchased // has been capped. We've addressed reentrancy with both a nonReentrant // modifier and the checks, effects, interactions pattern. if (_cost > 0) { beneficiary.sendValue(_cost); emit Revenue(beneficiary, n, _cost); } if (msg.value > _cost) { address payable reimburse = payable(_msgSender()); uint256 refund = msg.value - _cost; // Using Address.sendValue() here would mask the revertMsg upon // reentrancy, but we want to expose it to allow for more precise // testing. This otherwise uses the exact same pattern as // Address.sendValue(). // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returnData) = reimburse.call{ value: refund }(""); // Although `returnData` will have a spurious prefix, all we really // care about is that it contains the ReentrancyGuard reversion // message so we can check in the tests. require(success, string(returnData)); emit Refund(reimburse, refund); } } }
// SPDX-License-Identifier: CC0-1.0 pragma solidity ^0.8.19; struct RenderInfo { uint72 encoded; bool revealed; uint256[] traitCounts; uint256 tokenId; uint256 slot1; uint256 slot2; uint256 slot3; } interface IRender { function render( RenderInfo calldata r ) external view returns (bytes memory bgr); }
// SPDX-License-Identifier: CC0-1.0 pragma solidity ^0.8.19; interface IStringBank { function getString(uint256 index) external view returns (bytes memory value); }
// SPDX-License-Identifier: CC0-1.0 pragma solidity ^0.8.19; interface ISVGWrapper { struct Size { uint256 width; uint256 height; } function getWrappedImage( bytes memory imageUri, Size memory size ) external view returns (bytes memory imageDataUri); }
// SPDX-License-Identifier: CC0-1.0 pragma solidity ^0.8.19; interface ITokenURI { function tokenURI(uint256 tokenId) external view returns (string memory); }
// SPDX-License-Identifier: CC0-1.0 pragma solidity ^0.8.19; import "./ISVGWrapper.sol"; struct TokenURIOptions { bytes imageUri; bytes attributes; uint256 tokenId; string description; string externalUrl; string prefix; } enum SVGWrapperTarget { ImageDataWithNativeImage, ImageData, Image, None } interface ITokenURIBuilder { function encode(TokenURIOptions calldata options) external view returns (bytes memory); function encodeSVGWrapped(TokenURIOptions calldata options, ISVGWrapper svg, SVGWrapperTarget target, uint256 width, uint256 height) external view returns (bytes memory); }
// SPDX-License-Identifier: CC0-1.0 pragma solidity ^0.8.19; interface ITraits { function getTraits( uint72 encoded ) external view returns (bytes memory attributes); }
// SPDX-License-Identifier: CC0-1.0 // solhint-disable no-global-import pragma solidity ^0.8.19; import "@openzeppelin/contracts/access/Ownable.sol"; import "./StringBank.sol"; contract MetadataStrings is Ownable { mapping(uint256 => address) private _banks; bytes private _missing; function getString( uint256 bank, uint256 index ) external view returns (bytes memory value) { value = IStringBank(_banks[bank]).getString(index); if (value.length == 0) { value = _missing; } } function setBanks(address[] calldata addresses_) external onlyOwner { for (uint256 i; i < addresses_.length; i++) { _banks[i] = addresses_[i]; } } function setMissing(string calldata missing_) external onlyOwner { _missing = bytes(missing_); } }
// SPDX-License-Identifier: CC0-1.0 // solhint-disable no-global-import pragma solidity ^0.8.19; import "./IStringBank.sol"; contract StringBank is IStringBank { mapping(uint256 => bytes) private strings; function addString(uint256 index, bytes memory value) internal { strings[index] = value; } function getString(uint256 index) external view returns (bytes memory value) { value = strings[index]; } }
// SPDX-License-Identifier: MIT // ERC721A Contracts v4.2.3 // Creator: Chiru Labs pragma solidity ^0.8.4; import './IERC721A.sol'; /** * @dev Interface of ERC721 token receiver. */ interface ERC721A__IERC721Receiver { function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } /** * @title ERC721A * * @dev Implementation of the [ERC721](https://eips.ethereum.org/EIPS/eip-721) * Non-Fungible Token Standard, including the Metadata extension. * Optimized for lower gas during batch mints. * * Token IDs are minted in sequential order (e.g. 0, 1, 2, 3, ...) * starting from `_startTokenId()`. * * Assumptions: * * - An owner cannot have more than 2**64 - 1 (max value of uint64) of supply. * - The maximum token ID cannot exceed 2**256 - 1 (max value of uint256). */ contract ERC721A is IERC721A { // Bypass for a `--via-ir` bug (https://github.com/chiru-labs/ERC721A/pull/364). struct TokenApprovalRef { address value; } // ============================================================= // CONSTANTS // ============================================================= // Mask of an entry in packed address data. uint256 private constant _BITMASK_ADDRESS_DATA_ENTRY = (1 << 64) - 1; // The bit position of `numberMinted` in packed address data. uint256 private constant _BITPOS_NUMBER_MINTED = 64; // The bit position of `numberBurned` in packed address data. uint256 private constant _BITPOS_NUMBER_BURNED = 128; // The bit position of `aux` in packed address data. uint256 private constant _BITPOS_AUX = 192; // Mask of all 256 bits in packed address data except the 64 bits for `aux`. uint256 private constant _BITMASK_AUX_COMPLEMENT = (1 << 192) - 1; // The bit position of `startTimestamp` in packed ownership. uint256 private constant _BITPOS_START_TIMESTAMP = 160; // The bit mask of the `burned` bit in packed ownership. uint256 private constant _BITMASK_BURNED = 1 << 224; // The bit position of the `nextInitialized` bit in packed ownership. uint256 private constant _BITPOS_NEXT_INITIALIZED = 225; // The bit mask of the `nextInitialized` bit in packed ownership. uint256 private constant _BITMASK_NEXT_INITIALIZED = 1 << 225; // The bit position of `extraData` in packed ownership. uint256 private constant _BITPOS_EXTRA_DATA = 232; // Mask of all 256 bits in a packed ownership except the 24 bits for `extraData`. uint256 private constant _BITMASK_EXTRA_DATA_COMPLEMENT = (1 << 232) - 1; // The mask of the lower 160 bits for addresses. uint256 private constant _BITMASK_ADDRESS = (1 << 160) - 1; // The maximum `quantity` that can be minted with {_mintERC2309}. // This limit is to prevent overflows on the address data entries. // For a limit of 5000, a total of 3.689e15 calls to {_mintERC2309} // is required to cause an overflow, which is unrealistic. uint256 private constant _MAX_MINT_ERC2309_QUANTITY_LIMIT = 5000; // The `Transfer` event signature is given by: // `keccak256(bytes("Transfer(address,address,uint256)"))`. bytes32 private constant _TRANSFER_EVENT_SIGNATURE = 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef; // ============================================================= // STORAGE // ============================================================= // The next token ID to be minted. uint256 private _currentIndex; // The number of tokens burned. uint256 private _burnCounter; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to ownership details // An empty struct value does not necessarily mean the token is unowned. // See {_packedOwnershipOf} implementation for details. // // Bits Layout: // - [0..159] `addr` // - [160..223] `startTimestamp` // - [224] `burned` // - [225] `nextInitialized` // - [232..255] `extraData` mapping(uint256 => uint256) private _packedOwnerships; // Mapping owner address to address data. // // Bits Layout: // - [0..63] `balance` // - [64..127] `numberMinted` // - [128..191] `numberBurned` // - [192..255] `aux` mapping(address => uint256) private _packedAddressData; // Mapping from token ID to approved address. mapping(uint256 => TokenApprovalRef) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; // ============================================================= // CONSTRUCTOR // ============================================================= constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; _currentIndex = _startTokenId(); } // ============================================================= // TOKEN COUNTING OPERATIONS // ============================================================= /** * @dev Returns the starting token ID. * To change the starting token ID, please override this function. */ function _startTokenId() internal view virtual returns (uint256) { return 0; } /** * @dev Returns the next token ID to be minted. */ function _nextTokenId() internal view virtual returns (uint256) { return _currentIndex; } /** * @dev Returns the total number of tokens in existence. * Burned tokens will reduce the count. * To get the total number of tokens minted, please see {_totalMinted}. */ function totalSupply() public view virtual override returns (uint256) { // Counter underflow is impossible as _burnCounter cannot be incremented // more than `_currentIndex - _startTokenId()` times. unchecked { return _currentIndex - _burnCounter - _startTokenId(); } } /** * @dev Returns the total amount of tokens minted in the contract. */ function _totalMinted() internal view virtual returns (uint256) { // Counter underflow is impossible as `_currentIndex` does not decrement, // and it is initialized to `_startTokenId()`. unchecked { return _currentIndex - _startTokenId(); } } /** * @dev Returns the total number of tokens burned. */ function _totalBurned() internal view virtual returns (uint256) { return _burnCounter; } // ============================================================= // ADDRESS DATA OPERATIONS // ============================================================= /** * @dev Returns the number of tokens in `owner`'s account. */ function balanceOf(address owner) public view virtual override returns (uint256) { if (owner == address(0)) revert BalanceQueryForZeroAddress(); return _packedAddressData[owner] & _BITMASK_ADDRESS_DATA_ENTRY; } /** * Returns the number of tokens minted by `owner`. */ function _numberMinted(address owner) internal view returns (uint256) { return (_packedAddressData[owner] >> _BITPOS_NUMBER_MINTED) & _BITMASK_ADDRESS_DATA_ENTRY; } /** * Returns the number of tokens burned by or on behalf of `owner`. */ function _numberBurned(address owner) internal view returns (uint256) { return (_packedAddressData[owner] >> _BITPOS_NUMBER_BURNED) & _BITMASK_ADDRESS_DATA_ENTRY; } /** * Returns the auxiliary data for `owner`. (e.g. number of whitelist mint slots used). */ function _getAux(address owner) internal view returns (uint64) { return uint64(_packedAddressData[owner] >> _BITPOS_AUX); } /** * Sets the auxiliary data for `owner`. (e.g. number of whitelist mint slots used). * If there are multiple variables, please pack them into a uint64. */ function _setAux(address owner, uint64 aux) internal virtual { uint256 packed = _packedAddressData[owner]; uint256 auxCasted; // Cast `aux` with assembly to avoid redundant masking. assembly { auxCasted := aux } packed = (packed & _BITMASK_AUX_COMPLEMENT) | (auxCasted << _BITPOS_AUX); _packedAddressData[owner] = packed; } // ============================================================= // IERC165 // ============================================================= /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * [EIP section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified) * to learn more about how these ids are created. * * This function call must use less than 30000 gas. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { // The interface IDs are constants representing the first 4 bytes // of the XOR of all function selectors in the interface. // See: [ERC165](https://eips.ethereum.org/EIPS/eip-165) // (e.g. `bytes4(i.functionA.selector ^ i.functionB.selector ^ ...)`) return interfaceId == 0x01ffc9a7 || // ERC165 interface ID for ERC165. interfaceId == 0x80ac58cd || // ERC165 interface ID for ERC721. interfaceId == 0x5b5e139f; // ERC165 interface ID for ERC721Metadata. } // ============================================================= // IERC721Metadata // ============================================================= /** * @dev Returns the token collection name. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the token collection symbol. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { if (!_exists(tokenId)) revert URIQueryForNonexistentToken(); string memory baseURI = _baseURI(); return bytes(baseURI).length != 0 ? string(abi.encodePacked(baseURI, _toString(tokenId))) : ''; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, it can be overridden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ''; } // ============================================================= // OWNERSHIPS OPERATIONS // ============================================================= /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { return address(uint160(_packedOwnershipOf(tokenId))); } /** * @dev Gas spent here starts off proportional to the maximum mint batch size. * It gradually moves to O(1) as tokens get transferred around over time. */ function _ownershipOf(uint256 tokenId) internal view virtual returns (TokenOwnership memory) { return _unpackedOwnership(_packedOwnershipOf(tokenId)); } /** * @dev Returns the unpacked `TokenOwnership` struct at `index`. */ function _ownershipAt(uint256 index) internal view virtual returns (TokenOwnership memory) { return _unpackedOwnership(_packedOwnerships[index]); } /** * @dev Initializes the ownership slot minted at `index` for efficiency purposes. */ function _initializeOwnershipAt(uint256 index) internal virtual { if (_packedOwnerships[index] == 0) { _packedOwnerships[index] = _packedOwnershipOf(index); } } /** * Returns the packed ownership data of `tokenId`. */ function _packedOwnershipOf(uint256 tokenId) private view returns (uint256) { uint256 curr = tokenId; unchecked { if (_startTokenId() <= curr) if (curr < _currentIndex) { uint256 packed = _packedOwnerships[curr]; // If not burned. if (packed & _BITMASK_BURNED == 0) { // Invariant: // There will always be an initialized ownership slot // (i.e. `ownership.addr != address(0) && ownership.burned == false`) // before an unintialized ownership slot // (i.e. `ownership.addr == address(0) && ownership.burned == false`) // Hence, `curr` will not underflow. // // We can directly compare the packed value. // If the address is zero, packed will be zero. while (packed == 0) { packed = _packedOwnerships[--curr]; } return packed; } } } revert OwnerQueryForNonexistentToken(); } /** * @dev Returns the unpacked `TokenOwnership` struct from `packed`. */ function _unpackedOwnership(uint256 packed) private pure returns (TokenOwnership memory ownership) { ownership.addr = address(uint160(packed)); ownership.startTimestamp = uint64(packed >> _BITPOS_START_TIMESTAMP); ownership.burned = packed & _BITMASK_BURNED != 0; ownership.extraData = uint24(packed >> _BITPOS_EXTRA_DATA); } /** * @dev Packs ownership data into a single uint256. */ function _packOwnershipData(address owner, uint256 flags) private view returns (uint256 result) { assembly { // Mask `owner` to the lower 160 bits, in case the upper bits somehow aren't clean. owner := and(owner, _BITMASK_ADDRESS) // `owner | (block.timestamp << _BITPOS_START_TIMESTAMP) | flags`. result := or(owner, or(shl(_BITPOS_START_TIMESTAMP, timestamp()), flags)) } } /** * @dev Returns the `nextInitialized` flag set if `quantity` equals 1. */ function _nextInitializedFlag(uint256 quantity) private pure returns (uint256 result) { // For branchless setting of the `nextInitialized` flag. assembly { // `(quantity == 1) << _BITPOS_NEXT_INITIALIZED`. result := shl(_BITPOS_NEXT_INITIALIZED, eq(quantity, 1)) } } // ============================================================= // APPROVAL OPERATIONS // ============================================================= /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the * zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) public payable virtual override { address owner = ownerOf(tokenId); if (_msgSenderERC721A() != owner) if (!isApprovedForAll(owner, _msgSenderERC721A())) { revert ApprovalCallerNotOwnerNorApproved(); } _tokenApprovals[tokenId].value = to; emit Approval(owner, to, tokenId); } /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { if (!_exists(tokenId)) revert ApprovalQueryForNonexistentToken(); return _tokenApprovals[tokenId].value; } /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} * for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool approved) public virtual override { _operatorApprovals[_msgSenderERC721A()][operator] = approved; emit ApprovalForAll(_msgSenderERC721A(), operator, approved); } /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted. See {_mint}. */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _startTokenId() <= tokenId && tokenId < _currentIndex && // If within bounds, _packedOwnerships[tokenId] & _BITMASK_BURNED == 0; // and not burned. } /** * @dev Returns whether `msgSender` is equal to `approvedAddress` or `owner`. */ function _isSenderApprovedOrOwner( address approvedAddress, address owner, address msgSender ) private pure returns (bool result) { assembly { // Mask `owner` to the lower 160 bits, in case the upper bits somehow aren't clean. owner := and(owner, _BITMASK_ADDRESS) // Mask `msgSender` to the lower 160 bits, in case the upper bits somehow aren't clean. msgSender := and(msgSender, _BITMASK_ADDRESS) // `msgSender == owner || msgSender == approvedAddress`. result := or(eq(msgSender, owner), eq(msgSender, approvedAddress)) } } /** * @dev Returns the storage slot and value for the approved address of `tokenId`. */ function _getApprovedSlotAndAddress(uint256 tokenId) private view returns (uint256 approvedAddressSlot, address approvedAddress) { TokenApprovalRef storage tokenApproval = _tokenApprovals[tokenId]; // The following is equivalent to `approvedAddress = _tokenApprovals[tokenId].value`. assembly { approvedAddressSlot := tokenApproval.slot approvedAddress := sload(approvedAddressSlot) } } // ============================================================= // TRANSFER OPERATIONS // ============================================================= /** * @dev Transfers `tokenId` from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token * by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) public payable virtual override { uint256 prevOwnershipPacked = _packedOwnershipOf(tokenId); if (address(uint160(prevOwnershipPacked)) != from) revert TransferFromIncorrectOwner(); (uint256 approvedAddressSlot, address approvedAddress) = _getApprovedSlotAndAddress(tokenId); // The nested ifs save around 20+ gas over a compound boolean condition. if (!_isSenderApprovedOrOwner(approvedAddress, from, _msgSenderERC721A())) if (!isApprovedForAll(from, _msgSenderERC721A())) revert TransferCallerNotOwnerNorApproved(); if (to == address(0)) revert TransferToZeroAddress(); _beforeTokenTransfers(from, to, tokenId, 1); // Clear approvals from the previous owner. assembly { if approvedAddress { // This is equivalent to `delete _tokenApprovals[tokenId]`. sstore(approvedAddressSlot, 0) } } // Underflow of the sender's balance is impossible because we check for // ownership above and the recipient's balance can't realistically overflow. // Counter overflow is incredibly unrealistic as `tokenId` would have to be 2**256. unchecked { // We can directly increment and decrement the balances. --_packedAddressData[from]; // Updates: `balance -= 1`. ++_packedAddressData[to]; // Updates: `balance += 1`. // Updates: // - `address` to the next owner. // - `startTimestamp` to the timestamp of transfering. // - `burned` to `false`. // - `nextInitialized` to `true`. _packedOwnerships[tokenId] = _packOwnershipData( to, _BITMASK_NEXT_INITIALIZED | _nextExtraData(from, to, prevOwnershipPacked) ); // If the next slot may not have been initialized (i.e. `nextInitialized == false`) . if (prevOwnershipPacked & _BITMASK_NEXT_INITIALIZED == 0) { uint256 nextTokenId = tokenId + 1; // If the next slot's address is zero and not burned (i.e. packed value is zero). if (_packedOwnerships[nextTokenId] == 0) { // If the next slot is within bounds. if (nextTokenId != _currentIndex) { // Initialize the next slot to maintain correctness for `ownerOf(tokenId + 1)`. _packedOwnerships[nextTokenId] = prevOwnershipPacked; } } } } emit Transfer(from, to, tokenId); _afterTokenTransfers(from, to, tokenId, 1); } /** * @dev Equivalent to `safeTransferFrom(from, to, tokenId, '')`. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public payable virtual override { safeTransferFrom(from, to, tokenId, ''); } /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token * by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement * {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public payable virtual override { transferFrom(from, to, tokenId); if (to.code.length != 0) if (!_checkContractOnERC721Received(from, to, tokenId, _data)) { revert TransferToNonERC721ReceiverImplementer(); } } /** * @dev Hook that is called before a set of serially-ordered token IDs * are about to be transferred. This includes minting. * And also called before burning one token. * * `startTokenId` - the first token ID to be transferred. * `quantity` - the amount to be transferred. * * Calling conditions: * * - When `from` and `to` are both non-zero, `from`'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, `tokenId` will be burned by `from`. * - `from` and `to` are never both zero. */ function _beforeTokenTransfers( address from, address to, uint256 startTokenId, uint256 quantity ) internal virtual {} /** * @dev Hook that is called after a set of serially-ordered token IDs * have been transferred. This includes minting. * And also called after one token has been burned. * * `startTokenId` - the first token ID to be transferred. * `quantity` - the amount to be transferred. * * Calling conditions: * * - When `from` and `to` are both non-zero, `from`'s `tokenId` has been * transferred to `to`. * - When `from` is zero, `tokenId` has been minted for `to`. * - When `to` is zero, `tokenId` has been burned by `from`. * - `from` and `to` are never both zero. */ function _afterTokenTransfers( address from, address to, uint256 startTokenId, uint256 quantity ) internal virtual {} /** * @dev Private function to invoke {IERC721Receiver-onERC721Received} on a target contract. * * `from` - Previous owner of the given token ID. * `to` - Target address that will receive the token. * `tokenId` - Token ID to be transferred. * `_data` - Optional data to send along with the call. * * Returns whether the call correctly returned the expected magic value. */ function _checkContractOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { try ERC721A__IERC721Receiver(to).onERC721Received(_msgSenderERC721A(), from, tokenId, _data) returns ( bytes4 retval ) { return retval == ERC721A__IERC721Receiver(to).onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert TransferToNonERC721ReceiverImplementer(); } else { assembly { revert(add(32, reason), mload(reason)) } } } } // ============================================================= // MINT OPERATIONS // ============================================================= /** * @dev Mints `quantity` tokens and transfers them to `to`. * * Requirements: * * - `to` cannot be the zero address. * - `quantity` must be greater than 0. * * Emits a {Transfer} event for each mint. */ function _mint(address to, uint256 quantity) internal virtual { uint256 startTokenId = _currentIndex; if (quantity == 0) revert MintZeroQuantity(); _beforeTokenTransfers(address(0), to, startTokenId, quantity); // Overflows are incredibly unrealistic. // `balance` and `numberMinted` have a maximum limit of 2**64. // `tokenId` has a maximum limit of 2**256. unchecked { // Updates: // - `balance += quantity`. // - `numberMinted += quantity`. // // We can directly add to the `balance` and `numberMinted`. _packedAddressData[to] += quantity * ((1 << _BITPOS_NUMBER_MINTED) | 1); // Updates: // - `address` to the owner. // - `startTimestamp` to the timestamp of minting. // - `burned` to `false`. // - `nextInitialized` to `quantity == 1`. _packedOwnerships[startTokenId] = _packOwnershipData( to, _nextInitializedFlag(quantity) | _nextExtraData(address(0), to, 0) ); uint256 toMasked; uint256 end = startTokenId + quantity; // Use assembly to loop and emit the `Transfer` event for gas savings. // The duplicated `log4` removes an extra check and reduces stack juggling. // The assembly, together with the surrounding Solidity code, have been // delicately arranged to nudge the compiler into producing optimized opcodes. assembly { // Mask `to` to the lower 160 bits, in case the upper bits somehow aren't clean. toMasked := and(to, _BITMASK_ADDRESS) // Emit the `Transfer` event. log4( 0, // Start of data (0, since no data). 0, // End of data (0, since no data). _TRANSFER_EVENT_SIGNATURE, // Signature. 0, // `address(0)`. toMasked, // `to`. startTokenId // `tokenId`. ) // The `iszero(eq(,))` check ensures that large values of `quantity` // that overflows uint256 will make the loop run out of gas. // The compiler will optimize the `iszero` away for performance. for { let tokenId := add(startTokenId, 1) } iszero(eq(tokenId, end)) { tokenId := add(tokenId, 1) } { // Emit the `Transfer` event. Similar to above. log4(0, 0, _TRANSFER_EVENT_SIGNATURE, 0, toMasked, tokenId) } } if (toMasked == 0) revert MintToZeroAddress(); _currentIndex = end; } _afterTokenTransfers(address(0), to, startTokenId, quantity); } /** * @dev Mints `quantity` tokens and transfers them to `to`. * * This function is intended for efficient minting only during contract creation. * * It emits only one {ConsecutiveTransfer} as defined in * [ERC2309](https://eips.ethereum.org/EIPS/eip-2309), * instead of a sequence of {Transfer} event(s). * * Calling this function outside of contract creation WILL make your contract * non-compliant with the ERC721 standard. * For full ERC721 compliance, substituting ERC721 {Transfer} event(s) with the ERC2309 * {ConsecutiveTransfer} event is only permissible during contract creation. * * Requirements: * * - `to` cannot be the zero address. * - `quantity` must be greater than 0. * * Emits a {ConsecutiveTransfer} event. */ function _mintERC2309(address to, uint256 quantity) internal virtual { uint256 startTokenId = _currentIndex; if (to == address(0)) revert MintToZeroAddress(); if (quantity == 0) revert MintZeroQuantity(); if (quantity > _MAX_MINT_ERC2309_QUANTITY_LIMIT) revert MintERC2309QuantityExceedsLimit(); _beforeTokenTransfers(address(0), to, startTokenId, quantity); // Overflows are unrealistic due to the above check for `quantity` to be below the limit. unchecked { // Updates: // - `balance += quantity`. // - `numberMinted += quantity`. // // We can directly add to the `balance` and `numberMinted`. _packedAddressData[to] += quantity * ((1 << _BITPOS_NUMBER_MINTED) | 1); // Updates: // - `address` to the owner. // - `startTimestamp` to the timestamp of minting. // - `burned` to `false`. // - `nextInitialized` to `quantity == 1`. _packedOwnerships[startTokenId] = _packOwnershipData( to, _nextInitializedFlag(quantity) | _nextExtraData(address(0), to, 0) ); emit ConsecutiveTransfer(startTokenId, startTokenId + quantity - 1, address(0), to); _currentIndex = startTokenId + quantity; } _afterTokenTransfers(address(0), to, startTokenId, quantity); } /** * @dev Safely mints `quantity` tokens and transfers them to `to`. * * Requirements: * * - If `to` refers to a smart contract, it must implement * {IERC721Receiver-onERC721Received}, which is called for each safe transfer. * - `quantity` must be greater than 0. * * See {_mint}. * * Emits a {Transfer} event for each mint. */ function _safeMint( address to, uint256 quantity, bytes memory _data ) internal virtual { _mint(to, quantity); unchecked { if (to.code.length != 0) { uint256 end = _currentIndex; uint256 index = end - quantity; do { if (!_checkContractOnERC721Received(address(0), to, index++, _data)) { revert TransferToNonERC721ReceiverImplementer(); } } while (index < end); // Reentrancy protection. if (_currentIndex != end) revert(); } } } /** * @dev Equivalent to `_safeMint(to, quantity, '')`. */ function _safeMint(address to, uint256 quantity) internal virtual { _safeMint(to, quantity, ''); } // ============================================================= // BURN OPERATIONS // ============================================================= /** * @dev Equivalent to `_burn(tokenId, false)`. */ function _burn(uint256 tokenId) internal virtual { _burn(tokenId, false); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId, bool approvalCheck) internal virtual { uint256 prevOwnershipPacked = _packedOwnershipOf(tokenId); address from = address(uint160(prevOwnershipPacked)); (uint256 approvedAddressSlot, address approvedAddress) = _getApprovedSlotAndAddress(tokenId); if (approvalCheck) { // The nested ifs save around 20+ gas over a compound boolean condition. if (!_isSenderApprovedOrOwner(approvedAddress, from, _msgSenderERC721A())) if (!isApprovedForAll(from, _msgSenderERC721A())) revert TransferCallerNotOwnerNorApproved(); } _beforeTokenTransfers(from, address(0), tokenId, 1); // Clear approvals from the previous owner. assembly { if approvedAddress { // This is equivalent to `delete _tokenApprovals[tokenId]`. sstore(approvedAddressSlot, 0) } } // Underflow of the sender's balance is impossible because we check for // ownership above and the recipient's balance can't realistically overflow. // Counter overflow is incredibly unrealistic as `tokenId` would have to be 2**256. unchecked { // Updates: // - `balance -= 1`. // - `numberBurned += 1`. // // We can directly decrement the balance, and increment the number burned. // This is equivalent to `packed -= 1; packed += 1 << _BITPOS_NUMBER_BURNED;`. _packedAddressData[from] += (1 << _BITPOS_NUMBER_BURNED) - 1; // Updates: // - `address` to the last owner. // - `startTimestamp` to the timestamp of burning. // - `burned` to `true`. // - `nextInitialized` to `true`. _packedOwnerships[tokenId] = _packOwnershipData( from, (_BITMASK_BURNED | _BITMASK_NEXT_INITIALIZED) | _nextExtraData(from, address(0), prevOwnershipPacked) ); // If the next slot may not have been initialized (i.e. `nextInitialized == false`) . if (prevOwnershipPacked & _BITMASK_NEXT_INITIALIZED == 0) { uint256 nextTokenId = tokenId + 1; // If the next slot's address is zero and not burned (i.e. packed value is zero). if (_packedOwnerships[nextTokenId] == 0) { // If the next slot is within bounds. if (nextTokenId != _currentIndex) { // Initialize the next slot to maintain correctness for `ownerOf(tokenId + 1)`. _packedOwnerships[nextTokenId] = prevOwnershipPacked; } } } } emit Transfer(from, address(0), tokenId); _afterTokenTransfers(from, address(0), tokenId, 1); // Overflow not possible, as _burnCounter cannot be exceed _currentIndex times. unchecked { _burnCounter++; } } // ============================================================= // EXTRA DATA OPERATIONS // ============================================================= /** * @dev Directly sets the extra data for the ownership data `index`. */ function _setExtraDataAt(uint256 index, uint24 extraData) internal virtual { uint256 packed = _packedOwnerships[index]; if (packed == 0) revert OwnershipNotInitializedForExtraData(); uint256 extraDataCasted; // Cast `extraData` with assembly to avoid redundant masking. assembly { extraDataCasted := extraData } packed = (packed & _BITMASK_EXTRA_DATA_COMPLEMENT) | (extraDataCasted << _BITPOS_EXTRA_DATA); _packedOwnerships[index] = packed; } /** * @dev Called during each token transfer to set the 24bit `extraData` field. * Intended to be overridden by the cosumer contract. * * `previousExtraData` - the value of `extraData` before transfer. * * Calling conditions: * * - When `from` and `to` are both non-zero, `from`'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, `tokenId` will be burned by `from`. * - `from` and `to` are never both zero. */ function _extraData( address from, address to, uint24 previousExtraData ) internal view virtual returns (uint24) {} /** * @dev Returns the next extra data for the packed ownership data. * The returned result is shifted into position. */ function _nextExtraData( address from, address to, uint256 prevOwnershipPacked ) private view returns (uint256) { uint24 extraData = uint24(prevOwnershipPacked >> _BITPOS_EXTRA_DATA); return uint256(_extraData(from, to, extraData)) << _BITPOS_EXTRA_DATA; } // ============================================================= // OTHER OPERATIONS // ============================================================= /** * @dev Returns the message sender (defaults to `msg.sender`). * * If you are writing GSN compatible contracts, you need to override this function. */ function _msgSenderERC721A() internal view virtual returns (address) { return msg.sender; } /** * @dev Converts a uint256 to its ASCII string decimal representation. */ function _toString(uint256 value) internal pure virtual returns (string memory str) { assembly { // The maximum value of a uint256 contains 78 digits (1 byte per digit), but // we allocate 0xa0 bytes to keep the free memory pointer 32-byte word aligned. // We will need 1 word for the trailing zeros padding, 1 word for the length, // and 3 words for a maximum of 78 digits. Total: 5 * 0x20 = 0xa0. let m := add(mload(0x40), 0xa0) // Update the free memory pointer to allocate. mstore(0x40, m) // Assign the `str` to the end. str := sub(m, 0x20) // Zeroize the slot after the string. mstore(str, 0) // Cache the end of the memory to calculate the length later. let end := str // We write the string from rightmost digit to leftmost digit. // The following is essentially a do-while loop that also handles the zero case. // prettier-ignore for { let temp := value } 1 {} { str := sub(str, 1) // Write the character to the pointer. // The ASCII index of the '0' character is 48. mstore8(str, add(48, mod(temp, 10))) // Keep dividing `temp` until zero. temp := div(temp, 10) // prettier-ignore if iszero(temp) { break } } let length := sub(end, str) // Move the pointer 32 bytes leftwards to make room for the length. str := sub(str, 0x20) // Store the length. mstore(str, length) } } }
// SPDX-License-Identifier: MIT // ERC721A Contracts v4.2.3 // Creator: Chiru Labs pragma solidity ^0.8.4; /** * @dev Interface of ERC721A. */ interface IERC721A { /** * The caller must own the token or be an approved operator. */ error ApprovalCallerNotOwnerNorApproved(); /** * The token does not exist. */ error ApprovalQueryForNonexistentToken(); /** * Cannot query the balance for the zero address. */ error BalanceQueryForZeroAddress(); /** * Cannot mint to the zero address. */ error MintToZeroAddress(); /** * The quantity of tokens minted must be more than zero. */ error MintZeroQuantity(); /** * The token does not exist. */ error OwnerQueryForNonexistentToken(); /** * The caller must own the token or be an approved operator. */ error TransferCallerNotOwnerNorApproved(); /** * The token must be owned by `from`. */ error TransferFromIncorrectOwner(); /** * Cannot safely transfer to a contract that does not implement the * ERC721Receiver interface. */ error TransferToNonERC721ReceiverImplementer(); /** * Cannot transfer to the zero address. */ error TransferToZeroAddress(); /** * The token does not exist. */ error URIQueryForNonexistentToken(); /** * The `quantity` minted with ERC2309 exceeds the safety limit. */ error MintERC2309QuantityExceedsLimit(); /** * The `extraData` cannot be set on an unintialized ownership slot. */ error OwnershipNotInitializedForExtraData(); // ============================================================= // STRUCTS // ============================================================= struct TokenOwnership { // The address of the owner. address addr; // Stores the start time of ownership with minimal overhead for tokenomics. uint64 startTimestamp; // Whether the token has been burned. bool burned; // Arbitrary data similar to `startTimestamp` that can be set via {_extraData}. uint24 extraData; } // ============================================================= // TOKEN COUNTERS // ============================================================= /** * @dev Returns the total number of tokens in existence. * Burned tokens will reduce the count. * To get the total number of tokens minted, please see {_totalMinted}. */ function totalSupply() external view returns (uint256); // ============================================================= // IERC165 // ============================================================= /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * [EIP section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified) * to learn more about how these ids are created. * * This function call must use less than 30000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); // ============================================================= // IERC721 // ============================================================= /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables * (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in `owner`'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, * checking first that contract recipients are aware of the ERC721 protocol * to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move * this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement * {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external payable; /** * @dev Equivalent to `safeTransferFrom(from, to, tokenId, '')`. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external payable; /** * @dev Transfers `tokenId` from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} * whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token * by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external payable; /** * @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 payable; /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} * for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll}. */ function isApprovedForAll(address owner, address operator) external view returns (bool); // ============================================================= // IERC721Metadata // ============================================================= /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); // ============================================================= // IERC2309 // ============================================================= /** * @dev Emitted when tokens in `fromTokenId` to `toTokenId` * (inclusive) is transferred from `from` to `to`, as defined in the * [ERC2309](https://eips.ethereum.org/EIPS/eip-2309) standard. * * See {_mintERC2309} for more details. */ event ConsecutiveTransfer(uint256 indexed fromTokenId, uint256 toTokenId, address indexed from, address indexed to); }
{ "optimizer": { "enabled": true, "runs": 1 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"string","name":"name_","type":"string"},{"internalType":"string","name":"symbol_","type":"string"},{"internalType":"uint256","name":"maxSupply_","type":"uint256"},{"internalType":"uint256","name":"maxPerAddress_","type":"uint256"},{"internalType":"uint256","name":"maxPerTransaction_","type":"uint256"},{"internalType":"address","name":"salesRecipient_","type":"address"},{"internalType":"address","name":"royaltyRecipient_","type":"address"},{"internalType":"uint96","name":"royaltyBasisPoints_","type":"uint96"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"ApprovalCallerNotOwnerNorApproved","type":"error"},{"inputs":[],"name":"ApprovalQueryForNonexistentToken","type":"error"},{"inputs":[],"name":"BalanceQueryForZeroAddress","type":"error"},{"inputs":[{"internalType":"uint256","name":"expected","type":"uint256"},{"internalType":"uint256","name":"actual","type":"uint256"}],"name":"InvalidDimensions","type":"error"},{"inputs":[],"name":"InvalidSlot","type":"error"},{"inputs":[],"name":"MintERC2309QuantityExceedsLimit","type":"error"},{"inputs":[],"name":"MintNotOpen","type":"error"},{"inputs":[],"name":"MintToZeroAddress","type":"error"},{"inputs":[],"name":"MintZeroQuantity","type":"error"},{"inputs":[],"name":"OwnerQueryForNonexistentToken","type":"error"},{"inputs":[],"name":"OwnershipNotInitializedForExtraData","type":"error"},{"inputs":[],"name":"TransferCallerNotOwnerNorApproved","type":"error"},{"inputs":[],"name":"TransferFromIncorrectOwner","type":"error"},{"inputs":[],"name":"TransferToNonERC721ReceiverImplementer","type":"error"},{"inputs":[],"name":"TransferToZeroAddress","type":"error"},{"inputs":[],"name":"URIQueryForNonexistentToken","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_fromTokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_toTokenId","type":"uint256"}],"name":"BatchMetadataUpdate","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"fromTokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"toTokenId","type":"uint256"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"}],"name":"ConsecutiveTransfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"MetadataUpdate","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"buyer","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Refund","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"beneficiary","type":"address"},{"indexed":false,"internalType":"uint256","name":"numPurchased","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Revenue","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEFAULT_STEERING_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"beneficiary","outputs":[{"internalType":"address payable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"closeMint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"n","type":"uint256"},{"internalType":"uint256","name":"costEach","type":"uint256"}],"name":"cost","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"description","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"disableSVGWrapper","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"emitMetadataUpdateForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"enableSVGWrapper","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"extendedData","outputs":[{"components":[{"internalType":"string","name":"description","type":"string"},{"internalType":"string","name":"externalUrl","type":"string"},{"internalType":"string","name":"prefix","type":"string"}],"internalType":"struct Main.ExtendedData","name":"data","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"externalUrl","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":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getRoleMember","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleMemberCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"slot","type":"uint256"}],"name":"getSlot","outputs":[{"internalType":"uint256","name":"result","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"quantity","type":"uint256"}],"name":"mint","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"mintOpen","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"openMint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"prefix","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"price","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"n","type":"uint256"}],"name":"purchaseFreeOfCharge","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"revealed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"uint256","name":"_salePrice","type":"uint256"}],"name":"royaltyInfo","outputs":[{"internalType":"address","name":"","type":"address"},{"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":"payable","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":"payable","type":"function"},{"inputs":[],"name":"scaleFactor","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"sellerConfig","outputs":[{"internalType":"uint256","name":"totalInventory","type":"uint256"},{"internalType":"uint256","name":"maxPerAddress","type":"uint256"},{"internalType":"uint256","name":"maxPerTx","type":"uint256"},{"internalType":"uint248","name":"freeQuota","type":"uint248"},{"internalType":"bool","name":"reserveFreeQuota","type":"bool"},{"internalType":"bool","name":"lockFreeQuota","type":"bool"},{"internalType":"bool","name":"lockTotalInventory","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address payable","name":"_beneficiary","type":"address"}],"name":"setBeneficiary","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint96","name":"basisPoints","type":"uint96"}],"name":"setDefaultRoyalty","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"string","name":"description","type":"string"},{"internalType":"string","name":"externalUrl","type":"string"},{"internalType":"string","name":"prefix","type":"string"}],"internalType":"struct Main.ExtendedData","name":"extendedData_","type":"tuple"}],"name":"setExtendedData","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"name_","type":"string"}],"name":"setName","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"price_","type":"uint256"}],"name":"setPrice","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"render_","type":"address"}],"name":"setRender","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"setRevealed","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"svgWrapper_","type":"address"}],"name":"setSVGWrapper","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"enum SVGWrapperTarget","name":"svgWrapperTarget_","type":"uint8"}],"name":"setSVGWrapperTarget","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint8","name":"scaleFactor_","type":"uint8"}],"name":"setScaleFactor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"totalInventory","type":"uint256"},{"internalType":"uint256","name":"maxPerAddress","type":"uint256"},{"internalType":"uint256","name":"maxPerTx","type":"uint256"},{"internalType":"uint248","name":"freeQuota","type":"uint248"},{"internalType":"bool","name":"reserveFreeQuota","type":"bool"},{"internalType":"bool","name":"lockFreeQuota","type":"bool"},{"internalType":"bool","name":"lockTotalInventory","type":"bool"}],"internalType":"struct Seller.SellerConfig","name":"config","type":"tuple"}],"name":"setSellerConfig","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"slot","type":"uint256"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"setSlot","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"strings_","type":"address"}],"name":"setStrings","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"symbol_","type":"string"}],"name":"setSymbol","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenStart_","type":"uint256"}],"name":"setTokenStart","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"tokenURIBuilder_","type":"address"}],"name":"setTokenURIBuilder","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"tokenURIOverride_","type":"address"}],"name":"setTokenURIOverride","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"traitCounts_","type":"uint256[]"}],"name":"setTraitCounts","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string[]","name":"traitNames_","type":"string[]"}],"name":"setTraitNames","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"traitsOverride_","type":"address"}],"name":"setTraitsOverride","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"setUnrevealed","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"soldOut","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"svgWrapped","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tokenStart","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"tokenUri","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tokenURIBuilder","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tokenURIOverride","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSold","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"traitsOverride","outputs":[{"internalType":"address","name":"","type":"address"}],"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":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
60806040523480156200001157600080fd5b5060405162006acb38038062006acb83398101604081905262000034916200096e565b6040805160e081018252878152602081018790529081018590526000606082018190526080820181905260a0820181905260c082015283818133338d8d89898383600262000083838262000acb565b50600362000092828262000acb565b50506000805550620000a4336200029c565b600b805460ff19169055620000ba8282620002ee565b620000c7600087620003ef565b620000f37f1e4c11efbd6a865b1cba79eea33d1b33c1394d834190605ed6a14c71c480bf7686620003ef565b50506001600e55506200010b9250849150506200041a565b6200011681620005f0565b505050506200012a6200061c60201b60201c565b601b9062000139908262000acb565b5062000144620006b6565b601c9062000153908262000acb565b5060408051808201909152600b81526a2222a9a1a924a82a24a7a760a91b6020820152601d9062000185908262000acb565b5060408051808201909152600c81526b115615115493905317d5549360a21b6020820152601e90620001b8908262000acb565b50601b604051602001620001cd919062000b97565b604051602081830303815290604052601f9081620001ec919062000acb565b506025805460ff1916600a17905562000209600160fa1b620006c7565b15801562000223575062000221600160fb1b620006c7565b155b80156200023c57506200023a600160fc1b620006c7565b155b6200028e5760405162461bcd60e51b815260206004820152601760248201527f4d61696e3a696e76616c69642d736c6f742d737461746500000000000000000060448201526064015b60405180910390fd5b505050505050505062000c1f565b600880546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6127106001600160601b03821611156200035e5760405162461bcd60e51b815260206004820152602a60248201527f455243323938313a20726f79616c7479206665652077696c6c206578636565646044820152692073616c65507269636560b01b606482015260840162000285565b6001600160a01b038216620003b65760405162461bcd60e51b815260206004820152601960248201527f455243323938313a20696e76616c696420726563656976657200000000000000604482015260640162000285565b604080518082019091526001600160a01b039092168083526001600160601b039091166020909201829052600160a01b90910217600c55565b620003fb828262000717565b6000828152600a60205260409020620004159082620007bc565b505050565b62000424620007dc565b80606001516001600160f81b031681600001511015620004875760405162461bcd60e51b815260206004820152601c60248201527f53656c6c65723a2065786365737369766520667265652071756f746100000000604482015260640162000285565b60155481511015620004dc5760405162461bcd60e51b815260206004820181905260248201527f53656c6c65723a20696e76656e746f7279203c20616c726561647920736f6c64604482015260640162000285565b60175481606001516001600160f81b03161015620005475760405162461bcd60e51b815260206004820152602160248201527f53656c6c65723a20667265652071756f7461203c20616c7265616479207573656044820152601960fa1b606482015260840162000285565b601354610100900460ff16156200056557600160c0820152600f5481525b60135460ff16156200058a57600160a08201526012546001600160f81b031660608201525b8051600f5560208101516010556040810151601155606081015160808201511515600160f81b026001600160f81b039091161760125560a08101516013805460c09093015115156101000261ff00199215159290921661ffff1990931692909217179055565b620005fa620007dc565b601480546001600160a01b0319166001600160a01b0392909216919091179055565b6060600280546200062d9062000a3d565b80601f01602080910402602001604051908101604052809291908181526020018280546200065b9062000a3d565b8015620006ac5780601f106200068057610100808354040283529160200191620006ac565b820191906000526020600020905b8154815290600101906020018083116200068e57829003601f168201915b5050505050905090565b6060600380546200062d9062000a3d565b6000600160fa1b8214158015620006e25750600160fb1b8214155b8015620006f35750600160fc1b8214155b156200071257604051631258e44360e01b815260040160405180910390fd5b505490565b60008281526009602090815260408083206001600160a01b038516845290915290205460ff16620007b85760008281526009602090815260408083206001600160a01b03851684529091529020805460ff19166001179055620007773390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45b5050565b6000620007d3836001600160a01b0384166200083a565b90505b92915050565b6008546001600160a01b03163314620008385760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640162000285565b565b60008181526001830160205260408120546200088357508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155620007d6565b506000620007d6565b634e487b7160e01b600052604160045260246000fd5b600082601f830112620008b457600080fd5b81516001600160401b0380821115620008d157620008d16200088c565b604051601f8301601f19908116603f01168101908282118183101715620008fc57620008fc6200088c565b816040528381526020925086838588010111156200091957600080fd5b600091505b838210156200093d57858201830151818301840152908201906200091e565b600093810190920192909252949350505050565b80516001600160a01b03811681146200096957600080fd5b919050565b600080600080600080600080610100898b0312156200098c57600080fd5b88516001600160401b0380821115620009a457600080fd5b620009b28c838d01620008a2565b995060208b0151915080821115620009c957600080fd5b50620009d88b828c01620008a2565b975050604089015195506060890151945060808901519350620009fe60a08a0162000951565b925062000a0e60c08a0162000951565b60e08a01519092506001600160601b038116811462000a2c57600080fd5b809150509295985092959890939650565b600181811c9082168062000a5257607f821691505b60208210810362000a7357634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156200041557600081815260208120601f850160051c8101602086101562000aa25750805b601f850160051c820191505b8181101562000ac35782815560010162000aae565b505050505050565b81516001600160401b0381111562000ae75762000ae76200088c565b62000aff8162000af8845462000a3d565b8462000a79565b602080601f83116001811462000b37576000841562000b1e5750858301515b600019600386901b1c1916600185901b17855562000ac3565b600085815260208120601f198616915b8281101562000b685788860151825594840194600190910190840162000b47565b508582101562000b875787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b600080835462000ba78162000a3d565b6001828116801562000bc2576001811462000bd85762000c09565b60ff198416875282151583028701945062000c09565b8760005260208060002060005b8581101562000c005781548a82015290840190820162000be5565b50505082870194505b505061202360f01b835250506002019392505050565b615e9c8062000c2f6000396000f3fe60806040526004361061036d5760003560e01c806301b409a11461037257806301ffc9a71461039457806304634d8d146103c957806306fdde03146103e9578063081812fc1461040b5780630912fc0214610438578063095ea7b314610458578063168d7c471461046b57806318160ddd1461048b5780631c31f710146104ae57806323b872dd146104ce578063248a9ca3146104e157806324bbd049146105015780632a55205a1461051b5780632d28bb021461055a5780632d614ba51461057a5780632d8bb1101461059a5780632e4344c5146105af5780632f274bd4146105d15780632f2ff15d146105f157806331c23d20146106115780633204f6cd14610633578063323d4d0d1461065357806336568abe1461067357806338af3eed146106935780633bd64968146106b35780633ec02e14146106c85780633f4ba83a146106e857806340c10f19146106fd57806342842e0e1461071057806347beec8814610723578063518302271461074357806351c7fa2c146107625780635c975abb146107775780635fbc91701461078f5780636352211e146107af57806364f101f0146107cf578063683dd191146107e457806370a0823114610810578063715018a6146108305780637284e4161461084557806375dadb321461085a5780637eba7ba61461086f5780638222b7d71461088f5780638456cb59146108a4578063879a4105146108b9578063893da6c9146108d95780638da5cb5b146108ee5780638fc73484146109035780639010d07c146109185780639106d7ba1461093857806391b7f5ed1461094d57806391d148541461096d57806395d89b411461098d578063a035b1fe146109a2578063a217fddf146109b8578063a22cb465146109cd578063b167e1b5146109ed578063b25c4b6d14610a02578063b84c824614610a18578063b88d4fde14610a38578063bb69b7ef14610a4b578063bce6d67214610ad6578063bf62e21d14610aeb578063c47f002714610b0b578063c87b56dd14610b2b578063ca15c87314610b4b578063cab940e814610b6b578063cbc1475c14610b8b578063d24c01c614610bab578063d547741f14610bcb578063d567d4e014610beb578063d5abeb0114610c0c578063d76b47cb14610c21578063d7c3d21e14610c41578063e985e9c514610c61578063f0c136cb14610caa578063f2fde38b14610cca575b600080fd5b34801561037e57600080fd5b5061039261038d366004615094565b610cea565b005b3480156103a057600080fd5b506103b46103af3660046150eb565b610dcc565b60405190151581526020015b60405180910390f35b3480156103d557600080fd5b506103926103e436600461511d565b610ddd565b3480156103f557600080fd5b506103fe610e04565b6040516103c091906151b2565b34801561041757600080fd5b5061042b6104263660046151c5565b610e96565b6040516103c091906151de565b34801561044457600080fd5b506103926104533660046151f2565b610eda565b61039261046636600461520f565b610f08565b34801561047757600080fd5b5061039261048636600461523b565b610fa8565b34801561049757600080fd5b50600154600054035b6040519081526020016103c0565b3480156104ba57600080fd5b506103926104c93660046151f2565b611001565b6103926104dc36600461525d565b61102b565b3480156104ed57600080fd5b506104a06104fc3660046151c5565b6111bf565b34801561050d57600080fd5b506021546103b49060ff1681565b34801561052757600080fd5b5061053b61053636600461523b565b6111d4565b604080516001600160a01b0390931683526020830191909152016103c0565b34801561056657600080fd5b506103926105753660046151c5565b611282565b34801561058657600080fd5b5061039261059536600461529e565b611297565b3480156105a657600080fd5b506103926112f8565b3480156105bb57600080fd5b506105c461131d565b6040516103c091906152d8565b3480156105dd57600080fd5b506103926105ec3660046153b3565b6114f8565b3480156105fd57600080fd5b5061039261060c36600461543e565b6116c8565b34801561061d57600080fd5b506104a0600080516020615de783398151915281565b34801561063f57600080fd5b50601a5461042b906001600160a01b031681565b34801561065f57600080fd5b5061039261066e3660046151f2565b6116e4565b34801561067f57600080fd5b5061039261068e36600461543e565b61170f565b34801561069f57600080fd5b5060145461042b906001600160a01b031681565b3480156106bf57600080fd5b50610392611789565b3480156106d457600080fd5b506104a06106e336600461523b565b6117a8565b3480156106f457600080fd5b506103926117bb565b61039261070b36600461520f565b6117db565b61039261071e36600461525d565b61180b565b34801561072f57600080fd5b5061039261073e3660046151f2565b611826565b34801561074f57600080fd5b506025546103b490610100900460ff1681565b34801561076e57600080fd5b50610392611851565b34801561078357600080fd5b50600b5460ff166103b4565b34801561079b57600080fd5b506103926107aa3660046151f2565b61186c565b3480156107bb57600080fd5b5061042b6107ca3660046151c5565b611897565b3480156107db57600080fd5b506103926118a2565b3480156107f057600080fd5b506025546107fe9060ff1681565b60405160ff90911681526020016103c0565b34801561081c57600080fd5b506104a061082b3660046151f2565b6118b6565b34801561083c57600080fd5b50610392611904565b34801561085157600080fd5b506103fe611916565b34801561086657600080fd5b506103fe6119a4565b34801561087b57600080fd5b506104a061088a3660046151c5565b6119b1565b34801561089b57600080fd5b506103926119fe565b3480156108b057600080fd5b50610392611a2d565b3480156108c557600080fd5b506103926108d4366004615094565b611a4d565b3480156108e557600080fd5b506103b4611a61565b3480156108fa57600080fd5b5061042b611a7a565b34801561090f57600080fd5b506103fe611a89565b34801561092457600080fd5b5061042b61093336600461523b565b611a96565b34801561094457600080fd5b506104a0611aae565b34801561095957600080fd5b506103926109683660046151c5565b611abe565b34801561097957600080fd5b506103b461098836600461543e565b611acb565b34801561099957600080fd5b506103fe611af6565b3480156109ae57600080fd5b506104a060205481565b3480156109c457600080fd5b506104a0600081565b3480156109d957600080fd5b506103926109e8366004615463565b611b05565b3480156109f957600080fd5b50610392611b71565b348015610a0e57600080fd5b506104a060265481565b348015610a2457600080fd5b50610392610a33366004615498565b611b8e565b610392610a46366004615530565b611ba3565b348015610a5757600080fd5b50600f54601054601154601254601354610a93949392916001600160f81b0381169160ff600160f81b9092048216918181169161010090041687565b604080519788526020880196909652948601939093526001600160f81b03909116606085015215156080840152151560a0830152151560c082015260e0016103c0565b348015610ae257600080fd5b50610392611bed565b348015610af757600080fd5b50610392610b0636600461520f565b611c04565b348015610b1757600080fd5b50610392610b26366004615498565b611d10565b348015610b3757600080fd5b506103fe610b463660046151c5565b611d25565b348015610b5757600080fd5b506104a0610b663660046151c5565b6124c3565b348015610b7757600080fd5b50610392610b863660046151f2565b6124da565b348015610b9757600080fd5b50610392610ba63660046155de565b612505565b348015610bb757600080fd5b5060185461042b906001600160a01b031681565b348015610bd757600080fd5b50610392610be636600461543e565b612524565b348015610bf757600080fd5b506028546103b490600160a01b900460ff1681565b348015610c1857600080fd5b50600f546104a0565b348015610c2d57600080fd5b5060195461042b906001600160a01b031681565b348015610c4d57600080fd5b50610392610c5c366004615601565b612540565b348015610c6d57600080fd5b506103b4610c7c366004615622565b6001600160a01b03918216600090815260076020908152604080832093909416825291909152205460ff1690565b348015610cb657600080fd5b50610392610cc53660046151f2565b61257a565b348015610cd657600080fd5b50610392610ce53660046151f2565b6125a5565b610cf261261b565b806001600160401b03811115610d0a57610d0a615330565b604051908082528060200260200182016040528015610d3d57816020015b6060815260200190600190039081610d285790505b508051610d5291602491602090910190614f47565b5060005b81811015610dbf57828282818110610d7057610d70615650565b9050602002810190610d829190615666565b60248381548110610d9557610d95615650565b906000526020600020019182610dac92919061573b565b5080610db78161580a565b915050610d56565b50610dc861267a565b5050565b6000610dd78261268c565b92915050565b600080516020615de7833981519152610df5816126c4565b610dff83836126ce565b505050565b6060601b8054610e13906156ac565b80601f0160208091040260200160405190810160405280929190818152602001828054610e3f906156ac565b8015610e8c5780601f10610e6157610100808354040283529160200191610e8c565b820191906000526020600020905b815481529060010190602001808311610e6f57829003601f168201915b5050505050905090565b6000610ea1826127c7565b610ebe576040516333d1c03960e21b815260040160405180910390fd5b506000908152600660205260409020546001600160a01b031690565b610ee261261b565b601980546001600160a01b0319166001600160a01b038316179055610f0561267a565b50565b6000610f1382611897565b9050336001600160a01b03821614610f4c57610f2f8133610c7c565b610f4c576040516367d9dca160e11b815260040160405180910390fd5b60008281526006602052604080822080546001600160a01b0319166001600160a01b0387811691821790925591518593918516917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591a4505050565b610fb061261b565b600160fa1b8214158015610fc85750600160fb1b8214155b8015610fd85750600160fc1b8214155b15610ff657604051631258e44360e01b815260040160405180910390fd5b808255610dc861267a565b61100961261b565b601480546001600160a01b0319166001600160a01b0392909216919091179055565b6000611036826127ee565b9050836001600160a01b0316816001600160a01b0316146110695760405162a1148160e81b815260040160405180910390fd5b60008281526006602052604090208054338082146001600160a01b038816909114176110b6576110998633610c7c565b6110b657604051632ce44b5f60e11b815260040160405180910390fd5b6001600160a01b0385166110dd57604051633a954ecd60e21b815260040160405180910390fd5b6110ea8686866001612855565b80156110f557600082555b6001600160a01b0386811660009081526005602052604080822080546000190190559187168152208054600101905561113285600160e11b6128a5565b600085815260046020526040812091909155600160e11b84169003611187576001840160008181526004602052604081205490036111855760005481146111855760008181526004602052604090208490555b505b83856001600160a01b0316876001600160a01b0316600080516020615e4783398151915260405160405180910390a45b505050505050565b60009081526009602052604090206001015490565b6000828152600d602090815260408083208151808301909252546001600160a01b038116808352600160a01b9091046001600160601b0316928201929092528291611249575060408051808201909152600c546001600160a01b0381168252600160a01b90046001600160601b031660208201525b602081015160009061271090611268906001600160601b031687615823565b6112729190615850565b91519350909150505b9250929050565b61128a61261b565b6026819055610f0561267a565b61129f61261b565b6112a98180615666565b601d916112b791908361573b565b506112c56020820182615666565b601e916112d391908361573b565b506112e16040820182615666565b601f916112ef91908361573b565b50610f0561267a565b61130061261b565b6028805460ff60a01b1916600160a01b17905561131b61267a565b565b61134160405180606001604052806060815260200160608152602001606081525090565b601d805461134e906156ac565b80601f016020809104026020016040519081016040528092919081815260200182805461137a906156ac565b80156113c75780601f1061139c576101008083540402835291602001916113c7565b820191906000526020600020905b8154815290600101906020018083116113aa57829003601f168201915b5050509183525050601e80546113dc906156ac565b80601f0160208091040260200160405190810160405280929190818152602001828054611408906156ac565b80156114555780601f1061142a57610100808354040283529160200191611455565b820191906000526020600020905b81548152906001019060200180831161143857829003601f168201915b50505050508160200181905250601f805461146f906156ac565b80601f016020809104026020016040519081016040528092919081815260200182805461149b906156ac565b80156114e85780601f106114bd576101008083540402835291602001916114e8565b820191906000526020600020905b8154815290600101906020018083116114cb57829003601f168201915b5050505050816040018190525090565b61150061261b565b80606001516001600160f81b0316816000015110156115655760405162461bcd60e51b815260206004820152601c60248201527b53656c6c65723a2065786365737369766520667265652071756f746160201b60448201526064015b60405180910390fd5b601554815110156115b85760405162461bcd60e51b815260206004820181905260248201527f53656c6c65723a20696e76656e746f7279203c20616c726561647920736f6c64604482015260640161155c565b60175481606001516001600160f81b031610156116215760405162461bcd60e51b815260206004820152602160248201527f53656c6c65723a20667265652071756f7461203c20616c7265616479207573656044820152601960fa1b606482015260840161155c565b601354610100900460ff161561163e57600160c0820152600f5481525b60135460ff161561166257600160a08201526012546001600160f81b031660608201525b8051600f5560208101516010556040810151601155606081015160808201511515600160f81b026001600160f81b039091161760125560a08101516013805460c09093015115156101000261ff00199215159290921661ffff1990931692909217179055565b6116d1826111bf565b6116da816126c4565b610dff83836128ba565b6116ec61261b565b601a80546001600160a01b0319166001600160a01b038316179055610f0561267a565b6001600160a01b038116331461177f5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b606482015260840161155c565b610dc882826128dc565b61179161261b565b6025805461ff00191661010017905561131b61267a565b60006117b48284615823565b9392505050565b600080516020615de78339815191526117d3816126c4565b610f056128fe565b60215460ff166117fe5760405163951b974f60e01b815260040160405180910390fd5b610dc8828260205461294a565b610dff83838360405180602001604052806000815250611ba3565b61182e61261b565b601880546001600160a01b0319166001600160a01b038316179055610f0561267a565b61185961261b565b6025805461ff001916905561131b61267a565b61187461261b565b602880546001600160a01b0319166001600160a01b038316179055610f0561267a565b6000610dd7826127ee565b6118aa61261b565b6021805460ff19169055565b60006001600160a01b0382166118df576040516323d3ad8160e21b815260040160405180910390fd5b506001600160a01b03166000908152600560205260409020546001600160401b031690565b61190c61261b565b61131b6000612de2565b601d8054611923906156ac565b80601f016020809104026020016040519081016040528092919081815260200182805461194f906156ac565b801561199c5780601f106119715761010080835404028352916020019161199c565b820191906000526020600020905b81548152906001019060200180831161197f57829003601f168201915b505050505081565b601f8054611923906156ac565b6000600160fa1b82141580156119cb5750600160fb1b8214155b80156119db5750600160fc1b8214155b156119f957604051631258e44360e01b815260040160405180910390fd5b505490565b600080516020615de7833981519152611a16816126c4565b610f056000611a286001546000540390565b612e34565b600080516020615de7833981519152611a45816126c4565b610f05612e71565b611a5561261b565b610dbf60238383614f9d565b600f54600090611a746001546000540390565b14905090565b6008546001600160a01b031690565b601e8054611923906156ac565b6000828152600a602052604081206117b49083612eae565b6000611ab960155490565b905090565b611ac661261b565b602055565b60009182526009602090815260408084206001600160a01b0393909316845291905290205460ff1690565b6060601c8054610e13906156ac565b3360008181526007602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b611b7961261b565b6028805460ff60a01b1916905561131b61267a565b611b9661261b565b601c610dbf82848361573b565b611bae84848461102b565b6001600160a01b0383163b15611be757611bca84848484612eba565b611be7576040516368d2bf6b60e11b815260040160405180910390fd5b50505050565b611bf561261b565b6021805460ff19166001179055565b611c0c61261b565b611c14612fa6565b6012546001600160f81b0316611c3c82611c2d60175490565b611c379084615864565b612fec565b915060008211611c8c5760405162461bcd60e51b815260206004820152601b60248201527a14d95b1b195c8e88119c9959481c5d5bdd1848195e18d959591959602a1b604482015260640161155c565b600f54611c9c83611c2d60155490565b925060008311611cbe5760405162461bcd60e51b815260040161155c90615877565b611cc9601584613002565b611cd4601784613002565b611ce08484600161301f565b80611cea60155490565b1115611cf857611cf86158a1565b81611d0260175490565b1115611be757611be76158a1565b611d1861261b565b601b610dbf82848361573b565b606081611d31816127c7565b611d885760405162461bcd60e51b815260206004820152602260248201527f45524337323141436f6d6d6f6e3a20546f6b656e20646f65736e2774206578696044820152611cdd60f21b606482015260840161155c565b6019546001600160a01b031615611e115760195460405163c87b56dd60e01b8152600481018590526001600160a01b039091169063c87b56dd90602401600060405180830381865afa158015611de2573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611e0a91908101906158e7565b91506124bd565b60008381526022602090815260408083205481519283018190529291611e5c910160408051601f19818403018152828252805160209182012083830190925290825260809082015290565b600f5490915060006064611e71836019615823565b611e7b9190615850565b90506000611e91818484876000604060006130b6565b9050611ea5818484876001603860006130b6565b9050611eb9818484876002603060016130b6565b9050611ecd818484876003602860016130b6565b9050611ee1818484876004602060016130b6565b9050611ef5818484876005601060016130b6565b9050611f09818484876006600860016130b6565b9050611f1d818484876007600060016130b6565b6029546040805160e0810182526001600160481b0384168152602554610100900460ff1615156020808301919091526023805484518184028101840186528181529697506000966001600160a01b0390961695635bd320e99585019390929190830182828015611fac57602002820191906000526020600020905b815481526020019060010190808311611f98575b505050505081526020018c8152602001611fc9600160fa1b6119b1565b8152602001611fdb600160fb1b6119b1565b8152602001611fed600160fc1b6119b1565b8152506040518263ffffffff1660e01b815260040161200c919061592f565b600060405180830381865afa158015612029573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261205191908101906158e7565b6025549091506000906120929061206c9060ff1660366159cc565b60255463ffffffff91909116906120879060ff1660366159cc565b63ffffffff16613155565b9150600090506120d860036120a88460366159f4565b6120b39060026159f4565b6120be906004615823565b6120c89190615850565b6120d39060166159f4565b6131b3565b905061211b6040518060400160405280601681526020017519185d184e9a5b5859d94bd89b5c0ed8985cd94d8d0b60521b815250826131d090919063ffffffff16565b602854600160a01b900460ff1680612138575060255460ff166001145b1561215b5761215661214c846036806131e5565b829060008061322b565b6121a8565b60255461218a9061214c906121749060ff1660366159cc565b6025546121859060ff1660366159cc565b613337565b6121a8816121978561345f565b60255460369060049060ff166135b1565b60006040518060c001604052808381526020016121c4876136d7565b81526020018d6026546121d791906159f4565b8152602001601d80546121e9906156ac565b80601f0160208091040260200160405190810160405280929190818152602001828054612215906156ac565b80156122625780601f1061223757610100808354040283529160200191612262565b820191906000526020600020905b81548152906001019060200180831161224557829003601f168201915b50505050508152602001601e8054612279906156ac565b80601f01602080910402602001604051908101604052809291908181526020018280546122a5906156ac565b80156122f25780601f106122c7576101008083540402835291602001916122f2565b820191906000526020600020905b8154815290600101906020018083116122d557829003601f168201915b50505050508152602001601f8054612309906156ac565b80601f0160208091040260200160405190810160405280929190818152602001828054612335906156ac565b80156123825780601f1061235757610100808354040283529160200191612382565b820191906000526020600020905b81548152906001019060200180831161236557829003601f168201915b5050509190925250506018546028549192506001600160a01b031690600160a01b900460ff161561243e5760285460405163284e491b60e11b81526001600160a01b038381169263509c9236926123f292879290811691600160a81b90910460ff16906036908190600401615aa3565b600060405180830381865afa15801561240f573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261243791908101906158e7565b9b506124b2565b60405163e76d9fb360e01b81526001600160a01b0382169063e76d9fb39061246a908590600401615b08565b600060405180830381865afa158015612487573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526124af91908101906158e7565b9b505b505050505050505050505b50919050565b6000818152600a60205260408120610dd790613fb5565b6124e261261b565b602780546001600160a01b0319166001600160a01b038316179055610f0561267a565b61250d61261b565b6025805460ff191660ff8316179055610f0561267a565b61252d826111bf565b612536816126c4565b610dff83836128dc565b61254861261b565b6028805482919060ff60a81b1916600160a81b83600381111561256d5761256d615a8d565b0217905550610f0561267a565b61258261261b565b602980546001600160a01b0319166001600160a01b038316179055610f0561267a565b6125ad61261b565b6001600160a01b0381166126125760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161155c565b610f0581612de2565b33612624611a7a565b6001600160a01b03161461131b5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161155c565b61131b6000611a286001546000540390565b600061269782613fbf565b806126a657506126a68261400d565b806126b557506126b58261402e565b80610dd75750610dd782614039565b610f05813361405e565b6127106001600160601b038216111561273c5760405162461bcd60e51b815260206004820152602a60248201527f455243323938313a20726f79616c7479206665652077696c6c206578636565646044820152692073616c65507269636560b01b606482015260840161155c565b6001600160a01b03821661278e5760405162461bcd60e51b815260206004820152601960248201527822a921991c9c189d1034b73b30b634b2103932b1b2b4bb32b960391b604482015260640161155c565b604080518082019091526001600160a01b039092168083526001600160601b039091166020909201829052600160a01b90910217600c55565b6000805482108015610dd7575050600090815260046020526040902054600160e01b161590565b60008160005481101561283c5760008181526004602052604081205490600160e01b8216900361283a575b806000036117b4575060001901600081815260046020526040902054612819565b505b604051636f96cda160e11b815260040160405180910390fd5b600b5460ff16156128a05760405162461bcd60e51b8152602060048201526015602482015274115490cdcc8c5050dbdb5b5bdb8e881c185d5cd959605a1b604482015260640161155c565b611be7565b4260a01b176001600160a01b03919091161790565b6128c4828261409c565b6000828152600a60205260409020610dff9082614122565b6128e68282614137565b6000828152600a60205260409020610dff908261419e565b6129066141b3565b600b805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b60405161294091906151de565b60405180910390a1565b6002600e540361299c5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015260640161155c565b6002600e556129a9612fa6565b6040805160e081018252600f54815260105460208201526011549181018290526012546001600160f81b038116606083015260ff600160f81b909104811615156080830152601354808216151560a0840152610100900416151560c08201529060009015612a2457612a1f848360400151612fec565b612a26565b835b9050600080836080015115612a6e5760608401518451612a4f916001600160f81b031690615864565b9150612a5a60175490565b601554612a679190615864565b9050612a7e565b83519150612a7b60155490565b90505b612a8c83611c378385615864565b925060008311612aae5760405162461bcd60e51b815260040161155c90615877565b602084015115612c0a57336001600160a01b038816811415906000903214801590612ae25750326001600160a01b038a1614155b9050612b12858a6040518060400160405280600b81526020016a109d5e595c881b1a5b5a5d60aa1b8152506141fc565b94508115612b4c57612b4985336040518060400160405280600c81526020016b14d95b99195c881b1a5b5a5d60a21b8152506141fc565b94505b8015612b8457612b8185326040518060400160405280600c81526020016b13dc9a59da5b881b1a5b5a5d60a21b8152506141fc565b94505b6001600160a01b03891660009081526016602052604081208054879290612bac9084906159f4565b90915550508115612bdc573360009081526016602052604081208054879290612bd69084906159f4565b90915550505b8015612c07573260009081526016602052604081208054879290612c019084906159f4565b90915550505b50505b6000612c1684876117a8565b905080341015612c6c57612c36612c31633b9aca0083615850565b614251565b604051602001612c469190615b1b565b60408051601f198184030181529082905262461bcd60e51b825261155c916004016151b2565b612c77601585613002565b84516015541115612c8a57612c8a6158a1565b612c968885600061301f565b8015612cfb57601454612cb2906001600160a01b031682614351565b60145460408051868152602081018490526001600160a01b03909216917f01f51b99bd1c3cca301836178e5dee13aadfe44eff06dc3ddcbf3c9d058454f8910160405180910390a25b80341115612dd357336000612d108334615864565b9050600080836001600160a01b03168360405160006040518083038185875af1925050503d8060008114612d60576040519150601f19603f3d011682016040523d82523d6000602084013e612d65565b606091505b5091509150818190612d8a5760405162461bcd60e51b815260040161155c91906151b2565b50836001600160a01b03167fbb28353e4598c3b9199101a66e0989549b659a59a54d2c27fbb183f1932c8e6d84604051612dc691815260200190565b60405180910390a2505050505b50506001600e55505050505050565b600880546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60408051838152602081018390527f6bd5c950a8d8df17f772f5af37cb3655737899cbf903264b9795592da439661c910160405180910390a15050565b612e79612fa6565b600b805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586129333390565b60006117b48383614467565b604051630a85bd0160e11b81526000906001600160a01b0385169063150b7a0290612eef903390899088908890600401615b60565b6020604051808303816000875af1925050508015612f2a575060408051601f3d908101601f19168201909252612f2791810190615b9d565b60015b612f88573d808015612f58576040519150601f19603f3d011682016040523d82523d6000602084013e612f5d565b606091505b508051600003612f80576040516368d2bf6b60e11b815260040160405180910390fd5b805181602001fd5b6001600160e01b031916630a85bd0160e11b1490505b949350505050565b600b5460ff161561131b5760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015260640161155c565b6000818310612ffb57816117b4565b5090919050565b8082600001600082825461301691906159f4565b90915550505050565b600080549061302e84836159f4565b905061303a8585614491565b808210156130af576040516001600160601b031930606090811b8216602084015241901b1660348201524360488201524460688201526088810183905260a80160408051601f198184030181529181528151602092830120600085815260229093529120556130a88261580a565b915061303a565b5050505050565b600080602385815481106130cc576130cc615650565b9060005260206000200154905060006130e5878a6144ab565b9050831561312357846001600160481b031688821061310d576131088383615bba565b61310f565b825b6001600160481b0316901b8a179950613147565b6001600160481b0385166131378383615bba565b6001600160481b0316901b8a1799505b509798975050505050505050565b60008080613164856003615823565b905060006004613178600319841684615864565b613183906004615864565b61318d9190615bba565b9050600061319b82846159f4565b6131a59087615823565b919791965090945050505050565b604080518281016060018252910181526000602090910190815290565b6131db8282516144c0565b610dc88282614545565b606060006131ff8463ffffffff168463ffffffff16613155565b9150600090506132136120d38360366159f4565b90506132218187878761457b565b5095945050505050565b8251600081900361323c5750611be7565b60036002828101829004901b908206831561325e576001811481151501820391505b61326887836144c0565b6040517f4142434445464748494a4b4c4d4e4f505152535455565758595a616263646566601f526102308615027f6768696a6b6c6d6e6f707172737475767778797a303132333435363738392d5f03603f52875160208901018488015b6003890198508851603f8160121c16518353603f81600c1c16516001840153603f8160061c16516002840153603f8116516003840153506004820191508089106132c557508561332457603d831515820353603d6001841460011b8203535b5087519092018752506040525050505050565b606060006133518463ffffffff168463ffffffff16613155565b6040805160368082526060820190925291935060009250602082018180368337019050509050604260f81b8160008151811061338f5761338f615650565b60200101906001600160f81b031916908160001a905350604d60f81b816001815181106133be576133be615650565b60200101906001600160f81b031916908160001a90535060006133e2836036615bce565b90506133f082600283614607565b6133fd82600a6036614607565b61340a82600e6028614607565b61341682601288614607565b61342282601687614607565b61342f82601a60016146ff565b61343c82601c60186146ff565b6134498260266001614607565b61345682602a6001614607565b50949350505050565b6060815160000361347e57505060408051602081019091526000815290565b6000604051806060016040528060408152602001615e0760409139905060006003845160026134ad91906159f4565b6134b79190615850565b6134c2906004615823565b6001600160401b038111156134d9576134d9615330565b6040519080825280601f01601f191660200182016040528015613503576020820181803683370190505b509050600182016020820185865187015b8082101561356f576003820191508151603f8160121c168501518453600184019350603f81600c1c168501518453600184019350603f8160061c168501518453600184019350603f8116850151845350600183019250613514565b505060038651066001811461358b576002811461359e576135a6565b603d6001830353603d60028303536135a6565b603d60018303535b509195945050505050565b6135d3818286516135c29190615823565b6135cc9190615823565b86906144c0565b613620565b83820281015b8082101561361657816020858201035b81811061360157878252908801906135ee565b508051891689198816179052908201906135de565b5050505050505050565b60208401845181016020860182038486028586602004028587028a5160208c01018784026000198a60031b1c1960001985850660031b1c5b888a10156136bb576000828b5116600060088f025b89821015613686579282179291821c91908f019061366d565b5050506136988288838f8a898b6135d8565b50988b0198968b0196928401928688066136b6578a87840302840193505b613658565b5050505050505050505080810284510285510185525050505050565b601a546060906001600160a01b03161561376457601a54604051636f05967b60e01b81526001600160481b03841660048201526001600160a01b0390911690636f05967b90602401600060405180830381865afa15801561373c573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610dd791908101906158e7565b61376f6103e86131b3565b90506137aa6040518060400160405280600e81526020016d2261747472696275746573223a5b60901b8152508261454590919063ffffffff16565b602554600090610100900460ff1615613f46576138ed8260246000815481106137d5576137d5615650565b9060005260206000200180546137ea906156ac565b80601f0160208091040260200160405190810160405280929190818152602001828054613816906156ac565b80156138635780601f1061383857610100808354040283529160200191613863565b820191906000526020600020905b81548152906001019060200180831161384657829003601f168201915b50506027546040805163079be49360e01b81526001600160a01b03909216945063079be49393506138a29250600091908b901c60ff1690600401615beb565b600060405180830381865afa1580156138bf573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526138e791908101906158e7565b84614747565b90506139d482602460018154811061390757613907615650565b90600052602060002001805461391c906156ac565b80601f0160208091040260200160405190810160405280929190818152602001828054613948906156ac565b80156139955780601f1061396a57610100808354040283529160200191613995565b820191906000526020600020905b81548152906001019060200180831161397857829003601f168201915b505060275460405163079be49360e01b81526001600160a01b03909116935063079be49392506138a2915060019060ff60388c901c1690600401615beb565b9050613abb8260246002815481106139ee576139ee615650565b906000526020600020018054613a03906156ac565b80601f0160208091040260200160405190810160405280929190818152602001828054613a2f906156ac565b8015613a7c5780601f10613a5157610100808354040283529160200191613a7c565b820191906000526020600020905b815481529060010190602001808311613a5f57829003601f168201915b505060275460405163079be49360e01b81526001600160a01b03909116935063079be49392506138a2915060029060ff60308c901c1690600401615beb565b9050613ba2826024600381548110613ad557613ad5615650565b906000526020600020018054613aea906156ac565b80601f0160208091040260200160405190810160405280929190818152602001828054613b16906156ac565b8015613b635780601f10613b3857610100808354040283529160200191613b63565b820191906000526020600020905b815481529060010190602001808311613b4657829003601f168201915b505060275460405163079be49360e01b81526001600160a01b03909116935063079be49392506138a2915060039060ff60288c901c1690600401615beb565b9050613c88826024600481548110613bbc57613bbc615650565b906000526020600020018054613bd1906156ac565b80601f0160208091040260200160405190810160405280929190818152602001828054613bfd906156ac565b8015613c4a5780601f10613c1f57610100808354040283529160200191613c4a565b820191906000526020600020905b815481529060010190602001808311613c2d57829003601f168201915b505060275460405163079be49360e01b81526001600160a01b03909116935063079be49392506138a2915060049060ff60208c901c16908201615beb565b9050613d75826024600581548110613ca257613ca2615650565b906000526020600020018054613cb7906156ac565b80601f0160208091040260200160405190810160405280929190818152602001828054613ce3906156ac565b8015613d305780601f10613d0557610100808354040283529160200191613d30565b820191906000526020600020905b815481529060010190602001808311613d1357829003601f168201915b505060275460405163079be49360e01b81526005600482015260108b901c61ffff1660248201526001600160a01b03909116935063079be493925060440190506138a2565b9050613e5c826024600681548110613d8f57613d8f615650565b906000526020600020018054613da4906156ac565b80601f0160208091040260200160405190810160405280929190818152602001828054613dd0906156ac565b8015613e1d5780601f10613df257610100808354040283529160200191613e1d565b820191906000526020600020905b815481529060010190602001808311613e0057829003601f168201915b505060275460405163079be49360e01b81526001600160a01b03909116935063079be49392506138a2915060069060ff60088c901c1690600401615beb565b9050613f3f826024600781548110613e7657613e76615650565b906000526020600020018054613e8b906156ac565b80601f0160208091040260200160405190810160405280929190818152602001828054613eb7906156ac565b8015613f045780601f10613ed957610100808354040283529160200191613f04565b820191906000526020600020905b815481529060010190602001808311613ee757829003601f168201915b505060275460405163079be49360e01b81526001600160a01b03909116935063079be49392506138a2915060079060ff8b1690600401615beb565b9050613f92565b613f8f82604051806040016040528060088152602001671c995d99585b195960c21b8152506040518060400160405280600581526020016466616c736560d81b81525084614747565b90505b6040805180820190915260018152605d60f81b60208201526124bd908390614545565b6000610dd7825490565b60006301ffc9a760e01b6001600160e01b031983161480613ff057506380ac58cd60e01b6001600160e01b03198316145b80610dd75750506001600160e01b031916635b5e139f60e01b1490565b60006001600160e01b0319821663152a902d60e11b1480610dd75750610dd7825b6000610dd782614841565b60006001600160e01b03198216632483248360e11b1480610dd75750610dd782614866565b6140688282611acb565b610dc857614080816001600160a01b0316601461487c565b61408b83602061487c565b604051602001612c46929190615bfc565b6140a68282611acb565b610dc85760008281526009602090815260408083206001600160a01b03851684529091529020805460ff191660011790556140de3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b60006117b4836001600160a01b038416614a17565b6141418282611acb565b15610dc85760008281526009602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b60006117b4836001600160a01b038416614a66565b600b5460ff1661131b5760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604482015260640161155c565b6001600160a01b038216600090815260166020526040812054601054829161422391615864565b90508060000361423e5782604051602001612c469190615c6b565b6142488582612fec565b95945050505050565b6060816000036142785750506040805180820190915260018152600360fc1b602082015290565b8160005b81156142a2578061428c8161580a565b915061429b9050600a83615850565b915061427c565b6000816001600160401b038111156142bc576142bc615330565b6040519080825280601f01601f1916602001820160405280156142e6576020820181803683370190505b5090505b8415612f9e576142fb600183615864565b9150614308600a86615bba565b6143139060306159f4565b60f81b81838151811061432857614328615650565b60200101906001600160f81b031916908160001a90535061434a600a86615850565b94506142ea565b804710156143a15760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e6365000000604482015260640161155c565b6000826001600160a01b03168260405160006040518083038185875af1925050503d80600081146143ee576040519150601f19603f3d011682016040523d82523d6000602084013e6143f3565b606091505b5050905080610dff5760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c20726044820152791958da5c1a595b9d081b585e481a185d99481c995d995c9d195960321b606482015260840161155c565b600082600001828154811061447e5761447e615650565b9060005260206000200154905092915050565b610dc8828260405180602001604052806000815250614b60565b60006117b483836144bb85614bc6565b614bdc565b60006144d283601f190151603f190190565b905060008284516144e391906159f4565b905080821015611be75760405162461bcd60e51b815260206004820152602760248201527f44796e616d69634275666665723a20417070656e64696e67206f7574206f66206044820152663137bab732399760c91b606482015260840161155c565b8051602082019150808201602084510184015b81841015614570578351815260209384019301614558565b505082510190915250565b825160609061458a83856159cc565b6145959060036159cc565b63ffffffff16146145de576145aa82846159cc565b6145b59060036159cc565b8451604051635fae4ac560e11b815263ffffffff9092166004830152602482015260440161155c565b6145f26145eb8484613337565b86906131d0565b6145fe85858585614bfa565b50929392505050565b8060f81b83838151811061461d5761461d615650565b60200101906001600160f81b031916908160001a9053506001600160f81b031960f082901b168361464f8460016159f4565b8151811061465f5761465f615650565b60200101906001600160f81b031916908160001a9053506001600160f81b031960e882901b16836146918460026159f4565b815181106146a1576146a1615650565b60200101906001600160f81b031916908160001a9053506001600160f81b031960e082901b16836146d38460036159f4565b815181106146e3576146e3615650565b60200101906001600160f81b031916908160001a905350505050565b8060f81b83838151811061471557614715615650565b60200101906001600160f81b031916908160001a9053506001600160f81b031960f082901b16836146d38460016159f4565b815160009015614839578161475b81615c9b565b9250506147a360018360ff1611614781576040518060200160405280600081525061479c565b604051806040016040528060018152602001600b60fa1b8152505b8690614545565b60408051808201909152600f81526e3d913a3930b4ba2fba3cb832911d1160891b60208201526147d4908690614545565b6147de8585614545565b60408051808201909152600b81526a1116113b30b63ab2911d1160a91b602082015261480b908690614545565b6148158584614545565b604080518082019091526002815261227d60f01b6020820152614839908690614545565b509392505050565b60006001600160e01b03198216635a05180f60e01b1480610dd75750610dd782614c2c565b6001600160e01b0319166301ffc9a760e01b1490565b6060600061488b836002615823565b6148969060026159f4565b6001600160401b038111156148ad576148ad615330565b6040519080825280601f01601f1916602001820160405280156148d7576020820181803683370190505b509050600360fc1b816000815181106148f2576148f2615650565b60200101906001600160f81b031916908160001a905350600f60fb1b8160018151811061492157614921615650565b60200101906001600160f81b031916908160001a9053506000614945846002615823565b6149509060016159f4565b90505b60018111156149c8576f181899199a1a9b1b9c1cb0b131b232b360811b85600f166010811061498457614984615650565b1a60f81b82828151811061499a5761499a615650565b60200101906001600160f81b031916908160001a90535060049490941c936149c181615cba565b9050614953565b5083156117b45760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e74604482015260640161155c565b6000818152600183016020526040812054614a5e57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610dd7565b506000610dd7565b60008181526001830160205260408120548015614b4f576000614a8a600183615864565b8554909150600090614a9e90600190615864565b9050818114614b03576000866000018281548110614abe57614abe615650565b9060005260206000200154905080876000018481548110614ae157614ae1615650565b6000918252602080832090910192909255918252600188019052604090208390555b8554869080614b1457614b14615cd1565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610dd7565b6000915050610dd7565b5092915050565b614b6a8383614c51565b6001600160a01b0383163b15610dff576000548281035b614b946000868380600101945086612eba565b614bb1576040516368d2bf6b60e11b815260040160405180910390fd5b818110614b815781600054146130af57600080fd5b6000815b80156124bd576001918201911c614bca565b815b8281106117b457614bf3848361ffff16614d46565b9050614bde565b6000614c128363ffffffff168363ffffffff16613155565b9150614c20905085826144c0565b6130af85858585614e08565b60006001600160e01b03198216637965db0b60e01b1480610dd75750610dd782614866565b6000805490829003614c765760405163b562e8dd60e01b815260040160405180910390fd5b614c836000848385612855565b6001600160a01b038316600090815260056020526040902080546001600160401b018402019055614cba836001841460e11b6128a5565b6000828152600460205260408120919091556001600160a01b038416908383019083908390600080516020615e478339815191528180a4600183015b818114614d1c5780836000600080516020615e47833981519152600080a4600101614cf6565b5081600003614d3d57604051622e076360e81b815260040160405180910390fd5b60005550505050565b60006080821115614d8e5760405162461bcd60e51b815260206004820152601260248201527150524e473a206d617820313238206269747360701b604482015260640161155c565b602083015182811115614dad57614da58484614f28565b915050610dd7565b6000614db98285615864565b9050614dc58583614f28565b811b9250614df38580516128a8600160801b036001600160801b03821602608091821c018252602090910152565b614dfd8582614f28565b909217949350505050565b60006020614e178460036159cc565b614e219190615ce7565b63ffffffff16905060006020614e388560036159cc565b614e429190615d0a565b63ffffffff16905080600003614e6457614e5d600183615864565b9150602090505b6000614e7c8563ffffffff168563ffffffff16613155565b50905060006001614e8e846020615864565b614e99906008615823565b6001901b614ea79190615864565b90506000614eb782600019615864565b9050885160208a0101600060208a015b88821015614f125760005b88811015614ef0578151845260209384019390910190600101614ed2565b5082518151851690861617835285870190920191600191909101908601614ec7565b505060208a0181038a5250505050505050505050565b8151602090920180518281039091526101009081039290921b91031c90565b828054828255906000526020600020908101928215614f8d579160200282015b82811115614f8d5782518290614f7d9082615d2d565b5091602001919060010190614f67565b50614f99929150614fe4565b5090565b828054828255906000526020600020908101928215614fd8579160200282015b82811115614fd8578235825591602001919060010190614fbd565b50614f99929150615001565b80821115614f99576000614ff88282615016565b50600101614fe4565b5b80821115614f995760008155600101615002565b508054615022906156ac565b6000825580601f10615032575050565b601f016020900490600052602060002090810190610f059190615001565b60008083601f84011261506257600080fd5b5081356001600160401b0381111561507957600080fd5b6020830191508360208260051b850101111561127b57600080fd5b600080602083850312156150a757600080fd5b82356001600160401b038111156150bd57600080fd5b6150c985828601615050565b90969095509350505050565b6001600160e01b031981168114610f0557600080fd5b6000602082840312156150fd57600080fd5b81356117b4816150d5565b6001600160a01b0381168114610f0557600080fd5b6000806040838503121561513057600080fd5b823561513b81615108565b915060208301356001600160601b038116811461515757600080fd5b809150509250929050565b60005b8381101561517d578181015183820152602001615165565b50506000910152565b6000815180845261519e816020860160208601615162565b601f01601f19169290920160200192915050565b6020815260006117b46020830184615186565b6000602082840312156151d757600080fd5b5035919050565b6001600160a01b0391909116815260200190565b60006020828403121561520457600080fd5b81356117b481615108565b6000806040838503121561522257600080fd5b823561522d81615108565b946020939093013593505050565b6000806040838503121561524e57600080fd5b50508035926020909101359150565b60008060006060848603121561527257600080fd5b833561527d81615108565b9250602084013561528d81615108565b929592945050506040919091013590565b6000602082840312156152b057600080fd5b81356001600160401b038111156152c657600080fd5b8201606081850312156117b457600080fd5b6020815260008251606060208401526152f46080840182615186565b90506020840151601f19808584030160408601526153128383615186565b92506040860151915080858403016060860152506142488282615186565b634e487b7160e01b600052604160045260246000fd5b60405160e081016001600160401b038111828210171561536857615368615330565b60405290565b604051601f8201601f191681016001600160401b038111828210171561539657615396615330565b604052919050565b803580151581146153ae57600080fd5b919050565b600060e082840312156153c557600080fd5b6153cd615346565b82358152602080840135908201526040808401359082015260608301356001600160f81b03811681146153ff57600080fd5b60608201526154106080840161539e565b608082015261542160a0840161539e565b60a082015261543260c0840161539e565b60c08201529392505050565b6000806040838503121561545157600080fd5b82359150602083013561515781615108565b6000806040838503121561547657600080fd5b823561548181615108565b915061548f6020840161539e565b90509250929050565b600080602083850312156154ab57600080fd5b82356001600160401b03808211156154c257600080fd5b818501915085601f8301126154d657600080fd5b8135818111156154e557600080fd5b8660208285010111156154f757600080fd5b60209290920196919550909350505050565b60006001600160401b0382111561552257615522615330565b50601f01601f191660200190565b6000806000806080858703121561554657600080fd5b843561555181615108565b9350602085013561556181615108565b92506040850135915060608501356001600160401b0381111561558357600080fd5b8501601f8101871361559457600080fd5b80356155a76155a282615509565b61536e565b8181528860208385010111156155bc57600080fd5b8160208401602083013760006020838301015280935050505092959194509250565b6000602082840312156155f057600080fd5b813560ff811681146117b457600080fd5b60006020828403121561561357600080fd5b8135600481106117b457600080fd5b6000806040838503121561563557600080fd5b823561564081615108565b9150602083013561515781615108565b634e487b7160e01b600052603260045260246000fd5b6000808335601e1984360301811261567d57600080fd5b8301803591506001600160401b0382111561569757600080fd5b60200191503681900382131561127b57600080fd5b600181811c908216806156c057607f821691505b6020821081036124bd57634e487b7160e01b600052602260045260246000fd5b601f821115610dff57600081815260208120601f850160051c810160208610156157075750805b601f850160051c820191505b818110156111b757828155600101615713565b600019600383901b1c191660019190911b1790565b6001600160401b0383111561575257615752615330565b6157668361576083546156ac565b836156e0565b6000601f84116001811461579457600085156157825750838201355b61578c8682615726565b8455506130af565b600083815260209020601f19861690835b828110156157c557868501358255602094850194600190920191016157a5565b50868210156157e25760001960f88860031b161c19848701351681555b505060018560011b0183555050505050565b634e487b7160e01b600052601160045260246000fd5b60006001820161581c5761581c6157f4565b5060010190565b8082028115828204841417610dd757610dd76157f4565b634e487b7160e01b600052601260045260246000fd5b60008261585f5761585f61583a565b500490565b81810381811115610dd757610dd76157f4565b60208082526010908201526f14d95b1b195c8e8814dbdb19081bdd5d60821b604082015260600190565b634e487b7160e01b600052600160045260246000fd5b60006158c56155a284615509565b90508281528383830111156158d957600080fd5b6117b4836020830184615162565b6000602082840312156158f957600080fd5b81516001600160401b0381111561590f57600080fd5b8201601f8101841361592057600080fd5b612f9e848251602084016158b7565b602080825282516001600160481b03168282015282810151151560408084019190915283015160e06060840152805161010084018190526000929182019083906101208601905b808310156159965783518252928401926001929092019190840190615976565b5060608701516080870152608087015160a087015260a087015160c087015260c087015160e08701528094505050505092915050565b63ffffffff8181168382160280821691908281146159ec576159ec6157f4565b505092915050565b80820180821115610dd757610dd76157f4565b6000815160c08452615a1c60c0850182615186565b905060208301518482036020860152615a358282615186565b9150506040830151604085015260608301518482036060860152615a598282615186565b91505060808301518482036080860152615a738282615186565b91505060a083015184820360a08601526142488282615186565b634e487b7160e01b600052602160045260246000fd5b60a081526000615ab660a0830188615a07565b6001600160a01b0387166020840152905060048510615ae557634e487b7160e01b600052602160045260246000fd5b604082019490945263ffffffff9283166060820152911660809091015292915050565b6020815260006117b46020830184615a07565b6d029b2b63632b91d1021b7b9ba39960951b815260008251615b4481600e850160208701615162565b64204757656960d81b600e939091019283015250601301919050565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090615b9390830184615186565b9695505050505050565b600060208284031215615baf57600080fd5b81516117b4816150d5565b600082615bc957615bc961583a565b500690565b63ffffffff818116838216019080821115614b5957614b596157f4565b91825260ff16602082015260400190565b76020b1b1b2b9b9a1b7b73a3937b61d1030b1b1b7bab73a1604d1b815260008351615c2e816017850160208801615162565b7001034b99036b4b9b9b4b733903937b6329607d1b6017918401918201528351615c5f816028840160208801615162565b01602801949350505050565b67029b2b63632b91d160c51b815260008251615c8e816008850160208701615162565b9190910160080192915050565b600060ff821660ff8103615cb157615cb16157f4565b60010192915050565b600081615cc957615cc96157f4565b506000190190565b634e487b7160e01b600052603160045260246000fd5b600063ffffffff80841680615cfe57615cfe61583a565b92169190910492915050565b600063ffffffff80841680615d2157615d2161583a565b92169190910692915050565b81516001600160401b03811115615d4657615d46615330565b615d5a81615d5484546156ac565b846156e0565b602080601f831160018114615d895760008415615d775750858301515b615d818582615726565b8655506111b7565b600085815260208120601f198616915b82811015615db857888601518255948401946001909101908401615d99565b5085821015615dd65787850151600019600388901b60f8161c191681555b5050505050600190811b0190555056fe1e4c11efbd6a865b1cba79eea33d1b33c1394d834190605ed6a14c71c480bf764142434445464748494a4b4c4d4e4f505152535455565758595a6162636465666768696a6b6c6d6e6f707172737475767778797a303132333435363738392b2fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa26469706673582212205e018b46853be74163c35225f358aeb057669f34bd1c2299b4fdc7dbdd30f8bd64736f6c63430008130033000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000001af400000000000000000000000000000000000000000000000000000000000000640000000000000000000000000000000000000000000000000000000000000064000000000000000000000000617dfd0edaa02f2bc53caec96075450afc833bc3000000000000000000000000617dfd0edaa02f2bc53caec96075450afc833bc300000000000000000000000000000000000000000000000000000000000001f4000000000000000000000000000000000000000000000000000000000000001243727970746f4469636b6275747473205334000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000054344425334000000000000000000000000000000000000000000000000000000
Deployed Bytecode
0x60806040526004361061036d5760003560e01c806301b409a11461037257806301ffc9a71461039457806304634d8d146103c957806306fdde03146103e9578063081812fc1461040b5780630912fc0214610438578063095ea7b314610458578063168d7c471461046b57806318160ddd1461048b5780631c31f710146104ae57806323b872dd146104ce578063248a9ca3146104e157806324bbd049146105015780632a55205a1461051b5780632d28bb021461055a5780632d614ba51461057a5780632d8bb1101461059a5780632e4344c5146105af5780632f274bd4146105d15780632f2ff15d146105f157806331c23d20146106115780633204f6cd14610633578063323d4d0d1461065357806336568abe1461067357806338af3eed146106935780633bd64968146106b35780633ec02e14146106c85780633f4ba83a146106e857806340c10f19146106fd57806342842e0e1461071057806347beec8814610723578063518302271461074357806351c7fa2c146107625780635c975abb146107775780635fbc91701461078f5780636352211e146107af57806364f101f0146107cf578063683dd191146107e457806370a0823114610810578063715018a6146108305780637284e4161461084557806375dadb321461085a5780637eba7ba61461086f5780638222b7d71461088f5780638456cb59146108a4578063879a4105146108b9578063893da6c9146108d95780638da5cb5b146108ee5780638fc73484146109035780639010d07c146109185780639106d7ba1461093857806391b7f5ed1461094d57806391d148541461096d57806395d89b411461098d578063a035b1fe146109a2578063a217fddf146109b8578063a22cb465146109cd578063b167e1b5146109ed578063b25c4b6d14610a02578063b84c824614610a18578063b88d4fde14610a38578063bb69b7ef14610a4b578063bce6d67214610ad6578063bf62e21d14610aeb578063c47f002714610b0b578063c87b56dd14610b2b578063ca15c87314610b4b578063cab940e814610b6b578063cbc1475c14610b8b578063d24c01c614610bab578063d547741f14610bcb578063d567d4e014610beb578063d5abeb0114610c0c578063d76b47cb14610c21578063d7c3d21e14610c41578063e985e9c514610c61578063f0c136cb14610caa578063f2fde38b14610cca575b600080fd5b34801561037e57600080fd5b5061039261038d366004615094565b610cea565b005b3480156103a057600080fd5b506103b46103af3660046150eb565b610dcc565b60405190151581526020015b60405180910390f35b3480156103d557600080fd5b506103926103e436600461511d565b610ddd565b3480156103f557600080fd5b506103fe610e04565b6040516103c091906151b2565b34801561041757600080fd5b5061042b6104263660046151c5565b610e96565b6040516103c091906151de565b34801561044457600080fd5b506103926104533660046151f2565b610eda565b61039261046636600461520f565b610f08565b34801561047757600080fd5b5061039261048636600461523b565b610fa8565b34801561049757600080fd5b50600154600054035b6040519081526020016103c0565b3480156104ba57600080fd5b506103926104c93660046151f2565b611001565b6103926104dc36600461525d565b61102b565b3480156104ed57600080fd5b506104a06104fc3660046151c5565b6111bf565b34801561050d57600080fd5b506021546103b49060ff1681565b34801561052757600080fd5b5061053b61053636600461523b565b6111d4565b604080516001600160a01b0390931683526020830191909152016103c0565b34801561056657600080fd5b506103926105753660046151c5565b611282565b34801561058657600080fd5b5061039261059536600461529e565b611297565b3480156105a657600080fd5b506103926112f8565b3480156105bb57600080fd5b506105c461131d565b6040516103c091906152d8565b3480156105dd57600080fd5b506103926105ec3660046153b3565b6114f8565b3480156105fd57600080fd5b5061039261060c36600461543e565b6116c8565b34801561061d57600080fd5b506104a0600080516020615de783398151915281565b34801561063f57600080fd5b50601a5461042b906001600160a01b031681565b34801561065f57600080fd5b5061039261066e3660046151f2565b6116e4565b34801561067f57600080fd5b5061039261068e36600461543e565b61170f565b34801561069f57600080fd5b5060145461042b906001600160a01b031681565b3480156106bf57600080fd5b50610392611789565b3480156106d457600080fd5b506104a06106e336600461523b565b6117a8565b3480156106f457600080fd5b506103926117bb565b61039261070b36600461520f565b6117db565b61039261071e36600461525d565b61180b565b34801561072f57600080fd5b5061039261073e3660046151f2565b611826565b34801561074f57600080fd5b506025546103b490610100900460ff1681565b34801561076e57600080fd5b50610392611851565b34801561078357600080fd5b50600b5460ff166103b4565b34801561079b57600080fd5b506103926107aa3660046151f2565b61186c565b3480156107bb57600080fd5b5061042b6107ca3660046151c5565b611897565b3480156107db57600080fd5b506103926118a2565b3480156107f057600080fd5b506025546107fe9060ff1681565b60405160ff90911681526020016103c0565b34801561081c57600080fd5b506104a061082b3660046151f2565b6118b6565b34801561083c57600080fd5b50610392611904565b34801561085157600080fd5b506103fe611916565b34801561086657600080fd5b506103fe6119a4565b34801561087b57600080fd5b506104a061088a3660046151c5565b6119b1565b34801561089b57600080fd5b506103926119fe565b3480156108b057600080fd5b50610392611a2d565b3480156108c557600080fd5b506103926108d4366004615094565b611a4d565b3480156108e557600080fd5b506103b4611a61565b3480156108fa57600080fd5b5061042b611a7a565b34801561090f57600080fd5b506103fe611a89565b34801561092457600080fd5b5061042b61093336600461523b565b611a96565b34801561094457600080fd5b506104a0611aae565b34801561095957600080fd5b506103926109683660046151c5565b611abe565b34801561097957600080fd5b506103b461098836600461543e565b611acb565b34801561099957600080fd5b506103fe611af6565b3480156109ae57600080fd5b506104a060205481565b3480156109c457600080fd5b506104a0600081565b3480156109d957600080fd5b506103926109e8366004615463565b611b05565b3480156109f957600080fd5b50610392611b71565b348015610a0e57600080fd5b506104a060265481565b348015610a2457600080fd5b50610392610a33366004615498565b611b8e565b610392610a46366004615530565b611ba3565b348015610a5757600080fd5b50600f54601054601154601254601354610a93949392916001600160f81b0381169160ff600160f81b9092048216918181169161010090041687565b604080519788526020880196909652948601939093526001600160f81b03909116606085015215156080840152151560a0830152151560c082015260e0016103c0565b348015610ae257600080fd5b50610392611bed565b348015610af757600080fd5b50610392610b0636600461520f565b611c04565b348015610b1757600080fd5b50610392610b26366004615498565b611d10565b348015610b3757600080fd5b506103fe610b463660046151c5565b611d25565b348015610b5757600080fd5b506104a0610b663660046151c5565b6124c3565b348015610b7757600080fd5b50610392610b863660046151f2565b6124da565b348015610b9757600080fd5b50610392610ba63660046155de565b612505565b348015610bb757600080fd5b5060185461042b906001600160a01b031681565b348015610bd757600080fd5b50610392610be636600461543e565b612524565b348015610bf757600080fd5b506028546103b490600160a01b900460ff1681565b348015610c1857600080fd5b50600f546104a0565b348015610c2d57600080fd5b5060195461042b906001600160a01b031681565b348015610c4d57600080fd5b50610392610c5c366004615601565b612540565b348015610c6d57600080fd5b506103b4610c7c366004615622565b6001600160a01b03918216600090815260076020908152604080832093909416825291909152205460ff1690565b348015610cb657600080fd5b50610392610cc53660046151f2565b61257a565b348015610cd657600080fd5b50610392610ce53660046151f2565b6125a5565b610cf261261b565b806001600160401b03811115610d0a57610d0a615330565b604051908082528060200260200182016040528015610d3d57816020015b6060815260200190600190039081610d285790505b508051610d5291602491602090910190614f47565b5060005b81811015610dbf57828282818110610d7057610d70615650565b9050602002810190610d829190615666565b60248381548110610d9557610d95615650565b906000526020600020019182610dac92919061573b565b5080610db78161580a565b915050610d56565b50610dc861267a565b5050565b6000610dd78261268c565b92915050565b600080516020615de7833981519152610df5816126c4565b610dff83836126ce565b505050565b6060601b8054610e13906156ac565b80601f0160208091040260200160405190810160405280929190818152602001828054610e3f906156ac565b8015610e8c5780601f10610e6157610100808354040283529160200191610e8c565b820191906000526020600020905b815481529060010190602001808311610e6f57829003601f168201915b5050505050905090565b6000610ea1826127c7565b610ebe576040516333d1c03960e21b815260040160405180910390fd5b506000908152600660205260409020546001600160a01b031690565b610ee261261b565b601980546001600160a01b0319166001600160a01b038316179055610f0561267a565b50565b6000610f1382611897565b9050336001600160a01b03821614610f4c57610f2f8133610c7c565b610f4c576040516367d9dca160e11b815260040160405180910390fd5b60008281526006602052604080822080546001600160a01b0319166001600160a01b0387811691821790925591518593918516917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591a4505050565b610fb061261b565b600160fa1b8214158015610fc85750600160fb1b8214155b8015610fd85750600160fc1b8214155b15610ff657604051631258e44360e01b815260040160405180910390fd5b808255610dc861267a565b61100961261b565b601480546001600160a01b0319166001600160a01b0392909216919091179055565b6000611036826127ee565b9050836001600160a01b0316816001600160a01b0316146110695760405162a1148160e81b815260040160405180910390fd5b60008281526006602052604090208054338082146001600160a01b038816909114176110b6576110998633610c7c565b6110b657604051632ce44b5f60e11b815260040160405180910390fd5b6001600160a01b0385166110dd57604051633a954ecd60e21b815260040160405180910390fd5b6110ea8686866001612855565b80156110f557600082555b6001600160a01b0386811660009081526005602052604080822080546000190190559187168152208054600101905561113285600160e11b6128a5565b600085815260046020526040812091909155600160e11b84169003611187576001840160008181526004602052604081205490036111855760005481146111855760008181526004602052604090208490555b505b83856001600160a01b0316876001600160a01b0316600080516020615e4783398151915260405160405180910390a45b505050505050565b60009081526009602052604090206001015490565b6000828152600d602090815260408083208151808301909252546001600160a01b038116808352600160a01b9091046001600160601b0316928201929092528291611249575060408051808201909152600c546001600160a01b0381168252600160a01b90046001600160601b031660208201525b602081015160009061271090611268906001600160601b031687615823565b6112729190615850565b91519350909150505b9250929050565b61128a61261b565b6026819055610f0561267a565b61129f61261b565b6112a98180615666565b601d916112b791908361573b565b506112c56020820182615666565b601e916112d391908361573b565b506112e16040820182615666565b601f916112ef91908361573b565b50610f0561267a565b61130061261b565b6028805460ff60a01b1916600160a01b17905561131b61267a565b565b61134160405180606001604052806060815260200160608152602001606081525090565b601d805461134e906156ac565b80601f016020809104026020016040519081016040528092919081815260200182805461137a906156ac565b80156113c75780601f1061139c576101008083540402835291602001916113c7565b820191906000526020600020905b8154815290600101906020018083116113aa57829003601f168201915b5050509183525050601e80546113dc906156ac565b80601f0160208091040260200160405190810160405280929190818152602001828054611408906156ac565b80156114555780601f1061142a57610100808354040283529160200191611455565b820191906000526020600020905b81548152906001019060200180831161143857829003601f168201915b50505050508160200181905250601f805461146f906156ac565b80601f016020809104026020016040519081016040528092919081815260200182805461149b906156ac565b80156114e85780601f106114bd576101008083540402835291602001916114e8565b820191906000526020600020905b8154815290600101906020018083116114cb57829003601f168201915b5050505050816040018190525090565b61150061261b565b80606001516001600160f81b0316816000015110156115655760405162461bcd60e51b815260206004820152601c60248201527b53656c6c65723a2065786365737369766520667265652071756f746160201b60448201526064015b60405180910390fd5b601554815110156115b85760405162461bcd60e51b815260206004820181905260248201527f53656c6c65723a20696e76656e746f7279203c20616c726561647920736f6c64604482015260640161155c565b60175481606001516001600160f81b031610156116215760405162461bcd60e51b815260206004820152602160248201527f53656c6c65723a20667265652071756f7461203c20616c7265616479207573656044820152601960fa1b606482015260840161155c565b601354610100900460ff161561163e57600160c0820152600f5481525b60135460ff161561166257600160a08201526012546001600160f81b031660608201525b8051600f5560208101516010556040810151601155606081015160808201511515600160f81b026001600160f81b039091161760125560a08101516013805460c09093015115156101000261ff00199215159290921661ffff1990931692909217179055565b6116d1826111bf565b6116da816126c4565b610dff83836128ba565b6116ec61261b565b601a80546001600160a01b0319166001600160a01b038316179055610f0561267a565b6001600160a01b038116331461177f5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b606482015260840161155c565b610dc882826128dc565b61179161261b565b6025805461ff00191661010017905561131b61267a565b60006117b48284615823565b9392505050565b600080516020615de78339815191526117d3816126c4565b610f056128fe565b60215460ff166117fe5760405163951b974f60e01b815260040160405180910390fd5b610dc8828260205461294a565b610dff83838360405180602001604052806000815250611ba3565b61182e61261b565b601880546001600160a01b0319166001600160a01b038316179055610f0561267a565b61185961261b565b6025805461ff001916905561131b61267a565b61187461261b565b602880546001600160a01b0319166001600160a01b038316179055610f0561267a565b6000610dd7826127ee565b6118aa61261b565b6021805460ff19169055565b60006001600160a01b0382166118df576040516323d3ad8160e21b815260040160405180910390fd5b506001600160a01b03166000908152600560205260409020546001600160401b031690565b61190c61261b565b61131b6000612de2565b601d8054611923906156ac565b80601f016020809104026020016040519081016040528092919081815260200182805461194f906156ac565b801561199c5780601f106119715761010080835404028352916020019161199c565b820191906000526020600020905b81548152906001019060200180831161197f57829003601f168201915b505050505081565b601f8054611923906156ac565b6000600160fa1b82141580156119cb5750600160fb1b8214155b80156119db5750600160fc1b8214155b156119f957604051631258e44360e01b815260040160405180910390fd5b505490565b600080516020615de7833981519152611a16816126c4565b610f056000611a286001546000540390565b612e34565b600080516020615de7833981519152611a45816126c4565b610f05612e71565b611a5561261b565b610dbf60238383614f9d565b600f54600090611a746001546000540390565b14905090565b6008546001600160a01b031690565b601e8054611923906156ac565b6000828152600a602052604081206117b49083612eae565b6000611ab960155490565b905090565b611ac661261b565b602055565b60009182526009602090815260408084206001600160a01b0393909316845291905290205460ff1690565b6060601c8054610e13906156ac565b3360008181526007602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b611b7961261b565b6028805460ff60a01b1916905561131b61267a565b611b9661261b565b601c610dbf82848361573b565b611bae84848461102b565b6001600160a01b0383163b15611be757611bca84848484612eba565b611be7576040516368d2bf6b60e11b815260040160405180910390fd5b50505050565b611bf561261b565b6021805460ff19166001179055565b611c0c61261b565b611c14612fa6565b6012546001600160f81b0316611c3c82611c2d60175490565b611c379084615864565b612fec565b915060008211611c8c5760405162461bcd60e51b815260206004820152601b60248201527a14d95b1b195c8e88119c9959481c5d5bdd1848195e18d959591959602a1b604482015260640161155c565b600f54611c9c83611c2d60155490565b925060008311611cbe5760405162461bcd60e51b815260040161155c90615877565b611cc9601584613002565b611cd4601784613002565b611ce08484600161301f565b80611cea60155490565b1115611cf857611cf86158a1565b81611d0260175490565b1115611be757611be76158a1565b611d1861261b565b601b610dbf82848361573b565b606081611d31816127c7565b611d885760405162461bcd60e51b815260206004820152602260248201527f45524337323141436f6d6d6f6e3a20546f6b656e20646f65736e2774206578696044820152611cdd60f21b606482015260840161155c565b6019546001600160a01b031615611e115760195460405163c87b56dd60e01b8152600481018590526001600160a01b039091169063c87b56dd90602401600060405180830381865afa158015611de2573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611e0a91908101906158e7565b91506124bd565b60008381526022602090815260408083205481519283018190529291611e5c910160408051601f19818403018152828252805160209182012083830190925290825260809082015290565b600f5490915060006064611e71836019615823565b611e7b9190615850565b90506000611e91818484876000604060006130b6565b9050611ea5818484876001603860006130b6565b9050611eb9818484876002603060016130b6565b9050611ecd818484876003602860016130b6565b9050611ee1818484876004602060016130b6565b9050611ef5818484876005601060016130b6565b9050611f09818484876006600860016130b6565b9050611f1d818484876007600060016130b6565b6029546040805160e0810182526001600160481b0384168152602554610100900460ff1615156020808301919091526023805484518184028101840186528181529697506000966001600160a01b0390961695635bd320e99585019390929190830182828015611fac57602002820191906000526020600020905b815481526020019060010190808311611f98575b505050505081526020018c8152602001611fc9600160fa1b6119b1565b8152602001611fdb600160fb1b6119b1565b8152602001611fed600160fc1b6119b1565b8152506040518263ffffffff1660e01b815260040161200c919061592f565b600060405180830381865afa158015612029573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261205191908101906158e7565b6025549091506000906120929061206c9060ff1660366159cc565b60255463ffffffff91909116906120879060ff1660366159cc565b63ffffffff16613155565b9150600090506120d860036120a88460366159f4565b6120b39060026159f4565b6120be906004615823565b6120c89190615850565b6120d39060166159f4565b6131b3565b905061211b6040518060400160405280601681526020017519185d184e9a5b5859d94bd89b5c0ed8985cd94d8d0b60521b815250826131d090919063ffffffff16565b602854600160a01b900460ff1680612138575060255460ff166001145b1561215b5761215661214c846036806131e5565b829060008061322b565b6121a8565b60255461218a9061214c906121749060ff1660366159cc565b6025546121859060ff1660366159cc565b613337565b6121a8816121978561345f565b60255460369060049060ff166135b1565b60006040518060c001604052808381526020016121c4876136d7565b81526020018d6026546121d791906159f4565b8152602001601d80546121e9906156ac565b80601f0160208091040260200160405190810160405280929190818152602001828054612215906156ac565b80156122625780601f1061223757610100808354040283529160200191612262565b820191906000526020600020905b81548152906001019060200180831161224557829003601f168201915b50505050508152602001601e8054612279906156ac565b80601f01602080910402602001604051908101604052809291908181526020018280546122a5906156ac565b80156122f25780601f106122c7576101008083540402835291602001916122f2565b820191906000526020600020905b8154815290600101906020018083116122d557829003601f168201915b50505050508152602001601f8054612309906156ac565b80601f0160208091040260200160405190810160405280929190818152602001828054612335906156ac565b80156123825780601f1061235757610100808354040283529160200191612382565b820191906000526020600020905b81548152906001019060200180831161236557829003601f168201915b5050509190925250506018546028549192506001600160a01b031690600160a01b900460ff161561243e5760285460405163284e491b60e11b81526001600160a01b038381169263509c9236926123f292879290811691600160a81b90910460ff16906036908190600401615aa3565b600060405180830381865afa15801561240f573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261243791908101906158e7565b9b506124b2565b60405163e76d9fb360e01b81526001600160a01b0382169063e76d9fb39061246a908590600401615b08565b600060405180830381865afa158015612487573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526124af91908101906158e7565b9b505b505050505050505050505b50919050565b6000818152600a60205260408120610dd790613fb5565b6124e261261b565b602780546001600160a01b0319166001600160a01b038316179055610f0561267a565b61250d61261b565b6025805460ff191660ff8316179055610f0561267a565b61252d826111bf565b612536816126c4565b610dff83836128dc565b61254861261b565b6028805482919060ff60a81b1916600160a81b83600381111561256d5761256d615a8d565b0217905550610f0561267a565b61258261261b565b602980546001600160a01b0319166001600160a01b038316179055610f0561267a565b6125ad61261b565b6001600160a01b0381166126125760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161155c565b610f0581612de2565b33612624611a7a565b6001600160a01b03161461131b5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161155c565b61131b6000611a286001546000540390565b600061269782613fbf565b806126a657506126a68261400d565b806126b557506126b58261402e565b80610dd75750610dd782614039565b610f05813361405e565b6127106001600160601b038216111561273c5760405162461bcd60e51b815260206004820152602a60248201527f455243323938313a20726f79616c7479206665652077696c6c206578636565646044820152692073616c65507269636560b01b606482015260840161155c565b6001600160a01b03821661278e5760405162461bcd60e51b815260206004820152601960248201527822a921991c9c189d1034b73b30b634b2103932b1b2b4bb32b960391b604482015260640161155c565b604080518082019091526001600160a01b039092168083526001600160601b039091166020909201829052600160a01b90910217600c55565b6000805482108015610dd7575050600090815260046020526040902054600160e01b161590565b60008160005481101561283c5760008181526004602052604081205490600160e01b8216900361283a575b806000036117b4575060001901600081815260046020526040902054612819565b505b604051636f96cda160e11b815260040160405180910390fd5b600b5460ff16156128a05760405162461bcd60e51b8152602060048201526015602482015274115490cdcc8c5050dbdb5b5bdb8e881c185d5cd959605a1b604482015260640161155c565b611be7565b4260a01b176001600160a01b03919091161790565b6128c4828261409c565b6000828152600a60205260409020610dff9082614122565b6128e68282614137565b6000828152600a60205260409020610dff908261419e565b6129066141b3565b600b805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b60405161294091906151de565b60405180910390a1565b6002600e540361299c5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015260640161155c565b6002600e556129a9612fa6565b6040805160e081018252600f54815260105460208201526011549181018290526012546001600160f81b038116606083015260ff600160f81b909104811615156080830152601354808216151560a0840152610100900416151560c08201529060009015612a2457612a1f848360400151612fec565b612a26565b835b9050600080836080015115612a6e5760608401518451612a4f916001600160f81b031690615864565b9150612a5a60175490565b601554612a679190615864565b9050612a7e565b83519150612a7b60155490565b90505b612a8c83611c378385615864565b925060008311612aae5760405162461bcd60e51b815260040161155c90615877565b602084015115612c0a57336001600160a01b038816811415906000903214801590612ae25750326001600160a01b038a1614155b9050612b12858a6040518060400160405280600b81526020016a109d5e595c881b1a5b5a5d60aa1b8152506141fc565b94508115612b4c57612b4985336040518060400160405280600c81526020016b14d95b99195c881b1a5b5a5d60a21b8152506141fc565b94505b8015612b8457612b8185326040518060400160405280600c81526020016b13dc9a59da5b881b1a5b5a5d60a21b8152506141fc565b94505b6001600160a01b03891660009081526016602052604081208054879290612bac9084906159f4565b90915550508115612bdc573360009081526016602052604081208054879290612bd69084906159f4565b90915550505b8015612c07573260009081526016602052604081208054879290612c019084906159f4565b90915550505b50505b6000612c1684876117a8565b905080341015612c6c57612c36612c31633b9aca0083615850565b614251565b604051602001612c469190615b1b565b60408051601f198184030181529082905262461bcd60e51b825261155c916004016151b2565b612c77601585613002565b84516015541115612c8a57612c8a6158a1565b612c968885600061301f565b8015612cfb57601454612cb2906001600160a01b031682614351565b60145460408051868152602081018490526001600160a01b03909216917f01f51b99bd1c3cca301836178e5dee13aadfe44eff06dc3ddcbf3c9d058454f8910160405180910390a25b80341115612dd357336000612d108334615864565b9050600080836001600160a01b03168360405160006040518083038185875af1925050503d8060008114612d60576040519150601f19603f3d011682016040523d82523d6000602084013e612d65565b606091505b5091509150818190612d8a5760405162461bcd60e51b815260040161155c91906151b2565b50836001600160a01b03167fbb28353e4598c3b9199101a66e0989549b659a59a54d2c27fbb183f1932c8e6d84604051612dc691815260200190565b60405180910390a2505050505b50506001600e55505050505050565b600880546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60408051838152602081018390527f6bd5c950a8d8df17f772f5af37cb3655737899cbf903264b9795592da439661c910160405180910390a15050565b612e79612fa6565b600b805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586129333390565b60006117b48383614467565b604051630a85bd0160e11b81526000906001600160a01b0385169063150b7a0290612eef903390899088908890600401615b60565b6020604051808303816000875af1925050508015612f2a575060408051601f3d908101601f19168201909252612f2791810190615b9d565b60015b612f88573d808015612f58576040519150601f19603f3d011682016040523d82523d6000602084013e612f5d565b606091505b508051600003612f80576040516368d2bf6b60e11b815260040160405180910390fd5b805181602001fd5b6001600160e01b031916630a85bd0160e11b1490505b949350505050565b600b5460ff161561131b5760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015260640161155c565b6000818310612ffb57816117b4565b5090919050565b8082600001600082825461301691906159f4565b90915550505050565b600080549061302e84836159f4565b905061303a8585614491565b808210156130af576040516001600160601b031930606090811b8216602084015241901b1660348201524360488201524460688201526088810183905260a80160408051601f198184030181529181528151602092830120600085815260229093529120556130a88261580a565b915061303a565b5050505050565b600080602385815481106130cc576130cc615650565b9060005260206000200154905060006130e5878a6144ab565b9050831561312357846001600160481b031688821061310d576131088383615bba565b61310f565b825b6001600160481b0316901b8a179950613147565b6001600160481b0385166131378383615bba565b6001600160481b0316901b8a1799505b509798975050505050505050565b60008080613164856003615823565b905060006004613178600319841684615864565b613183906004615864565b61318d9190615bba565b9050600061319b82846159f4565b6131a59087615823565b919791965090945050505050565b604080518281016060018252910181526000602090910190815290565b6131db8282516144c0565b610dc88282614545565b606060006131ff8463ffffffff168463ffffffff16613155565b9150600090506132136120d38360366159f4565b90506132218187878761457b565b5095945050505050565b8251600081900361323c5750611be7565b60036002828101829004901b908206831561325e576001811481151501820391505b61326887836144c0565b6040517f4142434445464748494a4b4c4d4e4f505152535455565758595a616263646566601f526102308615027f6768696a6b6c6d6e6f707172737475767778797a303132333435363738392d5f03603f52875160208901018488015b6003890198508851603f8160121c16518353603f81600c1c16516001840153603f8160061c16516002840153603f8116516003840153506004820191508089106132c557508561332457603d831515820353603d6001841460011b8203535b5087519092018752506040525050505050565b606060006133518463ffffffff168463ffffffff16613155565b6040805160368082526060820190925291935060009250602082018180368337019050509050604260f81b8160008151811061338f5761338f615650565b60200101906001600160f81b031916908160001a905350604d60f81b816001815181106133be576133be615650565b60200101906001600160f81b031916908160001a90535060006133e2836036615bce565b90506133f082600283614607565b6133fd82600a6036614607565b61340a82600e6028614607565b61341682601288614607565b61342282601687614607565b61342f82601a60016146ff565b61343c82601c60186146ff565b6134498260266001614607565b61345682602a6001614607565b50949350505050565b6060815160000361347e57505060408051602081019091526000815290565b6000604051806060016040528060408152602001615e0760409139905060006003845160026134ad91906159f4565b6134b79190615850565b6134c2906004615823565b6001600160401b038111156134d9576134d9615330565b6040519080825280601f01601f191660200182016040528015613503576020820181803683370190505b509050600182016020820185865187015b8082101561356f576003820191508151603f8160121c168501518453600184019350603f81600c1c168501518453600184019350603f8160061c168501518453600184019350603f8116850151845350600183019250613514565b505060038651066001811461358b576002811461359e576135a6565b603d6001830353603d60028303536135a6565b603d60018303535b509195945050505050565b6135d3818286516135c29190615823565b6135cc9190615823565b86906144c0565b613620565b83820281015b8082101561361657816020858201035b81811061360157878252908801906135ee565b508051891689198816179052908201906135de565b5050505050505050565b60208401845181016020860182038486028586602004028587028a5160208c01018784026000198a60031b1c1960001985850660031b1c5b888a10156136bb576000828b5116600060088f025b89821015613686579282179291821c91908f019061366d565b5050506136988288838f8a898b6135d8565b50988b0198968b0196928401928688066136b6578a87840302840193505b613658565b5050505050505050505080810284510285510185525050505050565b601a546060906001600160a01b03161561376457601a54604051636f05967b60e01b81526001600160481b03841660048201526001600160a01b0390911690636f05967b90602401600060405180830381865afa15801561373c573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610dd791908101906158e7565b61376f6103e86131b3565b90506137aa6040518060400160405280600e81526020016d2261747472696275746573223a5b60901b8152508261454590919063ffffffff16565b602554600090610100900460ff1615613f46576138ed8260246000815481106137d5576137d5615650565b9060005260206000200180546137ea906156ac565b80601f0160208091040260200160405190810160405280929190818152602001828054613816906156ac565b80156138635780601f1061383857610100808354040283529160200191613863565b820191906000526020600020905b81548152906001019060200180831161384657829003601f168201915b50506027546040805163079be49360e01b81526001600160a01b03909216945063079be49393506138a29250600091908b901c60ff1690600401615beb565b600060405180830381865afa1580156138bf573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526138e791908101906158e7565b84614747565b90506139d482602460018154811061390757613907615650565b90600052602060002001805461391c906156ac565b80601f0160208091040260200160405190810160405280929190818152602001828054613948906156ac565b80156139955780601f1061396a57610100808354040283529160200191613995565b820191906000526020600020905b81548152906001019060200180831161397857829003601f168201915b505060275460405163079be49360e01b81526001600160a01b03909116935063079be49392506138a2915060019060ff60388c901c1690600401615beb565b9050613abb8260246002815481106139ee576139ee615650565b906000526020600020018054613a03906156ac565b80601f0160208091040260200160405190810160405280929190818152602001828054613a2f906156ac565b8015613a7c5780601f10613a5157610100808354040283529160200191613a7c565b820191906000526020600020905b815481529060010190602001808311613a5f57829003601f168201915b505060275460405163079be49360e01b81526001600160a01b03909116935063079be49392506138a2915060029060ff60308c901c1690600401615beb565b9050613ba2826024600381548110613ad557613ad5615650565b906000526020600020018054613aea906156ac565b80601f0160208091040260200160405190810160405280929190818152602001828054613b16906156ac565b8015613b635780601f10613b3857610100808354040283529160200191613b63565b820191906000526020600020905b815481529060010190602001808311613b4657829003601f168201915b505060275460405163079be49360e01b81526001600160a01b03909116935063079be49392506138a2915060039060ff60288c901c1690600401615beb565b9050613c88826024600481548110613bbc57613bbc615650565b906000526020600020018054613bd1906156ac565b80601f0160208091040260200160405190810160405280929190818152602001828054613bfd906156ac565b8015613c4a5780601f10613c1f57610100808354040283529160200191613c4a565b820191906000526020600020905b815481529060010190602001808311613c2d57829003601f168201915b505060275460405163079be49360e01b81526001600160a01b03909116935063079be49392506138a2915060049060ff60208c901c16908201615beb565b9050613d75826024600581548110613ca257613ca2615650565b906000526020600020018054613cb7906156ac565b80601f0160208091040260200160405190810160405280929190818152602001828054613ce3906156ac565b8015613d305780601f10613d0557610100808354040283529160200191613d30565b820191906000526020600020905b815481529060010190602001808311613d1357829003601f168201915b505060275460405163079be49360e01b81526005600482015260108b901c61ffff1660248201526001600160a01b03909116935063079be493925060440190506138a2565b9050613e5c826024600681548110613d8f57613d8f615650565b906000526020600020018054613da4906156ac565b80601f0160208091040260200160405190810160405280929190818152602001828054613dd0906156ac565b8015613e1d5780601f10613df257610100808354040283529160200191613e1d565b820191906000526020600020905b815481529060010190602001808311613e0057829003601f168201915b505060275460405163079be49360e01b81526001600160a01b03909116935063079be49392506138a2915060069060ff60088c901c1690600401615beb565b9050613f3f826024600781548110613e7657613e76615650565b906000526020600020018054613e8b906156ac565b80601f0160208091040260200160405190810160405280929190818152602001828054613eb7906156ac565b8015613f045780601f10613ed957610100808354040283529160200191613f04565b820191906000526020600020905b815481529060010190602001808311613ee757829003601f168201915b505060275460405163079be49360e01b81526001600160a01b03909116935063079be49392506138a2915060079060ff8b1690600401615beb565b9050613f92565b613f8f82604051806040016040528060088152602001671c995d99585b195960c21b8152506040518060400160405280600581526020016466616c736560d81b81525084614747565b90505b6040805180820190915260018152605d60f81b60208201526124bd908390614545565b6000610dd7825490565b60006301ffc9a760e01b6001600160e01b031983161480613ff057506380ac58cd60e01b6001600160e01b03198316145b80610dd75750506001600160e01b031916635b5e139f60e01b1490565b60006001600160e01b0319821663152a902d60e11b1480610dd75750610dd7825b6000610dd782614841565b60006001600160e01b03198216632483248360e11b1480610dd75750610dd782614866565b6140688282611acb565b610dc857614080816001600160a01b0316601461487c565b61408b83602061487c565b604051602001612c46929190615bfc565b6140a68282611acb565b610dc85760008281526009602090815260408083206001600160a01b03851684529091529020805460ff191660011790556140de3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b60006117b4836001600160a01b038416614a17565b6141418282611acb565b15610dc85760008281526009602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b60006117b4836001600160a01b038416614a66565b600b5460ff1661131b5760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604482015260640161155c565b6001600160a01b038216600090815260166020526040812054601054829161422391615864565b90508060000361423e5782604051602001612c469190615c6b565b6142488582612fec565b95945050505050565b6060816000036142785750506040805180820190915260018152600360fc1b602082015290565b8160005b81156142a2578061428c8161580a565b915061429b9050600a83615850565b915061427c565b6000816001600160401b038111156142bc576142bc615330565b6040519080825280601f01601f1916602001820160405280156142e6576020820181803683370190505b5090505b8415612f9e576142fb600183615864565b9150614308600a86615bba565b6143139060306159f4565b60f81b81838151811061432857614328615650565b60200101906001600160f81b031916908160001a90535061434a600a86615850565b94506142ea565b804710156143a15760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e6365000000604482015260640161155c565b6000826001600160a01b03168260405160006040518083038185875af1925050503d80600081146143ee576040519150601f19603f3d011682016040523d82523d6000602084013e6143f3565b606091505b5050905080610dff5760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c20726044820152791958da5c1a595b9d081b585e481a185d99481c995d995c9d195960321b606482015260840161155c565b600082600001828154811061447e5761447e615650565b9060005260206000200154905092915050565b610dc8828260405180602001604052806000815250614b60565b60006117b483836144bb85614bc6565b614bdc565b60006144d283601f190151603f190190565b905060008284516144e391906159f4565b905080821015611be75760405162461bcd60e51b815260206004820152602760248201527f44796e616d69634275666665723a20417070656e64696e67206f7574206f66206044820152663137bab732399760c91b606482015260840161155c565b8051602082019150808201602084510184015b81841015614570578351815260209384019301614558565b505082510190915250565b825160609061458a83856159cc565b6145959060036159cc565b63ffffffff16146145de576145aa82846159cc565b6145b59060036159cc565b8451604051635fae4ac560e11b815263ffffffff9092166004830152602482015260440161155c565b6145f26145eb8484613337565b86906131d0565b6145fe85858585614bfa565b50929392505050565b8060f81b83838151811061461d5761461d615650565b60200101906001600160f81b031916908160001a9053506001600160f81b031960f082901b168361464f8460016159f4565b8151811061465f5761465f615650565b60200101906001600160f81b031916908160001a9053506001600160f81b031960e882901b16836146918460026159f4565b815181106146a1576146a1615650565b60200101906001600160f81b031916908160001a9053506001600160f81b031960e082901b16836146d38460036159f4565b815181106146e3576146e3615650565b60200101906001600160f81b031916908160001a905350505050565b8060f81b83838151811061471557614715615650565b60200101906001600160f81b031916908160001a9053506001600160f81b031960f082901b16836146d38460016159f4565b815160009015614839578161475b81615c9b565b9250506147a360018360ff1611614781576040518060200160405280600081525061479c565b604051806040016040528060018152602001600b60fa1b8152505b8690614545565b60408051808201909152600f81526e3d913a3930b4ba2fba3cb832911d1160891b60208201526147d4908690614545565b6147de8585614545565b60408051808201909152600b81526a1116113b30b63ab2911d1160a91b602082015261480b908690614545565b6148158584614545565b604080518082019091526002815261227d60f01b6020820152614839908690614545565b509392505050565b60006001600160e01b03198216635a05180f60e01b1480610dd75750610dd782614c2c565b6001600160e01b0319166301ffc9a760e01b1490565b6060600061488b836002615823565b6148969060026159f4565b6001600160401b038111156148ad576148ad615330565b6040519080825280601f01601f1916602001820160405280156148d7576020820181803683370190505b509050600360fc1b816000815181106148f2576148f2615650565b60200101906001600160f81b031916908160001a905350600f60fb1b8160018151811061492157614921615650565b60200101906001600160f81b031916908160001a9053506000614945846002615823565b6149509060016159f4565b90505b60018111156149c8576f181899199a1a9b1b9c1cb0b131b232b360811b85600f166010811061498457614984615650565b1a60f81b82828151811061499a5761499a615650565b60200101906001600160f81b031916908160001a90535060049490941c936149c181615cba565b9050614953565b5083156117b45760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e74604482015260640161155c565b6000818152600183016020526040812054614a5e57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610dd7565b506000610dd7565b60008181526001830160205260408120548015614b4f576000614a8a600183615864565b8554909150600090614a9e90600190615864565b9050818114614b03576000866000018281548110614abe57614abe615650565b9060005260206000200154905080876000018481548110614ae157614ae1615650565b6000918252602080832090910192909255918252600188019052604090208390555b8554869080614b1457614b14615cd1565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610dd7565b6000915050610dd7565b5092915050565b614b6a8383614c51565b6001600160a01b0383163b15610dff576000548281035b614b946000868380600101945086612eba565b614bb1576040516368d2bf6b60e11b815260040160405180910390fd5b818110614b815781600054146130af57600080fd5b6000815b80156124bd576001918201911c614bca565b815b8281106117b457614bf3848361ffff16614d46565b9050614bde565b6000614c128363ffffffff168363ffffffff16613155565b9150614c20905085826144c0565b6130af85858585614e08565b60006001600160e01b03198216637965db0b60e01b1480610dd75750610dd782614866565b6000805490829003614c765760405163b562e8dd60e01b815260040160405180910390fd5b614c836000848385612855565b6001600160a01b038316600090815260056020526040902080546001600160401b018402019055614cba836001841460e11b6128a5565b6000828152600460205260408120919091556001600160a01b038416908383019083908390600080516020615e478339815191528180a4600183015b818114614d1c5780836000600080516020615e47833981519152600080a4600101614cf6565b5081600003614d3d57604051622e076360e81b815260040160405180910390fd5b60005550505050565b60006080821115614d8e5760405162461bcd60e51b815260206004820152601260248201527150524e473a206d617820313238206269747360701b604482015260640161155c565b602083015182811115614dad57614da58484614f28565b915050610dd7565b6000614db98285615864565b9050614dc58583614f28565b811b9250614df38580516128a8600160801b036001600160801b03821602608091821c018252602090910152565b614dfd8582614f28565b909217949350505050565b60006020614e178460036159cc565b614e219190615ce7565b63ffffffff16905060006020614e388560036159cc565b614e429190615d0a565b63ffffffff16905080600003614e6457614e5d600183615864565b9150602090505b6000614e7c8563ffffffff168563ffffffff16613155565b50905060006001614e8e846020615864565b614e99906008615823565b6001901b614ea79190615864565b90506000614eb782600019615864565b9050885160208a0101600060208a015b88821015614f125760005b88811015614ef0578151845260209384019390910190600101614ed2565b5082518151851690861617835285870190920191600191909101908601614ec7565b505060208a0181038a5250505050505050505050565b8151602090920180518281039091526101009081039290921b91031c90565b828054828255906000526020600020908101928215614f8d579160200282015b82811115614f8d5782518290614f7d9082615d2d565b5091602001919060010190614f67565b50614f99929150614fe4565b5090565b828054828255906000526020600020908101928215614fd8579160200282015b82811115614fd8578235825591602001919060010190614fbd565b50614f99929150615001565b80821115614f99576000614ff88282615016565b50600101614fe4565b5b80821115614f995760008155600101615002565b508054615022906156ac565b6000825580601f10615032575050565b601f016020900490600052602060002090810190610f059190615001565b60008083601f84011261506257600080fd5b5081356001600160401b0381111561507957600080fd5b6020830191508360208260051b850101111561127b57600080fd5b600080602083850312156150a757600080fd5b82356001600160401b038111156150bd57600080fd5b6150c985828601615050565b90969095509350505050565b6001600160e01b031981168114610f0557600080fd5b6000602082840312156150fd57600080fd5b81356117b4816150d5565b6001600160a01b0381168114610f0557600080fd5b6000806040838503121561513057600080fd5b823561513b81615108565b915060208301356001600160601b038116811461515757600080fd5b809150509250929050565b60005b8381101561517d578181015183820152602001615165565b50506000910152565b6000815180845261519e816020860160208601615162565b601f01601f19169290920160200192915050565b6020815260006117b46020830184615186565b6000602082840312156151d757600080fd5b5035919050565b6001600160a01b0391909116815260200190565b60006020828403121561520457600080fd5b81356117b481615108565b6000806040838503121561522257600080fd5b823561522d81615108565b946020939093013593505050565b6000806040838503121561524e57600080fd5b50508035926020909101359150565b60008060006060848603121561527257600080fd5b833561527d81615108565b9250602084013561528d81615108565b929592945050506040919091013590565b6000602082840312156152b057600080fd5b81356001600160401b038111156152c657600080fd5b8201606081850312156117b457600080fd5b6020815260008251606060208401526152f46080840182615186565b90506020840151601f19808584030160408601526153128383615186565b92506040860151915080858403016060860152506142488282615186565b634e487b7160e01b600052604160045260246000fd5b60405160e081016001600160401b038111828210171561536857615368615330565b60405290565b604051601f8201601f191681016001600160401b038111828210171561539657615396615330565b604052919050565b803580151581146153ae57600080fd5b919050565b600060e082840312156153c557600080fd5b6153cd615346565b82358152602080840135908201526040808401359082015260608301356001600160f81b03811681146153ff57600080fd5b60608201526154106080840161539e565b608082015261542160a0840161539e565b60a082015261543260c0840161539e565b60c08201529392505050565b6000806040838503121561545157600080fd5b82359150602083013561515781615108565b6000806040838503121561547657600080fd5b823561548181615108565b915061548f6020840161539e565b90509250929050565b600080602083850312156154ab57600080fd5b82356001600160401b03808211156154c257600080fd5b818501915085601f8301126154d657600080fd5b8135818111156154e557600080fd5b8660208285010111156154f757600080fd5b60209290920196919550909350505050565b60006001600160401b0382111561552257615522615330565b50601f01601f191660200190565b6000806000806080858703121561554657600080fd5b843561555181615108565b9350602085013561556181615108565b92506040850135915060608501356001600160401b0381111561558357600080fd5b8501601f8101871361559457600080fd5b80356155a76155a282615509565b61536e565b8181528860208385010111156155bc57600080fd5b8160208401602083013760006020838301015280935050505092959194509250565b6000602082840312156155f057600080fd5b813560ff811681146117b457600080fd5b60006020828403121561561357600080fd5b8135600481106117b457600080fd5b6000806040838503121561563557600080fd5b823561564081615108565b9150602083013561515781615108565b634e487b7160e01b600052603260045260246000fd5b6000808335601e1984360301811261567d57600080fd5b8301803591506001600160401b0382111561569757600080fd5b60200191503681900382131561127b57600080fd5b600181811c908216806156c057607f821691505b6020821081036124bd57634e487b7160e01b600052602260045260246000fd5b601f821115610dff57600081815260208120601f850160051c810160208610156157075750805b601f850160051c820191505b818110156111b757828155600101615713565b600019600383901b1c191660019190911b1790565b6001600160401b0383111561575257615752615330565b6157668361576083546156ac565b836156e0565b6000601f84116001811461579457600085156157825750838201355b61578c8682615726565b8455506130af565b600083815260209020601f19861690835b828110156157c557868501358255602094850194600190920191016157a5565b50868210156157e25760001960f88860031b161c19848701351681555b505060018560011b0183555050505050565b634e487b7160e01b600052601160045260246000fd5b60006001820161581c5761581c6157f4565b5060010190565b8082028115828204841417610dd757610dd76157f4565b634e487b7160e01b600052601260045260246000fd5b60008261585f5761585f61583a565b500490565b81810381811115610dd757610dd76157f4565b60208082526010908201526f14d95b1b195c8e8814dbdb19081bdd5d60821b604082015260600190565b634e487b7160e01b600052600160045260246000fd5b60006158c56155a284615509565b90508281528383830111156158d957600080fd5b6117b4836020830184615162565b6000602082840312156158f957600080fd5b81516001600160401b0381111561590f57600080fd5b8201601f8101841361592057600080fd5b612f9e848251602084016158b7565b602080825282516001600160481b03168282015282810151151560408084019190915283015160e06060840152805161010084018190526000929182019083906101208601905b808310156159965783518252928401926001929092019190840190615976565b5060608701516080870152608087015160a087015260a087015160c087015260c087015160e08701528094505050505092915050565b63ffffffff8181168382160280821691908281146159ec576159ec6157f4565b505092915050565b80820180821115610dd757610dd76157f4565b6000815160c08452615a1c60c0850182615186565b905060208301518482036020860152615a358282615186565b9150506040830151604085015260608301518482036060860152615a598282615186565b91505060808301518482036080860152615a738282615186565b91505060a083015184820360a08601526142488282615186565b634e487b7160e01b600052602160045260246000fd5b60a081526000615ab660a0830188615a07565b6001600160a01b0387166020840152905060048510615ae557634e487b7160e01b600052602160045260246000fd5b604082019490945263ffffffff9283166060820152911660809091015292915050565b6020815260006117b46020830184615a07565b6d029b2b63632b91d1021b7b9ba39960951b815260008251615b4481600e850160208701615162565b64204757656960d81b600e939091019283015250601301919050565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090615b9390830184615186565b9695505050505050565b600060208284031215615baf57600080fd5b81516117b4816150d5565b600082615bc957615bc961583a565b500690565b63ffffffff818116838216019080821115614b5957614b596157f4565b91825260ff16602082015260400190565b76020b1b1b2b9b9a1b7b73a3937b61d1030b1b1b7bab73a1604d1b815260008351615c2e816017850160208801615162565b7001034b99036b4b9b9b4b733903937b6329607d1b6017918401918201528351615c5f816028840160208801615162565b01602801949350505050565b67029b2b63632b91d160c51b815260008251615c8e816008850160208701615162565b9190910160080192915050565b600060ff821660ff8103615cb157615cb16157f4565b60010192915050565b600081615cc957615cc96157f4565b506000190190565b634e487b7160e01b600052603160045260246000fd5b600063ffffffff80841680615cfe57615cfe61583a565b92169190910492915050565b600063ffffffff80841680615d2157615d2161583a565b92169190910692915050565b81516001600160401b03811115615d4657615d46615330565b615d5a81615d5484546156ac565b846156e0565b602080601f831160018114615d895760008415615d775750858301515b615d818582615726565b8655506111b7565b600085815260208120601f198616915b82811015615db857888601518255948401946001909101908401615d99565b5085821015615dd65787850151600019600388901b60f8161c191681555b5050505050600190811b0190555056fe1e4c11efbd6a865b1cba79eea33d1b33c1394d834190605ed6a14c71c480bf764142434445464748494a4b4c4d4e4f505152535455565758595a6162636465666768696a6b6c6d6e6f707172737475767778797a303132333435363738392b2fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa26469706673582212205e018b46853be74163c35225f358aeb057669f34bd1c2299b4fdc7dbdd30f8bd64736f6c63430008130033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000001af400000000000000000000000000000000000000000000000000000000000000640000000000000000000000000000000000000000000000000000000000000064000000000000000000000000617dfd0edaa02f2bc53caec96075450afc833bc3000000000000000000000000617dfd0edaa02f2bc53caec96075450afc833bc300000000000000000000000000000000000000000000000000000000000001f4000000000000000000000000000000000000000000000000000000000000001243727970746f4469636b6275747473205334000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000054344425334000000000000000000000000000000000000000000000000000000
-----Decoded View---------------
Arg [0] : name_ (string): CryptoDickbutts S4
Arg [1] : symbol_ (string): CDBS4
Arg [2] : maxSupply_ (uint256): 6900
Arg [3] : maxPerAddress_ (uint256): 100
Arg [4] : maxPerTransaction_ (uint256): 100
Arg [5] : salesRecipient_ (address): 0x617dFd0eDAA02f2BC53CAEc96075450AFc833BC3
Arg [6] : royaltyRecipient_ (address): 0x617dFd0eDAA02f2BC53CAEc96075450AFc833BC3
Arg [7] : royaltyBasisPoints_ (uint96): 500
-----Encoded View---------------
12 Constructor Arguments found :
Arg [0] : 0000000000000000000000000000000000000000000000000000000000000100
Arg [1] : 0000000000000000000000000000000000000000000000000000000000000140
Arg [2] : 0000000000000000000000000000000000000000000000000000000000001af4
Arg [3] : 0000000000000000000000000000000000000000000000000000000000000064
Arg [4] : 0000000000000000000000000000000000000000000000000000000000000064
Arg [5] : 000000000000000000000000617dfd0edaa02f2bc53caec96075450afc833bc3
Arg [6] : 000000000000000000000000617dfd0edaa02f2bc53caec96075450afc833bc3
Arg [7] : 00000000000000000000000000000000000000000000000000000000000001f4
Arg [8] : 0000000000000000000000000000000000000000000000000000000000000012
Arg [9] : 43727970746f4469636b62757474732053340000000000000000000000000000
Arg [10] : 0000000000000000000000000000000000000000000000000000000000000005
Arg [11] : 4344425334000000000000000000000000000000000000000000000000000000
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
A token is a representation of an on-chain or off-chain asset. The token page shows information such as price, total supply, holders, transfers and social links. Learn more about this page in our Knowledge Base.