Token The Saba Collection
Polygon Sponsored slots available. Book your slot here!
Overview
TokenID:
7
Transfers:
-
Contract:
[ Download CSV Export ]
# | Exchange | Pair | Price | 24H Volume | % Volume |
---|
Similar Match Source Code
Note: This contract matches the deployed ByteCode of the Source Code for Contract 0x1D1400C163F0cEc9aFc895814EB1aD6779c8909e
Contract Name:
ERC721Suika
Compiler Version
v0.8.4+commit.c7e474f2
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT /** MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMMMMWWWWWWWWWWWWWWWMMMMMMMMMMMMMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMWWNXXKKKKKKKXXXXKKKKKKXXNWWMMMMMMMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMMMMWNXKKKKXXNWWWWMMWWWWMWWWWNXXXKKKXNWMMMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMWNXKKKXNWMMMMMMMMMNOdxKWMMMMMMMMWNXKKKXNWMMMMMMMMMMMMMM MMMMMMMMMMMMMWXKKKNWMMMMMMMMMMMMNx:;;l0WMMMMMMMMMMMWNK0KXWMMMMMMMMMMMM MMMMMMMMMMMWXKKXWMMMMMMMMMMMMMMXd:;;;;cOWMMMMMMMMMMMMMWXKKXWMMMMMMMMMM MMMMMMMMMWNKKXWMMMMMMMMMMMMMMWKo;;col:;:kNMMMMMMMMMMMMMMWX0KNWMMMMMMMM MMMMMMMMWX0XWMMMMMMMMMMMMMMMWOl;;oKWXkc;:dXMMMMMMMMMMMMMMMWX0XWMMMMMMM MMMMMMMNKKNWMMMMMMMMMMMMMMMNkc;:dXMMMWOc;;oKWMMMMMMMMMMMMMMWNKKNMMMMMM MMMMMMNKKNMMMMMMMMMMMMMMMMNx:;:xNMMMMMW0l;;l0WMMMMMMMWMMMMMMMNKKNMMMMM MMMMMNKKNMMMMMMMMMMMMMMMMXd:;ckNMMMMMMMMKo:;cOWMMMMXkxkXWMMMMMNKKNMMMM MMMMWK0NMMMMMMMMMMMMMMMWKo;;l0WMMMMMMMMMMXx:;:xNMMW0lccxXMMMMMMN0KWMMM MMMMX0XWMMMMMMWWMMMMMMWOl;;oKWMMMMMMMMMMMMNkc;:dXMMNklcoKMMMMMMMX0XMMM MMMWKKNMMWK0OkkkkkkKWNkc;:dXMMMMMMMMMMMMMMMWOl;;oKWMXdcxNMMMMMMMNKKWMM MMMN0XWMMWNXX0OdlccdKOc;:xNMMMWXKKXNWNNNNWWMW0o;;l0WNkdKWMMMMMMMWX0NMM MMMX0XMMMMMMMMMN0dlcdOxoONMMMMW0xdddddodxk0KNWXd:;l0Kx0WMMMMMMMMMX0XMM MMMX0NMMMMMMMMMMWXxlcoOXWMMMMWKkolclodkKNNNNWWMNxcxOkKWMMMMMMMMMMX0XMM MMMX0XMMMMMMMMMMMMNklclkNMMWXklccodxdodKWMMMMMMMNKOkKWMMMMMMMMMMMX0XMM MMMN0XWMMMMMMMMMMMMNOoclxXN0occcdKX0xlco0WMMMMMMNOOXMMMMMMMMMMMMMX0NMM MMMWKKWMMMMMMMMMMMMMW0dccoxocccdKWMWNklclONMMMMXOONMMMMMMMMMMMMMWKKWMM MMMMX0XMMMMMMMMMMMMMMWKdcccccco0WMMMMNOoclkNWWKk0NMMMMMMMMMMMMMMX0XWMM MMMMWKKNMMMMMMMMMMMMMMMXxlcccckNMMMMMMW0oclxK0kKWMMMMMMMMMMMMMMNKKWMMM MMMMMN0KWMMMMMMMMMMMMMMMNklccoKWMMMMMMMWKdlcoxKWMMMMMMMMMMMMMMWK0NMMMM MMMMMMN0KWMMMMMMMMMMMMMMMNOod0KXWMMMMMMNK0xoxXWMMMMMMMMMMMMMMWK0NMMMMM MMMMMMMN0KNMMMMMMMMMMMMMMMWXKkll0WMMMMXdcoOKNMMMMMMMMMMMMMMMNK0NMMMMMM MMMMMMMMNK0XWMMMMMMMMMMMMMMMNd:;cOWMWKo:;c0WMMMMMMMMMMMMMMWX0KNMMMMMMM MMMMMMMMMWXKKNWMMMMMMMMMMMMMMXd:;cx0kl;;l0WMMMMMMMMMMMMMWNKKXWMMMMMMMM MMMMMMMMMMMWX0KNWMMMMMMMMMMMMMNkc;;::;:oKWMMMMMMMMMMMMWNK0XWMMMMMMMMMM MMMMMMMMMMMMMNXKKXNWMMMMMMMMMMMWOc;;;:dXMMMMMMMMMMMWNXKKXWMMMMMMMMMMMM MMMMMMMMMMMMMMMWNKKKXNWMMMMMMMMMW0l:ckNMMMMMMMMMWNXKKKNWMMMMMMMMMMMMMM MMMMMMMMMMMMMMMMMMWNXKKKXXNWWWMMMMX0KWMMMWWWNXXKKKXNWMMMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMMMMMMMWWNXXKKKKKXXXXXXXXXXKKKKXXNWWMMMMMMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMMMWWNNNNNNNNNNNNWWWMMMMMMMMMMMMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM ---------------------- [ WPSmartContracts.com ] ---------------------- [ Blockchain Made Easy ] | | ERC-721 NFT Token Marketplace | |---------------------------- | | Flavors | | > Suika v.3: Standard ERC-721 Token with Marketplace | Supports Payment with Tokens, and royalties | */ pragma solidity ^0.8.2; /** * @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); } /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (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 assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } /** * @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; } } /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @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 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; } } /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { require(operator != _msgSender(), "ERC721: approve to caller"); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint( address to, uint256 tokenId, bytes memory _data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} } /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); } /** * @dev This implements an optional extension of {ERC721} defined in the EIP that adds * enumerability of all the token ids in the contract as well as all token ids owned by each * account. */ abstract contract ERC721Enumerable is ERC721, IERC721Enumerable { // Mapping from owner to list of owned token IDs mapping(address => mapping(uint256 => uint256)) private _ownedTokens; // Mapping from token ID to index of the owner tokens list mapping(uint256 => uint256) private _ownedTokensIndex; // Array with all token ids, used for enumeration uint256[] private _allTokens; // Mapping from token id to position in the allTokens array mapping(uint256 => uint256) private _allTokensIndex; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) { return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) { require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds"); return _ownedTokens[owner][index]; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _allTokens.length; } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view virtual override returns (uint256) { require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds"); return _allTokens[index]; } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` cannot be the zero address. * - `to` cannot be the zero address. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual override { super._beforeTokenTransfer(from, to, tokenId); if (from == address(0)) { _addTokenToAllTokensEnumeration(tokenId); } else if (from != to) { _removeTokenFromOwnerEnumeration(from, tokenId); } if (to == address(0)) { _removeTokenFromAllTokensEnumeration(tokenId); } else if (to != from) { _addTokenToOwnerEnumeration(to, tokenId); } } /** * @dev Private function to add a token to this extension's ownership-tracking data structures. * @param to address representing the new owner of the given token ID * @param tokenId uint256 ID of the token to be added to the tokens list of the given address */ function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private { uint256 length = ERC721.balanceOf(to); _ownedTokens[to][length] = tokenId; _ownedTokensIndex[tokenId] = length; } /** * @dev Private function to add a token to this extension's token tracking data structures. * @param tokenId uint256 ID of the token to be added to the tokens list */ function _addTokenToAllTokensEnumeration(uint256 tokenId) private { _allTokensIndex[tokenId] = _allTokens.length; _allTokens.push(tokenId); } /** * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for * gas optimizations e.g. when performing a transfer operation (avoiding double writes). * This has O(1) time complexity, but alters the order of the _ownedTokens array. * @param from address representing the previous owner of the given token ID * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address */ function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private { // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = ERC721.balanceOf(from) - 1; uint256 tokenIndex = _ownedTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary if (tokenIndex != lastTokenIndex) { uint256 lastTokenId = _ownedTokens[from][lastTokenIndex]; _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index } // This also deletes the contents at the last position of the array delete _ownedTokensIndex[tokenId]; delete _ownedTokens[from][lastTokenIndex]; } /** * @dev Private function to remove a token from this extension's token tracking data structures. * This has O(1) time complexity, but alters the order of the _allTokens array. * @param tokenId uint256 ID of the token to be removed from the tokens list */ function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private { // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = _allTokens.length - 1; uint256 tokenIndex = _allTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding // an 'if' statement (like in _removeTokenFromOwnerEnumeration) uint256 lastTokenId = _allTokens[lastTokenIndex]; _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index // This also deletes the contents at the last position of the array delete _allTokensIndex[tokenId]; _allTokens.pop(); } } /** * @dev ERC721 token with storage based token URI management. */ abstract contract ERC721URIStorage is ERC721 { using Strings for uint256; // Optional mapping for token URIs mapping(uint256 => string) private _tokenURIs; /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721URIStorage: URI query for nonexistent token"); string memory _tokenURI = _tokenURIs[tokenId]; string memory base = _baseURI(); // If there is no base URI, return the token URI. if (bytes(base).length == 0) { return _tokenURI; } // If both are set, concatenate the baseURI and tokenURI (via abi.encodePacked). if (bytes(_tokenURI).length > 0) { return string(abi.encodePacked(base, _tokenURI)); } return super.tokenURI(tokenId); } /** * @dev Sets `_tokenURI` as the tokenURI of `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _setTokenURI(uint256 tokenId, string memory _tokenURI) internal virtual { require(_exists(tokenId), "ERC721URIStorage: URI set of nonexistent token"); _tokenURIs[tokenId] = _tokenURI; } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual override { super._burn(tokenId); if (bytes(_tokenURIs[tokenId]).length != 0) { delete _tokenURIs[tokenId]; } } } /** * @title ERC721 Burnable Token * @dev ERC721 Token that can be irreversibly burned (destroyed). */ abstract contract ERC721Burnable is Context, ERC721 { /** * @dev Burns `tokenId`. See {ERC721-_burn}. * * Requirements: * * - The caller must own `tokenId` or be an approved operator. */ function burn(uint256 tokenId) public virtual { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721Burnable: caller is not owner nor approved"); _burn(tokenId); } } /** * @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; } /** * @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); } /** * @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, _msgSender()); _; } /** * @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 override returns (bool) { return _roles[role].members[account]; } /** * @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 { 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 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. */ 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. */ 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 granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ 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. * * [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}. * ==== */ 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); } function _grantRole(bytes32 role, address account) private { if (!hasRole(role, account)) { _roles[role].members[account] = true; emit RoleGranted(role, account, _msgSender()); } } function _revokeRole(bytes32 role, address account) private { if (hasRole(role, account)) { _roles[role].members[account] = false; emit RoleRevoked(role, account, _msgSender()); } } } /** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. */ library EnumerableSet { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping(bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; 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; 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; assembly { result := store } return result; } } /** * @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 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 override returns (uint256) { return _roleMembers[role].length(); } /** * @dev Overload {grantRole} to track enumerable memberships */ function grantRole(bytes32 role, address account) public virtual override(AccessControl, IAccessControl) { super.grantRole(role, account); _roleMembers[role].add(account); } /** * @dev Overload {revokeRole} to track enumerable memberships */ function revokeRole(bytes32 role, address account) public virtual override(AccessControl, IAccessControl) { super.revokeRole(role, account); _roleMembers[role].remove(account); } /** * @dev Overload {renounceRole} to track enumerable memberships */ function renounceRole(bytes32 role, address account) public virtual override(AccessControl, IAccessControl) { super.renounceRole(role, account); _roleMembers[role].remove(account); } /** * @dev Overload {_setupRole} to track enumerable memberships */ function _setupRole(bytes32 role, address account) internal virtual override { super._setupRole(role, account); _roleMembers[role].add(account); } } /** * @title Counters * @author Matt Condon (@shrugs) * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number * of elements in a mapping, issuing ERC721 ids, or counting request ids. * * Include with `using Counters for Counters.Counter;` */ library Counters { struct Counter { // This variable should never be directly accessed by users of the library: interactions must be restricted to // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add // this feature: see https://github.com/ethereum/solidity/issues/4637 uint256 _value; // default: 0 } function current(Counter storage counter) internal view returns (uint256) { return counter._value; } function increment(Counter storage counter) internal { unchecked { counter._value += 1; } } function decrement(Counter storage counter) internal { uint256 value = counter._value; require(value > 0, "Counter: decrement overflow"); unchecked { counter._value = value - 1; } } function reset(Counter storage counter) internal { counter._value = 0; } } contract ERC721Mochi is ERC721, ERC721Enumerable, ERC721URIStorage, AccessControlEnumerable, ERC721Burnable { using Counters for Counters.Counter; bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE"); Counters.Counter private _tokenIdCounter; bool public anyoneCanMint; constructor(address owner, string memory name, string memory symbol, bool _anyoneCanMint) ERC721(name, symbol) { _setupRole(DEFAULT_ADMIN_ROLE, owner); _setupRole(MINTER_ROLE, owner); anyoneCanMint = _anyoneCanMint; } function autoMint(string memory _tokenURI, address to) public onlyMinter { uint id; do { _tokenIdCounter.increment(); id = _tokenIdCounter.current(); } while(_exists(id)); _mint(to, id); _setTokenURI(id, _tokenURI); } function mint(address to, uint256 tokenId) public onlyMinter { _mint(to, tokenId); } function safeMint(address to, uint256 tokenId) public onlyMinter { _safeMint(to, tokenId); } function isMinter(address account) public view returns (bool) { return hasRole(MINTER_ROLE, account); } function safeMint(address to, uint256 tokenId, bytes memory _data) public onlyMinter { _safeMint(to, tokenId, _data); } function _burn(uint256 tokenId) internal virtual override(ERC721, ERC721URIStorage) { ERC721URIStorage._burn(tokenId); } function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal override(ERC721, ERC721Enumerable) { super._beforeTokenTransfer(from, to, tokenId); } function tokenURI(uint256 tokenId) public view override(ERC721, ERC721URIStorage) returns (string memory) { return super.tokenURI(tokenId); } function supportsInterface(bytes4 interfaceId) public view override(ERC721, ERC721Enumerable, AccessControlEnumerable) returns (bool) { return super.supportsInterface(interfaceId); } function addMinter(address account) public onlyRole(MINTER_ROLE) { grantRole(MINTER_ROLE, account); } function canIMint() public view returns (bool) { return anyoneCanMint || isMinter(msg.sender); } /** * Open modifier to anyone can mint possibility */ modifier onlyMinter() { string memory mensaje; require( canIMint(), "MinterRole: caller does not have the Minter role" ); _; } } /** * @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; } } contract EIP20 { uint256 public totalSupply; uint256 constant private MAX_UINT256 = 2**256 - 1; mapping (address => uint256) public balances; mapping (address => mapping (address => uint256)) public allowed; /* NOTE: The following variables are OPTIONAL vanities. One does not have to include them. They allow one to customise the token contract & in no way influences the core functionality. Some wallets/interfaces might not even bother to look at this information. */ string public name; //fancy name: eg Simon Bucks uint8 public decimals; //How many decimals to show. string public symbol; //An identifier: eg SBX event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); constructor( uint256 _initialAmount, string memory _tokenName, uint8 _decimalUnits, string memory _tokenSymbol ) { balances[msg.sender] = _initialAmount; // Give the creator all initial tokens totalSupply = _initialAmount; // Update total supply name = _tokenName; // Set the name for display purposes decimals = _decimalUnits; // Amount of decimals for display purposes symbol = _tokenSymbol; // Set the symbol for display purposes } function transfer(address _to, uint256 _value) public returns (bool success) { require(balances[msg.sender] >= _value); balances[msg.sender] -= _value; balances[_to] += _value; emit Transfer(msg.sender, _to, _value); //solhint-disable-line indent, no-unused-vars return true; } function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { uint256 _allowance = allowed[_from][msg.sender]; require(balances[_from] >= _value && _allowance >= _value); balances[_to] += _value; balances[_from] -= _value; if (_allowance < MAX_UINT256) { allowed[_from][msg.sender] -= _value; } emit Transfer(_from, _to, _value); //solhint-disable-line indent, no-unused-vars return true; } function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } function approve(address _spender, uint256 _value) public returns (bool success) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); //solhint-disable-line indent, no-unused-vars return true; } function allowance(address _owner, address _spender) public view returns (uint256 remaining) { return allowed[_owner][_spender]; } } /** * @title ERC721Suika * ERC-721 Marketplace with tokens and royalties support */ contract ERC721Suika is ERC721Mochi, ReentrancyGuard { using Address for address payable; using Address for address; // admin address, the owner of the marketplace address payable admin; address public contract_owner; // ERC20 token to be used for payments EIP20 public payment_token; // commission rate is a value from 0 to 100 uint256 commissionRate; // royalties commission rate is a value from 0 to 100 uint256 royaltiesCommissionRate; // nft item creators list, used to pay royalties mapping(uint256 => address) public creators; // last price sold or auctioned mapping(uint256 => uint256) public soldFor; // Mapping from token ID to sell price in Ether or to bid price, depending if it is an auction or not mapping(uint256 => uint256) public sellBidPrice; // Mapping payment address for tokenId mapping(uint256 => address payable) private _wallets; event Sale(uint256 indexed tokenId, address indexed from, address indexed to, uint256 value); event Commission(uint256 indexed tokenId, address indexed to, uint256 value, uint256 rate, uint256 total); event Royalty(uint256 indexed tokenId, address indexed to, uint256 value, uint256 rate, uint256 total); // Auction data struct Auction { // Parameters of the auction. Times are either // absolute unix timestamps (seconds since 1970-01-01) // or time periods in seconds. address payable beneficiary; uint auctionEnd; // Current state of the auction. address payable highestBidder; uint highestBid; // Set to true at the end, disallows any change bool open; // minimum reserve price in wei uint256 reserve; } // mapping auctions for each tokenId mapping(uint256 => Auction) public auctions; // Events that will be fired on changes. event Refund(address bidder, uint amount); event HighestBidIncreased(address indexed bidder, uint amount, uint256 tokenId); event AuctionEnded(address winner, uint amount); event LimitSell(address indexed from, address indexed to, uint256 amount); event LimitBuy(address indexed from, address indexed to, uint256 amount); event MarketSell(address indexed from, address indexed to, uint256 amount); event MarketBuy(address indexed from, address indexed to, uint256 amount); constructor( EIP20 _payment_token, address _owner, address payable _admin, uint256 _commissionRate, uint256 _royaltiesCommissionRate, string memory name, string memory symbol, bool _anyoneCanMint) ERC721Mochi(_owner, name, symbol, _anyoneCanMint) { admin = _admin; contract_owner = _owner; require(_commissionRate<=100, "ERC721Suika: Commission rate has to be between 0 and 100"); commissionRate = _commissionRate; royaltiesCommissionRate = _royaltiesCommissionRate; payment_token = _payment_token; } function canSell(uint256 tokenId) external view returns (bool) { return (ownerOf(tokenId)==msg.sender && !auctions[tokenId].open); } // Sell option for a fixed price function sell(uint256 tokenId, uint256 price, address payable wallet) external { // onlyOwner require(ownerOf(tokenId)==msg.sender, "ERC721Suika: Only owner can sell this item"); // cannot set a price if auction is activated require(!auctions[tokenId].open, "ERC721Suika: Cannot sell an item which has an active auction"); // set sell price for index sellBidPrice[tokenId] = price; // If price is zero, means not for sale if (price>0) { // approve the Index to the current contract approve(address(this), tokenId); // set wallet payment _wallets[tokenId] = wallet; } } // simple function to return the price of a tokenId // returns: sell price, bid price, sold price, only one can be non zero function getPrice(uint256 tokenId) external view returns (uint256, uint256, uint256) { if (sellBidPrice[tokenId]>0) return (sellBidPrice[tokenId], 0, 0); if (auctions[tokenId].highestBid>0) return (0, auctions[tokenId].highestBid, 0); return (0, 0, soldFor[tokenId]); } function canBuy(uint256 tokenId) external view returns (uint256) { if (!auctions[tokenId].open && sellBidPrice[tokenId]>0 && sellBidPrice[tokenId]>0 && getApproved(tokenId) == address(this)) { return sellBidPrice[tokenId]; } else { return 0; } } // Buy option function buy(uint256 tokenId) external nonReentrant { // is on sale require(!auctions[tokenId].open && sellBidPrice[tokenId]>0, "ERC721Suika: The collectible is not for sale"); // transfer ownership address owner = ownerOf(tokenId); require(msg.sender!=owner, "ERC721Suika: The seller cannot buy his own collectible"); // we need to call a transferFrom from this contract, which is the one with permission to sell the NFT callOptionalReturn(this, abi.encodeWithSelector(this.transferFrom.selector, owner, msg.sender, tokenId)); // calculate amounts uint256 amount4admin = sellBidPrice[tokenId] * commissionRate / 100; uint256 amount4creator = sellBidPrice[tokenId] * royaltiesCommissionRate / 100; uint256 amount4owner = sellBidPrice[tokenId] - amount4admin - amount4creator; // to owner require(payment_token.transferFrom(msg.sender, _wallets[tokenId], amount4owner), "Transfer failed."); // to creator if (amount4creator>0) { require(payment_token.transferFrom(msg.sender, creators[tokenId], amount4creator), "Transfer failed."); } // to admin if (amount4admin>0) { require(payment_token.transferFrom(msg.sender, admin, amount4admin), "Transfer failed."); } emit Sale(tokenId, owner, msg.sender, sellBidPrice[tokenId]); emit Commission(tokenId, owner, sellBidPrice[tokenId], commissionRate, amount4admin); emit Royalty(tokenId, owner, sellBidPrice[tokenId], royaltiesCommissionRate, amount4creator); soldFor[tokenId] = sellBidPrice[tokenId]; // close the sell sellBidPrice[tokenId] = 0; delete _wallets[tokenId]; } function canAuction(uint256 tokenId) external view returns (bool) { return (ownerOf(tokenId)==msg.sender && !auctions[tokenId].open && sellBidPrice[tokenId]==0); } // Instantiate an auction contract for a tokenId function createAuction(uint256 tokenId, uint _closingTime, address payable _beneficiary, uint256 _reservePrice) external { require(sellBidPrice[tokenId]==0, "ERC721Suika: The selected NFT is open for sale, cannot be auctioned"); require(!auctions[tokenId].open, "ERC721Suika: The selected NFT already has an auction"); require(ownerOf(tokenId)==msg.sender, "ERC721Suika: Only owner can auction this item"); auctions[tokenId].beneficiary = _beneficiary; auctions[tokenId].auctionEnd = _closingTime; auctions[tokenId].reserve = _reservePrice; auctions[tokenId].open = true; // approve the Index to the current contract approve(address(this), tokenId); } function canBid(uint256 tokenId) external view returns (bool) { if (msg.sender == tx.origin && auctions[tokenId].open && block.timestamp <= auctions[tokenId].auctionEnd && msg.sender != ownerOf(tokenId) && getApproved(tokenId) == address(this) ) { return true; } else { return false; } } /// Overrides minting function to keep track of item creators function _mint(address to, uint256 tokenId) override internal { creators[tokenId] = msg.sender; super._mint(to, tokenId); } /// Bid on the auction with the value sent /// together with this transaction. /// The value will only be refunded if the /// auction is not won. function bid(uint256 tokenId, uint256 bid_value) external nonReentrant { // Contracts cannot bid, because they can block the auction with a reentrant attack require(msg.sender == tx.origin, "No script kiddies"); // auction has to be opened require(auctions[tokenId].open, "No opened auction found"); // approve was lost require(getApproved(tokenId) == address(this), "Cannot complete the auction"); // Revert the call if the bidding // period is over. require( block.timestamp <= auctions[tokenId].auctionEnd, "Auction already ended." ); // If the bid is not higher, send the // money back. require( bid_value > auctions[tokenId].highestBid, "There already is a higher bid." ); address owner = ownerOf(tokenId); require(msg.sender!=owner, "ERC721Suika: The owner cannot bid his own collectible"); // return the funds to the previous bidder, if there is one if (auctions[tokenId].highestBid>0) { require(payment_token.transfer(auctions[tokenId].highestBidder, auctions[tokenId].highestBid), "Transfer failed."); emit Refund(auctions[tokenId].highestBidder, auctions[tokenId].highestBid); } // now store the bid data auctions[tokenId].highestBidder = payable(msg.sender); // transfer tokens to contract require(payment_token.transferFrom(msg.sender, address(this), bid_value), "Transfer failed."); // register the highest bid value auctions[tokenId].highestBid = bid_value; emit HighestBidIncreased(msg.sender, bid_value, tokenId); } // anyone can execute withdraw if auction is opened and // the bid time expired and the reserve was not met // or // the auction is openen but the contract is unable to transfer function canWithdraw(uint256 tokenId) public view returns (bool) { if (auctions[tokenId].open && ( ( block.timestamp >= auctions[tokenId].auctionEnd && auctions[tokenId].highestBid > 0 && auctions[tokenId].highestBid<auctions[tokenId].reserve ) || getApproved(tokenId) != address(this) ) ) { return true; } else { return false; } } /// Withdraw a bid when the auction is not finalized function withdraw(uint256 tokenId) external nonReentrant { require(canWithdraw(tokenId), "Conditions to withdraw are not met"); // transfer funds to highest bidder always if (auctions[tokenId].highestBid > 0) { require(payment_token.transfer(auctions[tokenId].highestBidder, auctions[tokenId].highestBid), "Transfer failed."); } // finalize the auction delete auctions[tokenId]; } function canFinalize(uint256 tokenId) public view returns (bool) { if (auctions[tokenId].open && block.timestamp >= auctions[tokenId].auctionEnd && ( auctions[tokenId].highestBid>=auctions[tokenId].reserve || auctions[tokenId].highestBid==0 ) ) { return true; } else { return false; } } // implement the auctionFinalize including the NFT transfer logic function auctionFinalize(uint256 tokenId) external nonReentrant { require(canFinalize(tokenId), "Cannot finalize"); if (auctions[tokenId].highestBid>0) { // transfer the ownership of token to the highest bidder address payable _highestBidder = auctions[tokenId].highestBidder; // calculate payment amounts uint256 amount4admin = auctions[tokenId].highestBid * commissionRate / 100; uint256 amount4creator = auctions[tokenId].highestBid * royaltiesCommissionRate / 100; uint256 amount4owner = auctions[tokenId].highestBid- amount4admin - amount4creator; // to owner require(payment_token.transfer(auctions[tokenId].beneficiary, amount4owner), "Transfer failed."); // to creator if (amount4creator>0) { require(payment_token.transfer(creators[tokenId], amount4creator), "Transfer failed."); } // to admin if (amount4admin>0) { require(payment_token.transfer(admin, amount4admin), "Transfer failed."); } emit Sale(tokenId, auctions[tokenId].beneficiary, _highestBidder, auctions[tokenId].highestBid); emit Royalty(tokenId, auctions[tokenId].beneficiary, auctions[tokenId].highestBid, royaltiesCommissionRate, amount4creator); emit Commission(tokenId, auctions[tokenId].beneficiary, auctions[tokenId].highestBid, commissionRate, amount4admin); // transfer ownership address owner = ownerOf(tokenId); // we need to call a transferFrom from this contract, which is the one with permission to sell the NFT // transfer the NFT to the auction's highest bidder callOptionalReturn(this, abi.encodeWithSelector(this.transferFrom.selector, owner, _highestBidder, tokenId)); soldFor[tokenId] = auctions[tokenId].highestBid; } emit AuctionEnded(auctions[tokenId].highestBidder, auctions[tokenId].highestBid); // finalize the auction delete auctions[tokenId]; } // Bid query functions function highestBidder(uint256 tokenId) external view returns (address payable) { return auctions[tokenId].highestBidder; } function highestBid(uint256 tokenId) external view returns (uint256) { return auctions[tokenId].highestBid; } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function callOptionalReturn(IERC721 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. // A Solidity high level call has three parts: // 1. The target address is checked to verify it contains contract code // 2. The call itself is made, and success asserted // 3. The return value is decoded, which in turn checks the size of the returned data. // solhint-disable-next-line max-line-length require(address(token).isContract(), "SafeERC721: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = address(token).call(data); require(success, "SafeERC721: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC721: ERC20 operation did not succeed"); } } // update contract fields function updateAdmin(address payable _admin, uint256 _commissionRate, uint256 _royaltiesCommissionRate, bool _anyoneCanMint, EIP20 _payment_token) external { require(msg.sender==contract_owner, "Only contract owner can do this"); require(_commissionRate <= 100, "Commission rate has to be equal or lower than 100"); require(_royaltiesCommissionRate <= 100, "Royalties commission rate has to be equal or lower than 100"); require(_commissionRate + _royaltiesCommissionRate <= 100, "Commision plus royalties has to be equal or lower than 100"); admin = _admin; commissionRate = _commissionRate; royaltiesCommissionRate = _royaltiesCommissionRate; anyoneCanMint = _anyoneCanMint; payment_token = _payment_token; } // update owner function updateOwner(address _contract_owner) external { require(msg.sender==contract_owner, "Only contract owner can do this"); // grant roles to new owner _setupRole(DEFAULT_ADMIN_ROLE, _contract_owner); _setupRole(MINTER_ROLE, _contract_owner); // revoke roles of old owner revokeRole(MINTER_ROLE, contract_owner); revokeRole(DEFAULT_ADMIN_ROLE, contract_owner); // change ownership contract_owner = _contract_owner; } }
{ "evmVersion": "istanbul", "libraries": {}, "metadata": { "bytecodeHash": "ipfs", "useLiteralContent": true }, "optimizer": { "enabled": true, "runs": 200 }, "remappings": [], "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } } }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"contract EIP20","name":"_payment_token","type":"address"},{"internalType":"address","name":"_owner","type":"address"},{"internalType":"address payable","name":"_admin","type":"address"},{"internalType":"uint256","name":"_commissionRate","type":"uint256"},{"internalType":"uint256","name":"_royaltiesCommissionRate","type":"uint256"},{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"symbol","type":"string"},{"internalType":"bool","name":"_anyoneCanMint","type":"bool"}],"stateMutability":"nonpayable","type":"constructor"},{"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":"address","name":"winner","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"AuctionEnded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"rate","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"total","type":"uint256"}],"name":"Commission","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"bidder","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"HighestBidIncreased","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"LimitBuy","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"LimitSell","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"MarketBuy","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"MarketSell","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"bidder","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Refund","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"rate","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"total","type":"uint256"}],"name":"Royalty","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Sale","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MINTER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"addMinter","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"anyoneCanMint","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"auctionFinalize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"auctions","outputs":[{"internalType":"address payable","name":"beneficiary","type":"address"},{"internalType":"uint256","name":"auctionEnd","type":"uint256"},{"internalType":"address payable","name":"highestBidder","type":"address"},{"internalType":"uint256","name":"highestBid","type":"uint256"},{"internalType":"bool","name":"open","type":"bool"},{"internalType":"uint256","name":"reserve","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"_tokenURI","type":"string"},{"internalType":"address","name":"to","type":"address"}],"name":"autoMint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"bid_value","type":"uint256"}],"name":"bid","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"burn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"buy","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"canAuction","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"canBid","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"canBuy","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"canFinalize","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"canIMint","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"canSell","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"canWithdraw","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"contract_owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"_closingTime","type":"uint256"},{"internalType":"address payable","name":"_beneficiary","type":"address"},{"internalType":"uint256","name":"_reservePrice","type":"uint256"}],"name":"createAuction","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"creators","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"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":"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":"uint256","name":"tokenId","type":"uint256"}],"name":"highestBid","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"highestBidder","outputs":[{"internalType":"address payable","name":"","type":"address"}],"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":[{"internalType":"address","name":"account","type":"address"}],"name":"isMinter","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"mint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"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":"payment_token","outputs":[{"internalType":"contract EIP20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"safeMint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"safeMint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"address payable","name":"wallet","type":"address"}],"name":"sell","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"sellBidPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"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":"uint256","name":"","type":"uint256"}],"name":"soldFor","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"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":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenOfOwnerByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address payable","name":"_admin","type":"address"},{"internalType":"uint256","name":"_commissionRate","type":"uint256"},{"internalType":"uint256","name":"_royaltiesCommissionRate","type":"uint256"},{"internalType":"bool","name":"_anyoneCanMint","type":"bool"},{"internalType":"contract EIP20","name":"_payment_token","type":"address"}],"name":"updateAdmin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_contract_owner","type":"address"}],"name":"updateOwner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
60806040523480156200001157600080fd5b50604051620050d0380380620050d0833981016040819052620000349162000463565b8683838382828160009080519060200190620000529291906200030a565b508051620000689060019060208401906200030a565b506200007a91506000905085620001a1565b620000a67f9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a685620001a1565b600e805491151560ff1990921691909117905550506001600f5550601080546001600160a01b038089166001600160a01b03199283161790925560118054928a169290911691909117905560648511156200016d5760405162461bcd60e51b815260206004820152603860248201527f4552433732315375696b613a20436f6d6d697373696f6e20726174652068617360448201527f20746f206265206265747765656e203020616e64203130300000000000000000606482015260840160405180910390fd5b5050506013919091556014555050601280546001600160a01b0319166001600160a01b0392909216919091179055620005a5565b620001b88282620001e460201b62002bf21760201c565b6000828152600c60209081526040909120620001df91839062002bfc620001f4821b17901c565b505050565b620001f0828262000214565b5050565b60006200020b836001600160a01b038416620002b8565b90505b92915050565b6000828152600b602090815260408083206001600160a01b038516845290915290205460ff16620001f0576000828152600b602090815260408083206001600160a01b03851684529091529020805460ff19166001179055620002743390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b600081815260018301602052604081205462000301575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556200020e565b5060006200020e565b828054620003189062000539565b90600052602060002090601f0160209004810192826200033c576000855562000387565b82601f106200035757805160ff191683800117855562000387565b8280016001018555821562000387579182015b82811115620003875782518255916020019190600101906200036a565b506200039592915062000399565b5090565b5b808211156200039557600081556001016200039a565b600082601f830112620003c1578081fd5b81516001600160401b0380821115620003de57620003de62000576565b604051601f8301601f19908116603f0116810190828211818310171562000409576200040962000576565b8160405283815260209250868385880101111562000425578485fd5b8491505b8382101562000448578582018301518183018401529082019062000429565b838211156200045957848385830101525b9695505050505050565b600080600080600080600080610100898b03121562000480578384fd5b88516200048d816200058c565b60208a0151909850620004a0816200058c565b60408a0151909750620004b3816200058c565b60608a015160808b015160a08c015192985090965094506001600160401b0380821115620004df578485fd5b620004ed8c838d01620003b0565b945060c08b015191508082111562000503578384fd5b50620005128b828c01620003b0565b92505060e0890151801515811462000528578182fd5b809150509295985092959890939650565b600181811c908216806200054e57607f821691505b602082108114156200057057634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0381168114620005a257600080fd5b50565b614b1b80620005b56000396000f3fe608060405234801561001057600080fd5b50600436106103835760003560e01c806389f4c0b1116101de578063b88d4fde1161010f578063d96a094a116100ad578063e985e9c51161007c578063e985e9c514610897578063ee1b59e4146108d3578063fa184c49146108db578063fbe85f06146108ee57600080fd5b8063d96a094a14610830578063dc16bd4314610843578063e4e2bfe414610856578063e75722301461086957600080fd5b8063cd53d08e116100e9578063cd53d08e146107cc578063d04c6983146107f5578063d539139314610808578063d547741f1461081d57600080fd5b8063b88d4fde14610793578063c87b56dd146107a6578063ca15c873146107b957600080fd5b8063a22cb4651161017c578063b13fbe9611610156578063b13fbe961461073d578063b14c63c51461074a578063b1cb48ef1461076d578063b2ecfad41461078057600080fd5b8063a22cb465146106f7578063a36b14621461070a578063aa271e1a1461072a57600080fd5b806395d89b41116101b857806395d89b41146106c1578063983b2d56146106c9578063a1448194146106dc578063a217fddf146106ef57600080fd5b806389f4c0b1146106885780639010d07c1461069b57806391d14854146106ae57600080fd5b8063384f58eb116102b8578063571a26a0116102565780636352211e116102305780636352211e1461063c57806370a082311461064f578063880cdc31146106625780638832e6e31461067557600080fd5b8063571a26a014610581578063598647f81461061657806361a09c971461062957600080fd5b806342842e0e1161029257806342842e0e1461051c57806342966c681461052f578063451df52e146105425780634f6ccce71461056e57600080fd5b8063384f58eb146104e35780633ca88a2f146104f657806340c10f191461050957600080fd5b806323b872dd116103255780632f2ff15d116102ff5780632f2ff15d146104975780632f745c59146104aa578063331c6587146104bd57806336568abe146104d057600080fd5b806323b872dd1461044e578063248a9ca3146104615780632e1a7d4d1461048457600080fd5b8063095ea7b311610361578063095ea7b3146103f0578063172b099d1461040557806318160ddd146104335780631ac70f6f1461043b57600080fd5b806301ffc9a71461038857806306fdde03146103b0578063081812fc146103c5575b600080fd5b61039b610396366004614581565b610901565b60405190151581526020015b60405180910390f35b6103b8610912565b6040516103a791906147d4565b6103d86103d3366004614524565b6109a4565b6040516001600160a01b0390911681526020016103a7565b6104036103fe366004614486565b610a31565b005b610425610413366004614524565b60176020526000908152604090205481565b6040519081526020016103a7565b600854610425565b61039b610449366004614524565b610b47565b61040361045c3660046143af565b610b96565b61042561046f366004614524565b6000908152600b602052604090206001015490565b610403610492366004614524565b610bc8565b6104036104a536600461453c565b610d77565b6104256104b8366004614486565b610d99565b6012546103d8906001600160a01b031681565b6104036104de36600461453c565b610e2f565b6011546103d8906001600160a01b031681565b610425610504366004614524565b610e51565b610403610517366004614486565b610ed5565b61040361052a3660046143af565b610f05565b61040361053d366004614524565b610f20565b6103d8610550366004614524565b6000908152601960205260409020600201546001600160a01b031690565b61042561057c366004614524565b610f9a565b6105d661058f366004614524565b6019602052600090815260409020805460018201546002830154600384015460048501546005909501546001600160a01b0394851695939490921692909160ff9091169086565b604080516001600160a01b0397881681526020810196909652939095169284019290925260608301521515608082015260a081019190915260c0016103a7565b610403610624366004614560565b61103b565b6104036106373660046145b9565b6114f8565b6103d861064a366004614524565b61155a565b61042561065d3660046142fd565b6115d1565b6104036106703660046142fd565b611658565b6104036106833660046144b1565b611734565b61039b610696366004614524565b611765565b6103d86106a9366004614560565b6117f3565b61039b6106bc36600461453c565b611812565b6103b861183d565b6104036106d73660046142fd565b61184c565b6104036106ea366004614486565b611881565b610425600081565b610403610705366004614459565b6118b1565b610425610718366004614524565b60166020526000908152604090205481565b61039b6107383660046142fd565b611976565b600e5461039b9060ff1681565b610425610758366004614524565b60009081526019602052604090206003015490565b61040361077b366004614649565b611990565b61039b61078e366004614524565b611b63565b6104036107a13660046143ef565b611b9a565b6103b86107b4366004614524565b611bcc565b6104256107c7366004614524565b611bd7565b6103d86107da366004614524565b6015602052600090815260409020546001600160a01b031681565b610403610803366004614611565b611bee565b610425600080516020614ac683398151915281565b61040361082b36600461453c565b611d38565b61040361083e366004614524565b611d42565b610403610851366004614524565b6122d8565b61039b610864366004614524565b612840565b61087c610877366004614524565b6128b8565b604080519384526020840192909252908201526060016103a7565b61039b6108a5366004614377565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b61039b612937565b6104036108e9366004614319565b612954565b61039b6108fc366004614524565b612b5d565b600061090c82612c11565b92915050565b606060008054610921906149e0565b80601f016020809104026020016040519081016040528092919081815260200182805461094d906149e0565b801561099a5780601f1061096f5761010080835404028352916020019161099a565b820191906000526020600020905b81548152906001019060200180831161097d57829003601f168201915b5050505050905090565b60006109af82612c36565b610a155760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084015b60405180910390fd5b506000908152600460205260409020546001600160a01b031690565b6000610a3c8261155a565b9050806001600160a01b0316836001600160a01b03161415610aaa5760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b6064820152608401610a0c565b336001600160a01b0382161480610ac65750610ac681336108a5565b610b385760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c00000000000000006064820152608401610a0c565b610b428383612c53565b505050565b600033610b538361155a565b6001600160a01b0316148015610b7b575060008281526019602052604090206004015460ff16155b801561090c5750506000908152601760205260409020541590565b610ba1335b82612cc1565b610bbd5760405162461bcd60e51b8152600401610a0c906148b3565b610b42838383612dab565b6002600f541415610beb5760405162461bcd60e51b8152600401610a0c90614904565b6002600f55610bf981612b5d565b610c505760405162461bcd60e51b815260206004820152602260248201527f436f6e646974696f6e7320746f20776974686472617720617265206e6f74206d604482015261195d60f21b6064820152608401610a0c565b60008181526019602052604090206003015415610d2457601254600082815260196020526040908190206002810154600390910154915163a9059cbb60e01b81526001600160a01b03918216600482015260248101929092529091169063a9059cbb90604401602060405180830381600087803b158015610cd057600080fd5b505af1158015610ce4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d089190614508565b610d245760405162461bcd60e51b8152600401610a0c90614889565b600090815260196020526040812080546001600160a01b0319908116825560018083018490556002830180549092169091556003820183905560048201805460ff19169055600590910191909155600f55565b610d818282612f56565b6000828152600c60205260409020610b429082612bfc565b6000610da4836115d1565b8210610e065760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201526a74206f6620626f756e647360a81b6064820152608401610a0c565b506001600160a01b03919091166000908152600660209081526040808320938352929052205490565b610e398282612f7c565b6000828152600c60205260409020610b429082612ff6565b60008181526019602052604081206004015460ff16158015610e80575060008281526017602052604090205415155b8015610e99575060008281526017602052604090205415155b8015610eb5575030610eaa836109a4565b6001600160a01b0316145b15610ecd575060009081526017602052604090205490565b506000919050565b6060610edf612937565b610efb5760405162461bcd60e51b8152600401610a0c90614839565b610b42838361300b565b610b4283838360405180602001604052806000815250611b9a565b610f2933610b9b565b610f8e5760405162461bcd60e51b815260206004820152603060248201527f4552433732314275726e61626c653a2063616c6c6572206973206e6f74206f7760448201526f1b995c881b9bdc88185c1c1c9bdd995960821b6064820152608401610a0c565b610f9781613033565b50565b6000610fa560085490565b82106110085760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201526b7574206f6620626f756e647360a01b6064820152608401610a0c565b6008828154811061102957634e487b7160e01b600052603260045260246000fd5b90600052602060002001549050919050565b6002600f54141561105e5760405162461bcd60e51b8152600401610a0c90614904565b6002600f553332146110a65760405162461bcd60e51b81526020600482015260116024820152704e6f20736372697074206b69646469657360781b6044820152606401610a0c565b60008281526019602052604090206004015460ff166111075760405162461bcd60e51b815260206004820152601760248201527f4e6f206f70656e65642061756374696f6e20666f756e640000000000000000006044820152606401610a0c565b30611111836109a4565b6001600160a01b0316146111675760405162461bcd60e51b815260206004820152601b60248201527f43616e6e6f7420636f6d706c657465207468652061756374696f6e00000000006044820152606401610a0c565b6000828152601960205260409020600101544211156111c15760405162461bcd60e51b815260206004820152601660248201527520bab1ba34b7b71030b63932b0b23c9032b73232b21760511b6044820152606401610a0c565b60008281526019602052604090206003015481116112215760405162461bcd60e51b815260206004820152601e60248201527f546865726520616c7265616479206973206120686967686572206269642e00006044820152606401610a0c565b600061122c8361155a565b9050336001600160a01b03821614156112a55760405162461bcd60e51b815260206004820152603560248201527f4552433732315375696b613a20546865206f776e65722063616e6e6f742062696044820152746420686973206f776e20636f6c6c65637469626c6560581b6064820152608401610a0c565b600083815260196020526040902060030154156113d857601254600084815260196020526040908190206002810154600390910154915163a9059cbb60e01b81526001600160a01b03918216600482015260248101929092529091169063a9059cbb90604401602060405180830381600087803b15801561132557600080fd5b505af1158015611339573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061135d9190614508565b6113795760405162461bcd60e51b8152600401610a0c90614889565b600083815260196020908152604091829020600281015460039091015483516001600160a01b039092168252918101919091527fbb28353e4598c3b9199101a66e0989549b659a59a54d2c27fbb183f1932c8e6d910160405180910390a15b6000838152601960205260409081902060020180546001600160a01b0319163390811790915560125491516323b872dd60e01b81526001600160a01b0392909216916323b872dd916114309130908790600401614773565b602060405180830381600087803b15801561144a57600080fd5b505af115801561145e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114829190614508565b61149e5760405162461bcd60e51b8152600401610a0c90614889565b600083815260196020908152604091829020600301849055815184815290810185905233917fdafc4a123c6bb3b49dd38a0cba299808581a0126a37248a5f1102d5e5fa06337910160405180910390a250506001600f5550565b6060611502612937565b61151e5760405162461bcd60e51b8152600401610a0c90614839565b60005b61152f600d80546001019055565b50600d5461153c81612c36565b6115215761154a838261300b565b611554818561303c565b50505050565b6000818152600260205260408120546001600160a01b03168061090c5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b6064820152608401610a0c565b60006001600160a01b03821661163c5760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b6064820152608401610a0c565b506001600160a01b031660009081526003602052604090205490565b6011546001600160a01b031633146116b25760405162461bcd60e51b815260206004820152601f60248201527f4f6e6c7920636f6e7472616374206f776e65722063616e20646f2074686973006044820152606401610a0c565b6116bd6000826130c7565b6116d5600080516020614ac6833981519152826130c7565b6011546116fa90600080516020614ac6833981519152906001600160a01b0316611d38565b601154611712906000906001600160a01b0316611d38565b601180546001600160a01b0319166001600160a01b0392909216919091179055565b606061173e612937565b61175a5760405162461bcd60e51b8152600401610a0c90614839565b6115548484846130d1565b60003332148015611787575060008281526019602052604090206004015460ff165b80156117a457506000828152601960205260409020600101544211155b80156117ca57506117b48261155a565b6001600160a01b0316336001600160a01b031614155b80156117e65750306117db836109a4565b6001600160a01b0316145b15610ecd57506001919050565b6000828152600c6020526040812061180b9083613104565b9392505050565b6000918252600b602090815260408084206001600160a01b0393909316845291905290205460ff1690565b606060018054610921906149e0565b600080516020614ac68339815191526118658133613110565b61187d600080516020614ac683398151915283610d77565b5050565b606061188b612937565b6118a75760405162461bcd60e51b8152600401610a0c90614839565b610b428383613174565b6001600160a01b03821633141561190a5760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610a0c565b3360008181526005602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b600061090c600080516020614ac683398151915283611812565b60008481526017602052604090205415611a1e5760405162461bcd60e51b815260206004820152604360248201527f4552433732315375696b613a205468652073656c6563746564204e465420697360448201527f206f70656e20666f722073616c652c2063616e6e6f742062652061756374696f6064820152621b995960ea1b608482015260a401610a0c565b60008481526019602052604090206004015460ff1615611a9d5760405162461bcd60e51b815260206004820152603460248201527f4552433732315375696b613a205468652073656c6563746564204e465420616c6044820152733932b0b23c903430b99030b71030bab1ba34b7b760611b6064820152608401610a0c565b33611aa78561155a565b6001600160a01b031614611b135760405162461bcd60e51b815260206004820152602d60248201527f4552433732315375696b613a204f6e6c79206f776e65722063616e206175637460448201526c696f6e2074686973206974656d60981b6064820152608401610a0c565b600084815260196020526040902080546001600160a01b0319166001600160a01b0384161781556001808201859055600582018390556004909101805460ff191690911790556115543085610a31565b600033611b6f8361155a565b6001600160a01b031614801561090c57505060009081526019602052604090206004015460ff161590565b611ba43383612cc1565b611bc05760405162461bcd60e51b8152600401610a0c906148b3565b6115548484848461318e565b606061090c826131c1565b6000818152600c6020526040812061090c90613330565b33611bf88461155a565b6001600160a01b031614611c615760405162461bcd60e51b815260206004820152602a60248201527f4552433732315375696b613a204f6e6c79206f776e65722063616e2073656c6c6044820152692074686973206974656d60b01b6064820152608401610a0c565b60008381526019602052604090206004015460ff1615611ce95760405162461bcd60e51b815260206004820152603c60248201527f4552433732315375696b613a2043616e6e6f742073656c6c20616e206974656d60448201527f2077686963682068617320616e206163746976652061756374696f6e000000006064820152608401610a0c565b60008381526017602052604090208290558115610b4257611d0a3084610a31565b600083815260186020526040902080546001600160a01b0383166001600160a01b0319909116179055505050565b610e39828261333a565b6002600f541415611d655760405162461bcd60e51b8152600401610a0c90614904565b6002600f5560008181526019602052604090206004015460ff16158015611d99575060008181526017602052604090205415155b611dfa5760405162461bcd60e51b815260206004820152602c60248201527f4552433732315375696b613a2054686520636f6c6c65637469626c652069732060448201526b6e6f7420666f722073616c6560a01b6064820152608401610a0c565b6000611e058261155a565b9050336001600160a01b0382161415611e7f5760405162461bcd60e51b815260206004820152603660248201527f4552433732315375696b613a205468652073656c6c65722063616e6e6f742062604482015275757920686973206f776e20636f6c6c65637469626c6560501b6064820152608401610a0c565b611ed7306323b872dd60e01b833386604051602401611ea093929190614773565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152613360565b6013546000838152601760205260408120549091606491611ef89190614967565b611f029190614953565b60145460008581526017602052604081205492935091606491611f2491614967565b611f2e9190614953565b600085815260176020526040812054919250908290611f4e908590614986565b611f589190614986565b601254600087815260186020526040908190205490516323b872dd60e01b81529293506001600160a01b03918216926323b872dd92611fa09233929116908690600401614773565b602060405180830381600087803b158015611fba57600080fd5b505af1158015611fce573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ff29190614508565b61200e5760405162461bcd60e51b8152600401610a0c90614889565b81156120c857601254600086815260156020526040908190205490516323b872dd60e01b81526001600160a01b03928316926323b872dd9261205a923392909116908790600401614773565b602060405180830381600087803b15801561207457600080fd5b505af1158015612088573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120ac9190614508565b6120c85760405162461bcd60e51b8152600401610a0c90614889565b8215612175576012546010546040516323b872dd60e01b81526001600160a01b03928316926323b872dd92612107923392909116908890600401614773565b602060405180830381600087803b15801561212157600080fd5b505af1158015612135573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121599190614508565b6121755760405162461bcd60e51b8152600401610a0c90614889565b336001600160a01b0316846001600160a01b0316867f88863d5e20f64464b554931394e2e4b6f09c10015147215bf26b3ba5070acebe601760008a8152602001908152602001600020546040516121ce91815260200190565b60405180910390a4600085815260176020908152604091829020546013548351918252918101919091529081018490526001600160a01b0385169086907fef7a63d352d8b0f42e35d7f8bd277ba75ba2ff721a50eaad4c62f1ee6561d5eb9060600160405180910390a3600085815260176020908152604091829020546014548351918252918101919091529081018390526001600160a01b0385169086907f69c21e0288fa2ee397e158571d58b093897385aaa1ccb8deacd82fc0e17a08bd9060600160405180910390a3505050600091825250601760209081526040808320805460168452828520558390556018909152902080546001600160a01b03191690556001600f55565b6002600f5414156122fb5760405162461bcd60e51b8152600401610a0c90614904565b6002600f5561230981612840565b6123475760405162461bcd60e51b815260206004820152600f60248201526e43616e6e6f742066696e616c697a6560881b6044820152606401610a0c565b6000818152601960205260409020600301541561278f57600081815260196020526040812060028101546013546003909201546001600160a01b0390911692916064916123949190614967565b61239e9190614953565b601454600085815260196020526040812060030154929350916064916123c391614967565b6123cd9190614953565b6000858152601960205260408120600301549192509082906123f0908590614986565b6123fa9190614986565b6012546000878152601960205260409081902054905163a9059cbb60e01b81526001600160a01b03918216600482015260248101849052929350169063a9059cbb90604401602060405180830381600087803b15801561245957600080fd5b505af115801561246d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124919190614508565b6124ad5760405162461bcd60e51b8152600401610a0c90614889565b8115612564576012546000868152601560205260409081902054905163a9059cbb60e01b81526001600160a01b0391821660048201526024810185905291169063a9059cbb90604401602060405180830381600087803b15801561251057600080fd5b505af1158015612524573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125489190614508565b6125645760405162461bcd60e51b8152600401610a0c90614889565b821561260e5760125460105460405163a9059cbb60e01b81526001600160a01b0391821660048201526024810186905291169063a9059cbb90604401602060405180830381600087803b1580156125ba57600080fd5b505af11580156125ce573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125f29190614508565b61260e5760405162461bcd60e51b8152600401610a0c90614889565b600085815260196020908152604091829020805460039091015492519283526001600160a01b038781169391169188917f88863d5e20f64464b554931394e2e4b6f09c10015147215bf26b3ba5070acebe910160405180910390a460008581526019602090815260409182902080546003909101546014548451918252928101929092529181018490526001600160a01b039091169086907f69c21e0288fa2ee397e158571d58b093897385aaa1ccb8deacd82fc0e17a08bd9060600160405180910390a360008581526019602090815260409182902080546003909101546013548451918252928101929092529181018590526001600160a01b039091169086907fef7a63d352d8b0f42e35d7f8bd277ba75ba2ff721a50eaad4c62f1ee6561d5eb9060600160405180910390a360006127488661155a565b905061276b306323b872dd60e01b83888a604051602401611ea093929190614773565b50505060008381526019602090815260408083206003015460169092529091205550505b600081815260196020908152604091829020600281015460039091015483516001600160a01b039092168252918101919091527fdaec4582d5d9595688c8c98545fdd1c696d41c6aeaeb636737e84ed2f5c00eda910160405180910390a1600090815260196020526040812080546001600160a01b0319908116825560018083018490556002830180549092169091556003820183905560048201805460ff19169055600590910191909155600f55565b60008181526019602052604081206004015460ff16801561287257506000828152601960205260409020600101544210155b80156117e65750600082815260196020526040902060058101546003909101541015806117e65750600082815260196020526040902060030154610ecd57506001919050565b60008181526017602052604081205481908190156128e9575050506000818152601760205260408120549080612930565b6000848152601960205260409020600301541561291b5750505060008181526019602052604081206003015481612930565b50505060008181526016602052604081205481905b9193909250565b600e5460009060ff168061294f575061294f33611976565b905090565b6011546001600160a01b031633146129ae5760405162461bcd60e51b815260206004820152601f60248201527f4f6e6c7920636f6e7472616374206f776e65722063616e20646f2074686973006044820152606401610a0c565b6064841115612a195760405162461bcd60e51b815260206004820152603160248201527f436f6d6d697373696f6e20726174652068617320746f20626520657175616c2060448201527006f72206c6f776572207468616e2031303607c1b6064820152608401610a0c565b6064831115612a905760405162461bcd60e51b815260206004820152603b60248201527f526f79616c7469657320636f6d6d697373696f6e20726174652068617320746f60448201527f20626520657175616c206f72206c6f776572207468616e2031303000000000006064820152608401610a0c565b6064612a9c848661493b565b1115612b105760405162461bcd60e51b815260206004820152603a60248201527f436f6d6d6973696f6e20706c757320726f79616c746965732068617320746f2060448201527f626520657175616c206f72206c6f776572207468616e203130300000000000006064820152608401610a0c565b601080546001600160a01b039687166001600160a01b031991821617909155601394909455601492909255600e805491151560ff1990921691909117905560128054919093169116179055565b60008181526019602052604081206004015460ff1680156117e657506000828152601960205260409020600101544210801590612baa575060008281526019602052604090206003015415155b8015612bcc575060008281526019602052604090206005810154600390910154105b806117e6575030612bdc836109a4565b6001600160a01b031614610ecd57506001919050565b61187d82826134eb565b600061180b836001600160a01b038416613571565b60006001600160e01b03198216635a05180f60e01b148061090c575061090c826135c0565b6000908152600260205260409020546001600160a01b0316151590565b600081815260046020526040902080546001600160a01b0319166001600160a01b0384169081179091558190612c888261155a565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000612ccc82612c36565b612d2d5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b6064820152608401610a0c565b6000612d388361155a565b9050806001600160a01b0316846001600160a01b03161480612d735750836001600160a01b0316612d68846109a4565b6001600160a01b0316145b80612da357506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff165b949350505050565b826001600160a01b0316612dbe8261155a565b6001600160a01b031614612e265760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b6064820152608401610a0c565b6001600160a01b038216612e885760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b6064820152608401610a0c565b612e938383836135e5565b612e9e600082612c53565b6001600160a01b0383166000908152600360205260408120805460019290612ec7908490614986565b90915550506001600160a01b0382166000908152600360205260408120805460019290612ef590849061493b565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b6000828152600b6020526040902060010154612f728133613110565b610b4283836134eb565b6001600160a01b0381163314612fec5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b6064820152608401610a0c565b61187d82826135f0565b600061180b836001600160a01b038416613657565b600081815260156020526040902080546001600160a01b0319163317905561187d8282613774565b610f97816138b3565b61304582612c36565b6130a85760405162461bcd60e51b815260206004820152602e60248201527f45524337323155524953746f726167653a2055524920736574206f66206e6f6e60448201526d32bc34b9ba32b73a103a37b5b2b760911b6064820152608401610a0c565b6000828152600a602090815260409091208251610b4292840190614199565b610d818282612bf2565b6130db838361300b565b6130e860008484846138f3565b610b425760405162461bcd60e51b8152600401610a0c906147e7565b600061180b8383613a00565b61311a8282611812565b61187d57613132816001600160a01b03166014613a38565b61313d836020613a38565b60405160200161314e9291906146fe565b60408051601f198184030181529082905262461bcd60e51b8252610a0c916004016147d4565b61187d8282604051806020016040528060008152506130d1565b613199848484612dab565b6131a5848484846138f3565b6115545760405162461bcd60e51b8152600401610a0c906147e7565b60606131cc82612c36565b6132325760405162461bcd60e51b815260206004820152603160248201527f45524337323155524953746f726167653a2055524920717565727920666f72206044820152703737b732bc34b9ba32b73a103a37b5b2b760791b6064820152608401610a0c565b6000828152600a60205260408120805461324b906149e0565b80601f0160208091040260200160405190810160405280929190818152602001828054613277906149e0565b80156132c45780601f10613299576101008083540402835291602001916132c4565b820191906000526020600020905b8154815290600101906020018083116132a757829003601f168201915b5050505050905060006132e260408051602081019091526000815290565b90508051600014156132f5575092915050565b81511561332757808260405160200161330f9291906146cf565b60405160208183030381529060405292505050919050565b612da384613c1a565b600061090c825490565b6000828152600b60205260409020600101546133568133613110565b610b4283836135f0565b6001600160a01b0382163b6133b75760405162461bcd60e51b815260206004820181905260248201527f536166654552433732313a2063616c6c20746f206e6f6e2d636f6e74726163746044820152606401610a0c565b600080836001600160a01b0316836040516133d291906146b3565b6000604051808303816000865af19150503d806000811461340f576040519150601f19603f3d011682016040523d82523d6000602084013e613414565b606091505b5091509150816134705760405162461bcd60e51b815260206004820152602160248201527f536166654552433732313a206c6f772d6c6576656c2063616c6c206661696c656044820152601960fa1b6064820152608401610a0c565b805115611554578080602001905181019061348b9190614508565b6115545760405162461bcd60e51b815260206004820152602b60248201527f536166654552433732313a204552433230206f7065726174696f6e206469642060448201526a1b9bdd081cdd58d8d9595960aa1b6064820152608401610a0c565b6134f58282611812565b61187d576000828152600b602090815260408083206001600160a01b03851684529091529020805460ff1916600117905561352d3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b60008181526001830160205260408120546135b85750815460018181018455600084815260208082209093018490558454848252828601909352604090209190915561090c565b50600061090c565b60006001600160e01b03198216637965db0b60e01b148061090c575061090c82613cf1565b610b42838383613d16565b6135fa8282611812565b1561187d576000828152600b602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6000818152600183016020526040812054801561376a57600061367b600183614986565b855490915060009061368f90600190614986565b90508181146137105760008660000182815481106136bd57634e487b7160e01b600052603260045260246000fd5b90600052602060002001549050808760000184815481106136ee57634e487b7160e01b600052603260045260246000fd5b6000918252602080832090910192909255918252600188019052604090208390555b855486908061372f57634e487b7160e01b600052603160045260246000fd5b60019003818190600052602060002001600090559055856001016000868152602001908152602001600020600090556001935050505061090c565b600091505061090c565b6001600160a01b0382166137ca5760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610a0c565b6137d381612c36565b156138205760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610a0c565b61382c600083836135e5565b6001600160a01b038216600090815260036020526040812080546001929061385590849061493b565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b6138bc81613dce565b6000818152600a6020526040902080546138d5906149e0565b159050610f97576000818152600a60205260408120610f979161421d565b60006001600160a01b0384163b156139f557604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290613937903390899088908890600401614797565b602060405180830381600087803b15801561395157600080fd5b505af1925050508015613981575060408051601f3d908101601f1916820190925261397e9181019061459d565b60015b6139db573d8080156139af576040519150601f19603f3d011682016040523d82523d6000602084013e6139b4565b606091505b5080516139d35760405162461bcd60e51b8152600401610a0c906147e7565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050612da3565b506001949350505050565b6000826000018281548110613a2557634e487b7160e01b600052603260045260246000fd5b9060005260206000200154905092915050565b60606000613a47836002614967565b613a5290600261493b565b67ffffffffffffffff811115613a7857634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015613aa2576020820181803683370190505b509050600360fc1b81600081518110613acb57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110613b0857634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a9053506000613b2c846002614967565b613b3790600161493b565b90505b6001811115613bcb576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110613b7957634e487b7160e01b600052603260045260246000fd5b1a60f81b828281518110613b9d57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a90535060049490941c93613bc4816149c9565b9050613b3a565b50831561180b5760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610a0c565b6060613c2582612c36565b613c895760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b6064820152608401610a0c565b6000613ca060408051602081019091526000815290565b90506000815111613cc0576040518060200160405280600081525061180b565b80613cca84613e75565b604051602001613cdb9291906146cf565b6040516020818303038152906040529392505050565b60006001600160e01b0319821663780e9d6360e01b148061090c575061090c82613f8f565b6001600160a01b038316613d7157613d6c81600880546000838152600960205260408120829055600182018355919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155565b613d94565b816001600160a01b0316836001600160a01b031614613d9457613d948382613fdf565b6001600160a01b038216613dab57610b428161407c565b826001600160a01b0316826001600160a01b031614610b4257610b428282614155565b6000613dd98261155a565b9050613de7816000846135e5565b613df2600083612c53565b6001600160a01b0381166000908152600360205260408120805460019290613e1b908490614986565b909155505060008281526002602052604080822080546001600160a01b0319169055518391906001600160a01b038416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908390a45050565b606081613e995750506040805180820190915260018152600360fc1b602082015290565b8160005b8115613ec35780613ead81614a1b565b9150613ebc9050600a83614953565b9150613e9d565b60008167ffffffffffffffff811115613eec57634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015613f16576020820181803683370190505b5090505b8415612da357613f2b600183614986565b9150613f38600a86614a36565b613f4390603061493b565b60f81b818381518110613f6657634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350613f88600a86614953565b9450613f1a565b60006001600160e01b031982166380ac58cd60e01b1480613fc057506001600160e01b03198216635b5e139f60e01b145b8061090c57506301ffc9a760e01b6001600160e01b031983161461090c565b60006001613fec846115d1565b613ff69190614986565b600083815260076020526040902054909150808214614049576001600160a01b03841660009081526006602090815260408083208584528252808320548484528184208190558352600790915290208190555b5060009182526007602090815260408084208490556001600160a01b039094168352600681528383209183525290812055565b60085460009061408e90600190614986565b600083815260096020526040812054600880549394509092849081106140c457634e487b7160e01b600052603260045260246000fd5b9060005260206000200154905080600883815481106140f357634e487b7160e01b600052603260045260246000fd5b600091825260208083209091019290925582815260099091526040808220849055858252812055600880548061413957634e487b7160e01b600052603160045260246000fd5b6001900381819060005260206000200160009055905550505050565b6000614160836115d1565b6001600160a01b039093166000908152600660209081526040808320868452825280832085905593825260079052919091209190915550565b8280546141a5906149e0565b90600052602060002090601f0160209004810192826141c7576000855561420d565b82601f106141e057805160ff191683800117855561420d565b8280016001018555821561420d579182015b8281111561420d5782518255916020019190600101906141f2565b50614219929150614253565b5090565b508054614229906149e0565b6000825580601f10614239575050565b601f016020900490600052602060002090810190610f9791905b5b808211156142195760008155600101614254565b600067ffffffffffffffff8084111561428357614283614a76565b604051601f8501601f19908116603f011681019082821181831017156142ab576142ab614a76565b816040528093508581528686860111156142c457600080fd5b858560208301376000602087830101525050509392505050565b600082601f8301126142ee578081fd5b61180b83833560208501614268565b60006020828403121561430e578081fd5b813561180b81614a8c565b600080600080600060a08688031215614330578081fd5b853561433b81614a8c565b94506020860135935060408601359250606086013561435981614aa1565b9150608086013561436981614a8c565b809150509295509295909350565b60008060408385031215614389578182fd5b823561439481614a8c565b915060208301356143a481614a8c565b809150509250929050565b6000806000606084860312156143c3578283fd5b83356143ce81614a8c565b925060208401356143de81614a8c565b929592945050506040919091013590565b60008060008060808587031215614404578384fd5b843561440f81614a8c565b9350602085013561441f81614a8c565b925060408501359150606085013567ffffffffffffffff811115614441578182fd5b61444d878288016142de565b91505092959194509250565b6000806040838503121561446b578182fd5b823561447681614a8c565b915060208301356143a481614aa1565b60008060408385031215614498578182fd5b82356144a381614a8c565b946020939093013593505050565b6000806000606084860312156144c5578283fd5b83356144d081614a8c565b925060208401359150604084013567ffffffffffffffff8111156144f2578182fd5b6144fe868287016142de565b9150509250925092565b600060208284031215614519578081fd5b815161180b81614aa1565b600060208284031215614535578081fd5b5035919050565b6000806040838503121561454e578182fd5b8235915060208301356143a481614a8c565b60008060408385031215614572578182fd5b50508035926020909101359150565b600060208284031215614592578081fd5b813561180b81614aaf565b6000602082840312156145ae578081fd5b815161180b81614aaf565b600080604083850312156145cb578182fd5b823567ffffffffffffffff8111156145e1578283fd5b8301601f810185136145f1578283fd5b61460085823560208401614268565b92505060208301356143a481614a8c565b600080600060608486031215614625578081fd5b8335925060208401359150604084013561463e81614a8c565b809150509250925092565b6000806000806080858703121561465e578182fd5b8435935060208501359250604085013561467781614a8c565b9396929550929360600135925050565b6000815180845261469f81602086016020860161499d565b601f01601f19169290920160200192915050565b600082516146c581846020870161499d565b9190910192915050565b600083516146e181846020880161499d565b8351908301906146f581836020880161499d565b01949350505050565b7f416363657373436f6e74726f6c3a206163636f756e742000000000000000000081526000835161473681601785016020880161499d565b7001034b99036b4b9b9b4b733903937b6329607d1b601791840191820152835161476781602884016020880161499d565b01602801949350505050565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b03858116825284166020820152604081018390526080606082018190526000906147ca90830184614687565b9695505050505050565b60208152600061180b6020830184614687565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b60208082526030908201527f4d696e746572526f6c653a2063616c6c657220646f6573206e6f74206861766560408201526f20746865204d696e74657220726f6c6560801b606082015260800190565b60208082526010908201526f2a3930b739b332b9103330b4b632b21760811b604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b6000821982111561494e5761494e614a4a565b500190565b60008261496257614962614a60565b500490565b600081600019048311821515161561498157614981614a4a565b500290565b60008282101561499857614998614a4a565b500390565b60005b838110156149b85781810151838201526020016149a0565b838111156115545750506000910152565b6000816149d8576149d8614a4a565b506000190190565b600181811c908216806149f457607f821691505b60208210811415614a1557634e487b7160e01b600052602260045260246000fd5b50919050565b6000600019821415614a2f57614a2f614a4a565b5060010190565b600082614a4557614a45614a60565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0381168114610f9757600080fd5b8015158114610f9757600080fd5b6001600160e01b031981168114610f9757600080fdfe9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a6a264697066735822122098200765bd020d165e8508ee6ca87b878b55409240a5245a88af1764dd9b7e7f64736f6c63430008040033000000000000000000000000e4379a25a0db888e19ec2c14416fe68a62aca5cc000000000000000000000000e4379a25a0db888e19ec2c14416fe68a62aca5cc000000000000000000000000e4379a25a0db888e19ec2c14416fe68a62aca5cc000000000000000000000000000000000000000000000000000000000000000b000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044e4654320000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000034e46540000000000000000000000000000000000000000000000000000000000