Token Items
Overview ERC-1155
Total Supply:
174 ITMS
Holders:
761 addresses
Transfers:
-
Profile Summary
Contract:
[ Download CSV Export ]
# | Exchange | Pair | Price | 24H Volume | % Volume |
---|
Contract Source Code Verified (Exact Match)
Contract Name:
ItemsIsERC1155
Compiler Version
v0.8.17+commit.8df45f5f
Optimization Enabled:
Yes with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (access/AccessControl.sol) pragma solidity ^0.8.0; import "./IAccessControl.sol"; import "../utils/Context.sol"; import "../utils/Strings.sol"; import "../utils/introspection/ERC165.sol"; /** * @dev Contract module that allows children to implement role-based access * control mechanisms. This is a lightweight version that doesn't allow enumerating role * members except through off-chain means by accessing the contract event logs. Some * applications may benefit from on-chain enumerability, for those cases see * {AccessControlEnumerable}. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ``` * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ``` * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. */ abstract contract AccessControl is Context, IAccessControl, ERC165 { struct RoleData { mapping(address => bool) members; bytes32 adminRole; } mapping(bytes32 => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Modifier that checks that an account has a specific role. Reverts * with a standardized message including the required role. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ * * _Available since v4.1._ */ modifier onlyRole(bytes32 role) { _checkRole(role); _; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view virtual override returns (bool) { return _roles[role].members[account]; } /** * @dev Revert with a standard message if `_msgSender()` is missing `role`. * Overriding this function changes the behavior of the {onlyRole} modifier. * * Format of the revert message is described in {_checkRole}. * * _Available since v4.6._ */ function _checkRole(bytes32 role) internal view virtual { _checkRole(role, _msgSender()); } /** * @dev Revert with a standard message if `account` is missing `role`. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ */ function _checkRole(bytes32 role, address account) internal view virtual { if (!hasRole(role, account)) { revert( string( abi.encodePacked( "AccessControl: account ", Strings.toHexString(account), " is missing role ", Strings.toHexString(uint256(role), 32) ) ) ); } } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) { return _roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. * * May emit a {RoleGranted} event. */ function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. * * May emit a {RoleRevoked} event. */ function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been revoked `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. * * May emit a {RoleRevoked} event. */ function renounceRole(bytes32 role, address account) public virtual override { require(account == _msgSender(), "AccessControl: can only renounce roles for self"); _revokeRole(role, account); } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. Note that unlike {grantRole}, this function doesn't perform any * checks on the calling account. * * May emit a {RoleGranted} event. * * [WARNING] * ==== * This function should only be called from the constructor when setting * up the initial roles for the system. * * Using this function in any other way is effectively circumventing the admin * system imposed by {AccessControl}. * ==== * * NOTE: This function is deprecated in favor of {_grantRole}. */ function _setupRole(bytes32 role, address account) internal virtual { _grantRole(role, account); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { bytes32 previousAdminRole = getRoleAdmin(role); _roles[role].adminRole = adminRole; emit RoleAdminChanged(role, previousAdminRole, adminRole); } /** * @dev Grants `role` to `account`. * * Internal function without access restriction. * * May emit a {RoleGranted} event. */ function _grantRole(bytes32 role, address account) internal virtual { if (!hasRole(role, account)) { _roles[role].members[account] = true; emit RoleGranted(role, account, _msgSender()); } } /** * @dev Revokes `role` from `account`. * * Internal function without access restriction. * * May emit a {RoleRevoked} event. */ function _revokeRole(bytes32 role, address account) internal virtual { if (hasRole(role, account)) { _roles[role].members[account] = false; emit RoleRevoked(role, account, _msgSender()); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol) pragma solidity ^0.8.0; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControl { /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {AccessControl-_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) external view returns (bool); /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {AccessControl-_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) external view returns (bytes32); /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) external; /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) external; /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract Pausable is Context { /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. */ constructor() { _paused = false; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { _requireNotPaused(); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { _requirePaused(); _; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { return _paused; } /** * @dev Throws if the contract is paused. */ function _requireNotPaused() internal view virtual { require(!paused(), "Pausable: paused"); } /** * @dev Throws if the contract is not paused. */ function _requirePaused() internal view virtual { require(paused(), "Pausable: not paused"); } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (token/ERC1155/ERC1155.sol) pragma solidity ^0.8.0; import "./IERC1155.sol"; import "./IERC1155Receiver.sol"; import "./extensions/IERC1155MetadataURI.sol"; import "../../utils/Address.sol"; import "../../utils/Context.sol"; import "../../utils/introspection/ERC165.sol"; /** * @dev Implementation of the basic standard multi-token. * See https://eips.ethereum.org/EIPS/eip-1155 * Originally based on code by Enjin: https://github.com/enjin/erc-1155 * * _Available since v3.1._ */ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { using Address for address; // Mapping from token ID to account balances mapping(uint256 => mapping(address => uint256)) private _balances; // Mapping from account to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; // Used as the URI for all token types by relying on ID substitution, e.g. https://token-cdn-domain/{id}.json string private _uri; /** * @dev See {_setURI}. */ constructor(string memory uri_) { _setURI(uri_); } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC1155).interfaceId || interfaceId == type(IERC1155MetadataURI).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC1155MetadataURI-uri}. * * This implementation returns the same URI for *all* token types. It relies * on the token type ID substitution mechanism * https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP]. * * Clients calling this function must replace the `\{id\}` substring with the * actual token type ID. */ function uri(uint256) public view virtual override returns (string memory) { return _uri; } /** * @dev See {IERC1155-balanceOf}. * * Requirements: * * - `account` cannot be the zero address. */ function balanceOf(address account, uint256 id) public view virtual override returns (uint256) { require(account != address(0), "ERC1155: address zero is not a valid owner"); return _balances[id][account]; } /** * @dev See {IERC1155-balanceOfBatch}. * * Requirements: * * - `accounts` and `ids` must have the same length. */ function balanceOfBatch(address[] memory accounts, uint256[] memory ids) public view virtual override returns (uint256[] memory) { require(accounts.length == ids.length, "ERC1155: accounts and ids length mismatch"); uint256[] memory batchBalances = new uint256[](accounts.length); for (uint256 i = 0; i < accounts.length; ++i) { batchBalances[i] = balanceOf(accounts[i], ids[i]); } return batchBalances; } /** * @dev See {IERC1155-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC1155-isApprovedForAll}. */ function isApprovedForAll(address account, address operator) public view virtual override returns (bool) { return _operatorApprovals[account][operator]; } /** * @dev See {IERC1155-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 id, uint256 amount, bytes memory data ) public virtual override { require( from == _msgSender() || isApprovedForAll(from, _msgSender()), "ERC1155: caller is not token owner or approved" ); _safeTransferFrom(from, to, id, amount, data); } /** * @dev See {IERC1155-safeBatchTransferFrom}. */ function safeBatchTransferFrom( address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) public virtual override { require( from == _msgSender() || isApprovedForAll(from, _msgSender()), "ERC1155: caller is not token owner or approved" ); _safeBatchTransferFrom(from, to, ids, amounts, data); } /** * @dev Transfers `amount` tokens of token type `id` from `from` to `to`. * * Emits a {TransferSingle} event. * * Requirements: * * - `to` cannot be the zero address. * - `from` must have a balance of tokens of type `id` of at least `amount`. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function _safeTransferFrom( address from, address to, uint256 id, uint256 amount, bytes memory data ) internal virtual { require(to != address(0), "ERC1155: transfer to the zero address"); address operator = _msgSender(); uint256[] memory ids = _asSingletonArray(id); uint256[] memory amounts = _asSingletonArray(amount); _beforeTokenTransfer(operator, from, to, ids, amounts, data); uint256 fromBalance = _balances[id][from]; require(fromBalance >= amount, "ERC1155: insufficient balance for transfer"); unchecked { _balances[id][from] = fromBalance - amount; } _balances[id][to] += amount; emit TransferSingle(operator, from, to, id, amount); _afterTokenTransfer(operator, from, to, ids, amounts, data); _doSafeTransferAcceptanceCheck(operator, from, to, id, amount, data); } /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_safeTransferFrom}. * * Emits a {TransferBatch} event. * * Requirements: * * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. */ function _safeBatchTransferFrom( address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual { require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch"); require(to != address(0), "ERC1155: transfer to the zero address"); address operator = _msgSender(); _beforeTokenTransfer(operator, from, to, ids, amounts, data); for (uint256 i = 0; i < ids.length; ++i) { uint256 id = ids[i]; uint256 amount = amounts[i]; uint256 fromBalance = _balances[id][from]; require(fromBalance >= amount, "ERC1155: insufficient balance for transfer"); unchecked { _balances[id][from] = fromBalance - amount; } _balances[id][to] += amount; } emit TransferBatch(operator, from, to, ids, amounts); _afterTokenTransfer(operator, from, to, ids, amounts, data); _doSafeBatchTransferAcceptanceCheck(operator, from, to, ids, amounts, data); } /** * @dev Sets a new URI for all token types, by relying on the token type ID * substitution mechanism * https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP]. * * By this mechanism, any occurrence of the `\{id\}` substring in either the * URI or any of the amounts in the JSON file at said URI will be replaced by * clients with the token type ID. * * For example, the `https://token-cdn-domain/\{id\}.json` URI would be * interpreted by clients as * `https://token-cdn-domain/000000000000000000000000000000000000000000000000000000000004cce0.json` * for token type ID 0x4cce0. * * See {uri}. * * Because these URIs cannot be meaningfully represented by the {URI} event, * this function emits no events. */ function _setURI(string memory newuri) internal virtual { _uri = newuri; } /** * @dev Creates `amount` tokens of token type `id`, and assigns them to `to`. * * Emits a {TransferSingle} event. * * Requirements: * * - `to` cannot be the zero address. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function _mint( address to, uint256 id, uint256 amount, bytes memory data ) internal virtual { require(to != address(0), "ERC1155: mint to the zero address"); address operator = _msgSender(); uint256[] memory ids = _asSingletonArray(id); uint256[] memory amounts = _asSingletonArray(amount); _beforeTokenTransfer(operator, address(0), to, ids, amounts, data); _balances[id][to] += amount; emit TransferSingle(operator, address(0), to, id, amount); _afterTokenTransfer(operator, address(0), to, ids, amounts, data); _doSafeTransferAcceptanceCheck(operator, address(0), to, id, amount, data); } /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_mint}. * * Emits a {TransferBatch} event. * * Requirements: * * - `ids` and `amounts` must have the same length. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. */ function _mintBatch( address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual { require(to != address(0), "ERC1155: mint to the zero address"); require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch"); address operator = _msgSender(); _beforeTokenTransfer(operator, address(0), to, ids, amounts, data); for (uint256 i = 0; i < ids.length; i++) { _balances[ids[i]][to] += amounts[i]; } emit TransferBatch(operator, address(0), to, ids, amounts); _afterTokenTransfer(operator, address(0), to, ids, amounts, data); _doSafeBatchTransferAcceptanceCheck(operator, address(0), to, ids, amounts, data); } /** * @dev Destroys `amount` tokens of token type `id` from `from` * * Emits a {TransferSingle} event. * * Requirements: * * - `from` cannot be the zero address. * - `from` must have at least `amount` tokens of token type `id`. */ function _burn( address from, uint256 id, uint256 amount ) internal virtual { require(from != address(0), "ERC1155: burn from the zero address"); address operator = _msgSender(); uint256[] memory ids = _asSingletonArray(id); uint256[] memory amounts = _asSingletonArray(amount); _beforeTokenTransfer(operator, from, address(0), ids, amounts, ""); uint256 fromBalance = _balances[id][from]; require(fromBalance >= amount, "ERC1155: burn amount exceeds balance"); unchecked { _balances[id][from] = fromBalance - amount; } emit TransferSingle(operator, from, address(0), id, amount); _afterTokenTransfer(operator, from, address(0), ids, amounts, ""); } /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_burn}. * * Emits a {TransferBatch} event. * * Requirements: * * - `ids` and `amounts` must have the same length. */ function _burnBatch( address from, uint256[] memory ids, uint256[] memory amounts ) internal virtual { require(from != address(0), "ERC1155: burn from the zero address"); require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch"); address operator = _msgSender(); _beforeTokenTransfer(operator, from, address(0), ids, amounts, ""); for (uint256 i = 0; i < ids.length; i++) { uint256 id = ids[i]; uint256 amount = amounts[i]; uint256 fromBalance = _balances[id][from]; require(fromBalance >= amount, "ERC1155: burn amount exceeds balance"); unchecked { _balances[id][from] = fromBalance - amount; } } emit TransferBatch(operator, from, address(0), ids, amounts); _afterTokenTransfer(operator, from, address(0), ids, amounts, ""); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits an {ApprovalForAll} event. */ function _setApprovalForAll( address owner, address operator, bool approved ) internal virtual { require(owner != operator, "ERC1155: setting approval status for self"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Hook that is called before any token transfer. This includes minting * and burning, as well as batched variants. * * The same hook is called on both single and batched variants. For single * transfers, the length of the `ids` and `amounts` arrays will be 1. * * Calling conditions (for each `id` and `amount` pair): * * - When `from` and `to` are both non-zero, `amount` of ``from``'s tokens * of token type `id` will be transferred to `to`. * - When `from` is zero, `amount` tokens of token type `id` will be minted * for `to`. * - when `to` is zero, `amount` of ``from``'s tokens of token type `id` * will be burned. * - `from` and `to` are never both zero. * - `ids` and `amounts` have the same, non-zero length. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual {} /** * @dev Hook that is called after any token transfer. This includes minting * and burning, as well as batched variants. * * The same hook is called on both single and batched variants. For single * transfers, the length of the `id` and `amount` arrays will be 1. * * Calling conditions (for each `id` and `amount` pair): * * - When `from` and `to` are both non-zero, `amount` of ``from``'s tokens * of token type `id` will be transferred to `to`. * - When `from` is zero, `amount` tokens of token type `id` will be minted * for `to`. * - when `to` is zero, `amount` of ``from``'s tokens of token type `id` * will be burned. * - `from` and `to` are never both zero. * - `ids` and `amounts` have the same, non-zero length. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual {} function _doSafeTransferAcceptanceCheck( address operator, address from, address to, uint256 id, uint256 amount, bytes memory data ) private { if (to.isContract()) { try IERC1155Receiver(to).onERC1155Received(operator, from, id, amount, data) returns (bytes4 response) { if (response != IERC1155Receiver.onERC1155Received.selector) { revert("ERC1155: ERC1155Receiver rejected tokens"); } } catch Error(string memory reason) { revert(reason); } catch { revert("ERC1155: transfer to non-ERC1155Receiver implementer"); } } } function _doSafeBatchTransferAcceptanceCheck( address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) private { if (to.isContract()) { try IERC1155Receiver(to).onERC1155BatchReceived(operator, from, ids, amounts, data) returns ( bytes4 response ) { if (response != IERC1155Receiver.onERC1155BatchReceived.selector) { revert("ERC1155: ERC1155Receiver rejected tokens"); } } catch Error(string memory reason) { revert(reason); } catch { revert("ERC1155: transfer to non-ERC1155Receiver implementer"); } } } function _asSingletonArray(uint256 element) private pure returns (uint256[] memory) { uint256[] memory array = new uint256[](1); array[0] = element; return array; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC1155/extensions/ERC1155Pausable.sol) pragma solidity ^0.8.0; import "../ERC1155.sol"; import "../../../security/Pausable.sol"; /** * @dev ERC1155 token with pausable token transfers, minting and burning. * * Useful for scenarios such as preventing trades until the end of an evaluation * period, or having an emergency switch for freezing all token transfers in the * event of a large bug. * * _Available since v3.1._ */ abstract contract ERC1155Pausable is ERC1155, Pausable { /** * @dev See {ERC1155-_beforeTokenTransfer}. * * Requirements: * * - the contract must not be paused. */ function _beforeTokenTransfer( address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual override { super._beforeTokenTransfer(operator, from, to, ids, amounts, data); require(!paused(), "ERC1155Pausable: token transfer while paused"); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC1155/extensions/IERC1155MetadataURI.sol) pragma solidity ^0.8.0; import "../IERC1155.sol"; /** * @dev Interface of the optional ERC1155MetadataExtension interface, as defined * in the https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[EIP]. * * _Available since v3.1._ */ interface IERC1155MetadataURI is IERC1155 { /** * @dev Returns the URI for token type `id`. * * If the `\{id\}` substring is present in the URI, it must be replaced by * clients with the actual token type ID. */ function uri(uint256 id) external view returns (string memory); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (token/ERC1155/IERC1155.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC1155 compliant contract, as defined in the * https://eips.ethereum.org/EIPS/eip-1155[EIP]. * * _Available since v3.1._ */ interface IERC1155 is IERC165 { /** * @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`. */ event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value); /** * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all * transfers. */ event TransferBatch( address indexed operator, address indexed from, address indexed to, uint256[] ids, uint256[] values ); /** * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to * `approved`. */ event ApprovalForAll(address indexed account, address indexed operator, bool approved); /** * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI. * * If an {URI} event was emitted for `id`, the standard * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value * returned by {IERC1155MetadataURI-uri}. */ event URI(string value, uint256 indexed id); /** * @dev Returns the amount of tokens of token type `id` owned by `account`. * * Requirements: * * - `account` cannot be the zero address. */ function balanceOf(address account, uint256 id) external view returns (uint256); /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}. * * Requirements: * * - `accounts` and `ids` must have the same length. */ function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids) external view returns (uint256[] memory); /** * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`, * * Emits an {ApprovalForAll} event. * * Requirements: * * - `operator` cannot be the caller. */ function setApprovalForAll(address operator, bool approved) external; /** * @dev Returns true if `operator` is approved to transfer ``account``'s tokens. * * See {setApprovalForAll}. */ function isApprovedForAll(address account, address operator) external view returns (bool); /** * @dev Transfers `amount` tokens of token type `id` from `from` to `to`. * * Emits a {TransferSingle} event. * * Requirements: * * - `to` cannot be the zero address. * - If the caller is not `from`, it must have been approved to spend ``from``'s tokens via {setApprovalForAll}. * - `from` must have a balance of tokens of type `id` of at least `amount`. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function safeTransferFrom( address from, address to, uint256 id, uint256 amount, bytes calldata data ) external; /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}. * * Emits a {TransferBatch} event. * * Requirements: * * - `ids` and `amounts` must have the same length. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. */ function safeBatchTransferFrom( address from, address to, uint256[] calldata ids, uint256[] calldata amounts, bytes calldata data ) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC1155/IERC1155Receiver.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev _Available since v3.1._ */ interface IERC1155Receiver is IERC165 { /** * @dev Handles the receipt of a single ERC1155 token type. This function is * called at the end of a `safeTransferFrom` after the balance has been updated. * * NOTE: To accept the transfer, this must return * `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` * (i.e. 0xf23a6e61, or its own function selector). * * @param operator The address which initiated the transfer (i.e. msg.sender) * @param from The address which previously owned the token * @param id The ID of the token being transferred * @param value The amount of tokens being transferred * @param data Additional data with no specified format * @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed */ function onERC1155Received( address operator, address from, uint256 id, uint256 value, bytes calldata data ) external returns (bytes4); /** * @dev Handles the receipt of a multiple ERC1155 token types. This function * is called at the end of a `safeBatchTransferFrom` after the balances have * been updated. * * NOTE: To accept the transfer(s), this must return * `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` * (i.e. 0xbc197c81, or its own function selector). * * @param operator The address which initiated the batch transfer (i.e. msg.sender) * @param from The address which previously owned the token * @param ids An array containing ids of each token being transferred (order and length must match values array) * @param values An array containing amounts of each token being transferred (order and length must match ids array) * @param data Additional data with no specified format * @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed */ function onERC1155BatchReceived( address operator, address from, uint256[] calldata ids, uint256[] calldata values, bytes calldata data ) external returns (bytes4); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 amount ) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, "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"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, 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) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, 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) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract. * * _Available since v4.8._ */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata, string memory errorMessage ) internal view returns (bytes memory) { if (success) { if (returndata.length == 0) { // only check isContract if the call was successful and the return data is empty // otherwise we already know that it was a contract require(isContract(target), "Address: call to non-contract"); } return returndata; } else { _revert(returndata, errorMessage); } } /** * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason or 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 { _revert(returndata, errorMessage); } } function _revert(bytes memory returndata, string memory errorMessage) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Counters.sol) pragma solidity ^0.8.0; /** * @title Counters * @author Matt Condon (@shrugs) * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number * of elements in a mapping, issuing ERC721 ids, or counting request ids. * * Include with `using Counters for Counters.Counter;` */ library Counters { struct Counter { // This variable should never be directly accessed by users of the library: interactions must be restricted to // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add // this feature: see https://github.com/ethereum/solidity/issues/4637 uint256 _value; // default: 0 } function current(Counter storage counter) internal view returns (uint256) { return counter._value; } function increment(Counter storage counter) internal { unchecked { counter._value += 1; } } function decrement(Counter storage counter) internal { uint256 value = counter._value; require(value > 0, "Counter: decrement overflow"); unchecked { counter._value = value - 1; } } function reset(Counter storage counter) internal { counter._value = 0; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol) pragma solidity ^0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { enum Rounding { Down, // Toward negative infinity Up, // Toward infinity Zero // Toward zero } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a > b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds up instead * of rounding down. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b - 1) / b can overflow on addition, so we distribute. return a == 0 ? 0 : (a - 1) / b + 1; } /** * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) * with further edits by Uniswap Labs also under MIT license. */ function mulDiv( uint256 x, uint256 y, uint256 denominator ) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2^256 + prod0. uint256 prod0; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod0 := mul(x, y) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. require(denominator > prod1); /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. uint256 remainder; assembly { // Compute remainder using mulmod. remainder := mulmod(x, y, denominator) // Subtract 256 bit number from 512 bit number. prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1. // See https://cs.stackexchange.com/q/138556/92363. // Does not overflow because the denominator cannot be zero at this stage in the function. uint256 twos = denominator & (~denominator + 1); assembly { // Divide denominator by twos. denominator := div(denominator, twos) // Divide [prod1 prod0] by twos. prod0 := div(prod0, twos) // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one. twos := add(div(sub(0, twos), twos), 1) } // Shift in bits from prod1 into prod0. prod0 |= prod1 * twos; // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv = 1 mod 2^4. uint256 inverse = (3 * denominator) ^ 2; // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works // in modular arithmetic, doubling the correct bits in each step. inverse *= 2 - denominator * inverse; // inverse mod 2^8 inverse *= 2 - denominator * inverse; // inverse mod 2^16 inverse *= 2 - denominator * inverse; // inverse mod 2^32 inverse *= 2 - denominator * inverse; // inverse mod 2^64 inverse *= 2 - denominator * inverse; // inverse mod 2^128 inverse *= 2 - denominator * inverse; // inverse mod 2^256 // Because the division is now exact we can divide by multiplying with the modular inverse of denominator. // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inverse; return result; } } /** * @notice Calculates x * y / denominator with full precision, following the selected rounding direction. */ function mulDiv( uint256 x, uint256 y, uint256 denominator, Rounding rounding ) internal pure returns (uint256) { uint256 result = mulDiv(x, y, denominator); if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) { result += 1; } return result; } /** * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down. * * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11). */ function sqrt(uint256 a) internal pure returns (uint256) { if (a == 0) { return 0; } // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target. // // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`. // // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)` // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))` // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)` // // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit. uint256 result = 1 << (log2(a) >> 1); // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128, // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision // into the expected uint128 result. unchecked { result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; return min(result, a / result); } } /** * @notice Calculates sqrt(a), following the selected rounding direction. */ function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = sqrt(a); return result + (rounding == Rounding.Up && result * result < a ? 1 : 0); } } /** * @dev Return the log in base 2, rounded down, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 128; } if (value >> 64 > 0) { value >>= 64; result += 64; } if (value >> 32 > 0) { value >>= 32; result += 32; } if (value >> 16 > 0) { value >>= 16; result += 16; } if (value >> 8 > 0) { value >>= 8; result += 8; } if (value >> 4 > 0) { value >>= 4; result += 4; } if (value >> 2 > 0) { value >>= 2; result += 2; } if (value >> 1 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 2, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log2(value); return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0); } } /** * @dev Return the log in base 10, rounded down, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >= 10**64) { value /= 10**64; result += 64; } if (value >= 10**32) { value /= 10**32; result += 32; } if (value >= 10**16) { value /= 10**16; result += 16; } if (value >= 10**8) { value /= 10**8; result += 8; } if (value >= 10**4) { value /= 10**4; result += 4; } if (value >= 10**2) { value /= 10**2; result += 2; } if (value >= 10**1) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log10(value); return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0); } } /** * @dev Return the log in base 256, rounded down, of a positive value. * Returns 0 if given 0. * * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string. */ function log256(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 16; } if (value >> 64 > 0) { value >>= 64; result += 8; } if (value >> 32 > 0) { value >>= 32; result += 4; } if (value >> 16 > 0) { value >>= 16; result += 2; } if (value >> 8 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log256(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log256(value); return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol) pragma solidity ^0.8.0; import "./math/Math.sol"; /** * @dev String operations. */ library Strings { bytes16 private constant _SYMBOLS = "0123456789abcdef"; uint8 private constant _ADDRESS_LENGTH = 20; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { unchecked { uint256 length = Math.log10(value) + 1; string memory buffer = new string(length); uint256 ptr; /// @solidity memory-safe-assembly assembly { ptr := add(buffer, add(32, length)) } while (true) { ptr--; /// @solidity memory-safe-assembly assembly { mstore8(ptr, byte(mod(value, 10), _SYMBOLS)) } value /= 10; if (value == 0) break; } return buffer; } } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { unchecked { return toHexString(value, Math.log256(value) + 1); } } /** * @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] = _SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } /** * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation. */ function toHexString(address addr) internal pure returns (string memory) { return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.17; import "@openzeppelin/contracts/token/ERC1155/IERC1155.sol"; interface IItemsIsERC1155 is IERC1155{ function ADMIN_CREATOR ( ) external view returns ( bytes32 ); function ADMIN_MINTER ( ) external view returns ( bytes32 ); function CREATOR ( ) external view returns ( bytes32 ); function MINTER ( ) external view returns ( bytes32 ); function getTokenAddress ( ) external view returns ( address ); function getMaxSupplyById ( uint256 ) external view returns ( uint256 ); function addAdmin ( address ) external; function addAdminCreator ( address ) external; function addAdminMinter ( address ) external; function addCreator ( address ) external; function addItemSupply ( uint256, uint256 ) external; function addMinter ( address ) external; function adminMint ( address, uint256, uint256 ) external; function airdropItems ( address[] memory, uint256[] memory, uint256[] memory ) external; function batchAddItemSupply ( uint256[] memory, uint256[] memory ) external; function batchPurchaseItem ( uint256[] memory, uint256[] memory ) external; function batchCreateItem ( string[] memory, string[] memory, string[] memory, uint256[] memory, uint256[] memory, uint256[] memory, uint256[] memory ) external; function batchRemoveItemSupply ( uint256[] memory, uint256[] memory ) external; function batchUpdateItem ( uint256[] memory, string[] memory, string[] memory, string[] memory, uint256[] memory, uint256[] memory, uint256[] memory, uint256[] memory ) external; function purchaseItem ( uint256, uint256 ) external; function createItem ( string memory, string memory, string memory, uint256, uint256, uint256, uint256 ) external; function itemById ( uint256 ) external view returns ( uint256, string memory, string memory, string memory, uint256, uint256, uint256, uint256, uint256 ); function mintedItemsByUser ( address, uint256 ) external view returns ( uint256 ); function pause ( ) external; function removeItemSupply ( uint256, uint256 ) external; function revokeAdminCreator ( address ) external; function revokeAdminMinter ( address ) external; function revokeCreator ( address ) external; function revokeMinter ( address ) external; function unpause ( ) external; function updateItem ( uint256, string memory, string memory, string memory, uint256, uint256, uint256, uint256 ) external; function getItemPrice ( uint256 ) external view returns ( uint256 ); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.17; import "@openzeppelin/contracts/token/ERC1155/extensions/ERC1155Pausable.sol"; import "@openzeppelin/contracts/access/AccessControl.sol"; import "@openzeppelin/contracts/utils/Counters.sol"; import "../Token/ITokenIsERC20.sol"; import "./IItemsIsERC1155.sol"; contract ItemsIsERC1155 is IItemsIsERC1155, ERC1155Pausable, AccessControl { string public constant name = "Items"; string public constant symbol = "ITMS"; using Counters for Counters.Counter; Counters.Counter private _idIncrementer; ITokenIsERC20 Token; bytes32 public constant CREATOR = keccak256("CREATOR"); bytes32 public constant ADMIN_CREATOR = keccak256("ADMIN_CREATOR"); bytes32 public constant MINTER = keccak256("MINTER"); bytes32 public constant ADMIN_MINTER = keccak256("ADMIN_MINTER"); struct Item { uint256 id; string name; string description; string uri; uint256 questId; // 0 if not a quest item uint256 price; uint256 maxSupply; uint256 currentSupply; uint256 maxByUser; } mapping(uint256 => Item) public itemById; mapping(address => mapping(uint256 => uint256)) public mintedItemsByUser; mapping(address => bool) public unlimitedAllowance; event NewAdmin(address indexed grantedBy, address indexed newAdmin); event NewAdminMinter(address indexed grantedBy, address indexed newAdminMinter); event NewMinter(address indexed grantedBy, address indexed newMinter); event NewAdminCreator(address indexed grantedBy, address indexed newAdminCreator); event NewCreator(address indexed grantedBy, address indexed newCreator); event RevokedAdmin(address indexed revokedBy, address indexed revokedAdmin); event RevokedAdminMinter(address indexed revokedBy, address indexed revokedAdminMinter); event RevokedMinter(address indexed revokedBy, address indexed revokedMinter); event RevokedAdminCreator(address indexed revokedBy, address indexed revokedAdminCreator); event RevokedCreator(address indexed revokedBy, address indexed revokedCreator); event NewItem(address indexed creator, uint256 indexed id, string name, string description, string uri, uint256 questId, uint256 price, uint256 maxSupply, uint256 maxByUser); event ItemSupplyAdded(address indexed creator, uint256 indexed id, uint256 amount); event ItemSupplyRemoved(address indexed creator, uint256 indexed id, uint256 amount); event ItemUpdated(address indexed creator, uint256 indexed id, string name, string description, string uri, uint256 questId, uint256 price, uint256 maxSupply, uint256 maxByUser); event ItemPurchased(address indexed from, uint256 indexed id, uint256 amount); event NewDrop(address indexed from, address indexed to, uint256 indexed id, uint256 amount); constructor(ITokenIsERC20 _tokenAddress) ERC1155("") { Token = _tokenAddress; _setupRole(DEFAULT_ADMIN_ROLE, msg.sender); emit NewAdmin(address(0), msg.sender); _setupRole(ADMIN_MINTER, msg.sender); emit NewAdminMinter(address(0), msg.sender); _setupRole(MINTER, msg.sender); emit NewMinter(address(0), msg.sender); _setupRole(ADMIN_CREATOR, msg.sender); emit NewAdminCreator(address(0), msg.sender); _setupRole(CREATOR, msg.sender); emit NewCreator(address(0), msg.sender); _setRoleAdmin(MINTER, ADMIN_MINTER); _setRoleAdmin(CREATOR, ADMIN_CREATOR); } /* ********************************** */ /* Modifiers */ /* ********************************** */ modifier onlyAdmin() { require(hasRole(DEFAULT_ADMIN_ROLE, msg.sender), "Only admin can call this function"); _; } modifier onlyAdminMinter() { require(hasRole(ADMIN_MINTER, msg.sender), "Only 'ADMIN_MINTER' can call this function"); _; } modifier onlyMinter() { require(hasRole(MINTER, msg.sender), "Only 'MINTER' can call this function"); _; } modifier onlyAdminCreator() { require(hasRole(ADMIN_CREATOR, msg.sender), "Only 'ADMIN_CREATOR' can call this function"); _; } modifier onlyCreator() { require(hasRole(CREATOR, msg.sender), "Only 'CREATOR' can call this function"); _; } modifier itemShouldExist(uint _itemId) { require(keccak256(abi.encodePacked(itemById[_itemId].name)) != keccak256(abi.encodePacked("")), "Item does not exist"); _; } /* ********************************** */ /* Items */ /* ********************************** */ function createItem(string memory _name, string memory _description, string memory _uri, uint256 _questId, uint256 _price, uint256 _maxSupply, uint256 _maxByUser) public onlyCreator { require(keccak256(abi.encodePacked(_name)) != keccak256(abi.encodePacked("")), "Name cannot be empty"); uint256 newItemId = _idIncrementer.current(); itemById[newItemId] = Item(newItemId, _name, _description, _uri, _questId, _price, _maxSupply, 0, _maxByUser); emit NewItem(msg.sender, newItemId, _name, _description, _uri, _questId, _price, _maxSupply, _maxByUser); _idIncrementer.increment(); } function batchCreateItem(string[] memory _names, string[] memory _descriptions, string[] memory _uris, uint256[] memory _questIds, uint256[] memory _prices, uint256[] memory _maxSupplies, uint256[] memory _maxByUsers) public onlyCreator { require(_names.length == _descriptions.length && _names.length == _uris.length && _questIds.length == _names.length && _names.length == _prices.length && _names.length == _maxSupplies.length && _names.length == _maxByUsers.length, "Arrays must have the same length"); for (uint i = 0; i < _names.length; i++) { createItem(_names[i], _descriptions[i], _uris[i], _questIds[i], _prices[i], _maxSupplies[i], _maxByUsers[i]); } } function updateItem(uint256 _itemId, string memory _name, string memory _description, string memory _uri, uint256 _questId, uint256 _price, uint256 _maxSupply, uint256 _maxByUser) public onlyCreator itemShouldExist(_itemId) { require(_maxSupply >= itemById[_itemId].currentSupply, "Max supply must be greater than current supply"); itemById[_itemId].name = _name; itemById[_itemId].description = _description; itemById[_itemId].uri = _uri; itemById[_itemId].questId = _questId; itemById[_itemId].price = _price; itemById[_itemId].maxSupply = _maxSupply; itemById[_itemId].maxByUser = _maxByUser; emit ItemUpdated(msg.sender, _itemId, _name, _description, _uri, _questId, _price, _maxSupply, _maxByUser); } function batchUpdateItem(uint256[] memory _itemIds, string[] memory _names, string[] memory _descriptions, string[] memory _uris, uint256[] memory _questIds, uint256[] memory _prices, uint256[] memory _maxSupplies, uint256[] memory _maxByUsers) public onlyCreator { require(_itemIds.length == _names.length && _itemIds.length == _descriptions.length && _itemIds.length == _uris.length && _itemIds.length == _questIds.length && _itemIds.length == _prices.length && _itemIds.length == _maxSupplies.length && _itemIds.length == _maxByUsers.length, "Arrays must have the same length"); for (uint i = 0; i < _itemIds.length; i++) { updateItem(_itemIds[i], _names[i], _descriptions[i], _uris[i], _questIds[i], _prices[i], _maxSupplies[i], _maxByUsers[i]); } } function addItemSupply(uint256 _itemId, uint256 _amount) public onlyCreator itemShouldExist(_itemId) { itemById[_itemId].maxSupply += _amount; emit ItemSupplyAdded(msg.sender, _itemId, _amount); } function batchAddItemSupply(uint256[] memory _itemIds, uint256[] memory _amounts) public onlyCreator { require(_itemIds.length == _amounts.length, "Arrays must have the same length"); for (uint i = 0; i < _itemIds.length; i++) { addItemSupply(_itemIds[i], _amounts[i]); } } function removeItemSupply(uint256 _itemId, uint256 _amount) public onlyCreator itemShouldExist(_itemId) { require(itemById[_itemId].maxSupply >= _amount, "Cannot remove more supply than available"); require(itemById[_itemId].currentSupply <= itemById[_itemId].maxSupply - _amount, "Cannot remove more supply already minted"); itemById[_itemId].maxSupply -= _amount; emit ItemSupplyRemoved(msg.sender, _itemId, _amount); } function batchRemoveItemSupply(uint256[] memory _itemIds, uint256[] memory _amounts) public onlyCreator { require(_itemIds.length == _amounts.length, "Arrays must have the same length"); for (uint i = 0; i < _itemIds.length; i++) { removeItemSupply(_itemIds[i], _amounts[i]); } } function airdropItems(address[] memory _to, uint256[] memory _itemId, uint256[] memory _amount) public onlyMinter { require(_to.length == _itemId.length && _to.length == _amount.length, "Arrays must have same length"); for (uint256 i = 0; i < _to.length; i++) { require(keccak256(abi.encodePacked(itemById[_itemId[i]].name)) != keccak256(abi.encodePacked("")), "Item does not exist"); require(itemById[_itemId[i]].currentSupply + _amount[i] <= itemById[_itemId[i]].maxSupply, "No items available"); itemById[_itemId[i]].currentSupply += _amount[i]; mintedItemsByUser[_to[i]][_itemId[i]] += _amount[i]; _mint(_to[i], _itemId[i], _amount[i], ""); emit NewDrop(msg.sender, _to[i], _itemId[i], _amount[i]); } } function adminMint(address _to, uint256 _itemId, uint256 _amount) public onlyMinter itemShouldExist(_itemId) { require(itemById[_itemId].currentSupply + _amount <= itemById[_itemId].maxSupply, "No items available"); itemById[_itemId].currentSupply += _amount; mintedItemsByUser[_to][_itemId] += _amount; _mint(_to, _itemId, _amount, ""); emit NewDrop(msg.sender, _to, _itemId, _amount); } function purchaseItem(uint256 _itemId, uint256 _amount) public itemShouldExist(_itemId) { require(itemById[_itemId].currentSupply + _amount <= itemById[_itemId].maxSupply, "No items available"); require(mintedItemsByUser[msg.sender][_itemId] + _amount <= itemById[_itemId].maxByUser, "Cannot buy more than max by user"); if (itemById[_itemId].price > 0) { require(Token.balanceOf(msg.sender) >= itemById[_itemId].price * _amount, "Not enough token to purchase"); Token.transferFrom(msg.sender, address(this), itemById[_itemId].price * _amount); } itemById[_itemId].currentSupply += _amount; mintedItemsByUser[msg.sender][_itemId] += _amount; _mint(msg.sender, _itemId, _amount, ""); emit ItemPurchased(msg.sender, _itemId, _amount); } function batchPurchaseItem(uint256[] memory _itemIds, uint256[] memory _amounts) public { require(_itemIds.length == _amounts.length, "Arrays must have the same length"); for (uint i = 0; i < _itemIds.length; i++) { purchaseItem(_itemIds[i], _amounts[i]); } } /* ********************************** */ /* Add role */ /* ********************************** */ /* * @dev see {IItemsIsERC1155-addAdmin} */ function addAdmin(address _address) external onlyAdmin whenNotPaused { _setupRole(DEFAULT_ADMIN_ROLE, _address); emit NewAdmin(msg.sender, _address); } /* * @dev see {IItemsIsERC1155-addAdminCreator} */ function addAdminCreator(address _address) external onlyAdmin whenNotPaused { _setupRole(CREATOR, _address); emit NewAdminCreator(msg.sender, _address); } /* * @dev see {IItemsIsERC1155-addCreator} */ function addCreator(address _address) external onlyAdminCreator whenNotPaused { _setupRole(CREATOR, _address); emit NewCreator(msg.sender, _address); } /* * @dev see {IItemsIsERC1155-addAdminMinter} */ function addAdminMinter(address _address) public onlyAdmin whenNotPaused { _grantRole(ADMIN_MINTER, _address); emit NewAdminMinter(msg.sender, _address); } /* * @dev see {IItemsIsERC1155-addMinter} */ function addMinter(address _address) external onlyAdminMinter whenNotPaused { _grantRole(MINTER, _address); emit NewMinter(msg.sender, _address); } /* ********************************** */ /* Revoke role */ /* ********************************** */ /* * @dev see {IItemsIsERC1155-revokeAdminMinter} */ function revokeAdminMinter(address _address) external onlyAdmin whenNotPaused { require(hasRole(ADMIN_MINTER, _address) == true, "Address does not have admin role"); _revokeRole(ADMIN_MINTER, _address); emit RevokedAdminMinter(msg.sender, _address); } /* * @dev see {IItemsIsERC1155-revokeMinter} */ function revokeMinter(address _address) external onlyAdminMinter whenNotPaused { _revokeRole(MINTER, _address); emit RevokedMinter(msg.sender, _address); } /* * @dev see {IItemsIsERC1155-revokeAdminCreator} */ function revokeAdminCreator(address _address) external onlyAdmin whenNotPaused { _revokeRole(ADMIN_CREATOR, _address); emit RevokedAdminCreator(msg.sender, _address); } /* * @dev see {IItemsIsERC1155-revokeCreator} */ function revokeCreator(address _address) external onlyAdminCreator whenNotPaused { _revokeRole(CREATOR, _address); emit RevokedCreator(msg.sender, _address); } /* ********************************** */ /* Views */ /* ********************************** */ function getTokenAddress() external view returns (address) { return address(Token); } function getItemPrice(uint256 _itemId) external view itemShouldExist(_itemId) returns (uint256) { return itemById[_itemId].price; } function getWalletItems(address _address) external view returns (uint256[] memory) { uint itemsCount = _idIncrementer.current(); uint[] memory tmpList = new uint[](itemsCount); uint userItemsCount = 0; for (uint i = 0; i < itemsCount; i++) { if (balanceOf(_address, i) > 0) { tmpList[userItemsCount] = i; userItemsCount++; } } uint[] memory itemsList = new uint[](userItemsCount); for (uint i = 0; i < userItemsCount; i++) { itemsList[i] = tmpList[i]; } return itemsList; } function getWalletItemsBalance(address _address) external view returns (uint256[] memory) { uint itemsCount = _idIncrementer.current(); uint[] memory tmpList = new uint[](itemsCount); uint userItemsCount = 0; for (uint i = 0; i < itemsCount; i++) { if (balanceOf(_address, i) > 0) { tmpList[userItemsCount] = balanceOf(_address, i); userItemsCount++; } } uint[] memory itemsList = new uint[](userItemsCount); for (uint i = 0; i < userItemsCount; i++) { itemsList[i] = tmpList[i]; } return itemsList; } function uri(uint _itemId) public view override returns (string memory) { return itemById[_itemId].uri; } function totalSupply() public view returns (uint256) { return _idIncrementer.current(); } function getMaxSupplyById(uint _itemId) external view returns (uint256) { return itemById[_itemId].maxSupply; } /* ********************************** */ /* Burnable */ /* ********************************** */ /* * @dev see {ITokenIsERC20-adminBurn} */ function adminBurn(address account, uint256 id, uint256 value) external onlyAdminMinter whenNotPaused { _burn(account, id, value); } /* * @dev see {ITokenIsERC20-adminBurnBatch} */ function adminBurnBatch(address account, uint256[] memory ids, uint256[] memory values) external onlyAdminMinter whenNotPaused { _burnBatch(account, ids, values); } function burn(address account, uint256 id, uint256 value) public virtual whenNotPaused { require( account == _msgSender() || isApprovedForAll(account, _msgSender()), "ERC1155: caller is not token owner or approved" ); _burn(account, id, value); } function burnBatch(address account, uint256[] memory ids, uint256[] memory values) public virtual whenNotPaused { require( account == _msgSender() || isApprovedForAll(account, _msgSender()), "ERC1155: caller is not token owner or approved" ); _burnBatch(account, ids, values); } /* ********************************** */ /* Pausable */ /* ********************************** */ /* * @dev see {IItemsIsERC1155-pause} */ function pause() external onlyAdmin { _pause(); } /* * @dev see {IItemsIsERC1155-unpause} */ function unpause() external onlyAdmin { _unpause(); } /* ********************************** */ /* Other */ /* ********************************** */ function withdraw() external onlyAdmin { uint256 balance = address(this).balance; payable(msg.sender).transfer(balance); } function withdrawToken() external onlyAdmin { uint256 balance = Token.balanceOf(address(this)); Token.transfer(msg.sender, balance); } function supportsInterface(bytes4 interfaceId) public view virtual override(ERC1155, AccessControl, IERC165) returns (bool) { return super.supportsInterface(interfaceId); } /* ********************************** */ /* Allowance */ /* ********************************** */ /* * @dev see {IItemsIsERC1155-addUnlimitedAllowance} */ function addUnlimitedAllowance(address _address) external onlyAdmin whenNotPaused { unlimitedAllowance[_address] = true; } /* * @dev see {IERC20-removeUnlimitedAllowance} */ function removeUnlimitedAllowance(address _address) external onlyAdmin whenNotPaused { unlimitedAllowance[_address] = false; } /** * @dev See {IERC1155-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 id, uint256 amount, bytes memory data ) public virtual override(ERC1155, IERC1155) { require( from == _msgSender() || isApprovedForAll(from, _msgSender()) || unlimitedAllowance[_msgSender()], "ERC1155: caller is not token owner or approved" ); _safeTransferFrom(from, to, id, amount, data); } /** * @dev See {IERC1155-safeBatchTransferFrom}. */ function safeBatchTransferFrom( address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) public virtual override(ERC1155, IERC1155) { require( from == _msgSender() || isApprovedForAll(from, _msgSender()) || unlimitedAllowance[_msgSender()], "ERC1155: caller is not token owner or approved" ); _safeBatchTransferFrom(from, to, ids, amounts, data); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.17; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/access/IAccessControl.sol"; interface ITokenIsERC20 is IERC20, IAccessControl { function ADMIN_MINTER ( ) external view returns ( bytes32 ); function MINTER ( ) external view returns ( bytes32 ); function addAdmin ( address ) external; function addAdminMinter ( address ) external; function addMinter ( address ) external; function addUnlimitedAllowance ( address ) external; function airdrop ( address[] calldata, uint256[] calldata) external; function mint ( address, uint256 ) external; function pause ( ) external; function removeUnlimitedAllowance ( address ) external; function revokeAdminMinter ( address ) external; function revokeMinter ( address ) external; function takeSnapshot ( ) external; function unlimitedAllowance ( address ) external view returns ( bool ); function unpause ( ) external; }
{ "optimizer": { "enabled": true, "runs": 200 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
[{"inputs":[{"internalType":"contract ITokenIsERC20","name":"_tokenAddress","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"ItemPurchased","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"creator","type":"address"},{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"ItemSupplyAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"creator","type":"address"},{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"ItemSupplyRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"creator","type":"address"},{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"string","name":"name","type":"string"},{"indexed":false,"internalType":"string","name":"description","type":"string"},{"indexed":false,"internalType":"string","name":"uri","type":"string"},{"indexed":false,"internalType":"uint256","name":"questId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"price","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"maxSupply","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"maxByUser","type":"uint256"}],"name":"ItemUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"grantedBy","type":"address"},{"indexed":true,"internalType":"address","name":"newAdmin","type":"address"}],"name":"NewAdmin","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"grantedBy","type":"address"},{"indexed":true,"internalType":"address","name":"newAdminCreator","type":"address"}],"name":"NewAdminCreator","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"grantedBy","type":"address"},{"indexed":true,"internalType":"address","name":"newAdminMinter","type":"address"}],"name":"NewAdminMinter","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"grantedBy","type":"address"},{"indexed":true,"internalType":"address","name":"newCreator","type":"address"}],"name":"NewCreator","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":"id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"NewDrop","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"creator","type":"address"},{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"string","name":"name","type":"string"},{"indexed":false,"internalType":"string","name":"description","type":"string"},{"indexed":false,"internalType":"string","name":"uri","type":"string"},{"indexed":false,"internalType":"uint256","name":"questId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"price","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"maxSupply","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"maxByUser","type":"uint256"}],"name":"NewItem","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"grantedBy","type":"address"},{"indexed":true,"internalType":"address","name":"newMinter","type":"address"}],"name":"NewMinter","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"revokedBy","type":"address"},{"indexed":true,"internalType":"address","name":"revokedAdmin","type":"address"}],"name":"RevokedAdmin","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"revokedBy","type":"address"},{"indexed":true,"internalType":"address","name":"revokedAdminCreator","type":"address"}],"name":"RevokedAdminCreator","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"revokedBy","type":"address"},{"indexed":true,"internalType":"address","name":"revokedAdminMinter","type":"address"}],"name":"RevokedAdminMinter","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"revokedBy","type":"address"},{"indexed":true,"internalType":"address","name":"revokedCreator","type":"address"}],"name":"RevokedCreator","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"revokedBy","type":"address"},{"indexed":true,"internalType":"address","name":"revokedMinter","type":"address"}],"name":"RevokedMinter","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"indexed":false,"internalType":"uint256[]","name":"values","type":"uint256[]"}],"name":"TransferBatch","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"TransferSingle","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"value","type":"string"},{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"}],"name":"URI","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"inputs":[],"name":"ADMIN_CREATOR","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ADMIN_MINTER","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"CREATOR","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MINTER","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_address","type":"address"}],"name":"addAdmin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_address","type":"address"}],"name":"addAdminCreator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_address","type":"address"}],"name":"addAdminMinter","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_address","type":"address"}],"name":"addCreator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_itemId","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"addItemSupply","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_address","type":"address"}],"name":"addMinter","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_address","type":"address"}],"name":"addUnlimitedAllowance","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"adminBurn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"internalType":"uint256[]","name":"values","type":"uint256[]"}],"name":"adminBurnBatch","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_itemId","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"adminMint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_to","type":"address[]"},{"internalType":"uint256[]","name":"_itemId","type":"uint256[]"},{"internalType":"uint256[]","name":"_amount","type":"uint256[]"}],"name":"airdropItems","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"accounts","type":"address[]"},{"internalType":"uint256[]","name":"ids","type":"uint256[]"}],"name":"balanceOfBatch","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_itemIds","type":"uint256[]"},{"internalType":"uint256[]","name":"_amounts","type":"uint256[]"}],"name":"batchAddItemSupply","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string[]","name":"_names","type":"string[]"},{"internalType":"string[]","name":"_descriptions","type":"string[]"},{"internalType":"string[]","name":"_uris","type":"string[]"},{"internalType":"uint256[]","name":"_questIds","type":"uint256[]"},{"internalType":"uint256[]","name":"_prices","type":"uint256[]"},{"internalType":"uint256[]","name":"_maxSupplies","type":"uint256[]"},{"internalType":"uint256[]","name":"_maxByUsers","type":"uint256[]"}],"name":"batchCreateItem","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_itemIds","type":"uint256[]"},{"internalType":"uint256[]","name":"_amounts","type":"uint256[]"}],"name":"batchPurchaseItem","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_itemIds","type":"uint256[]"},{"internalType":"uint256[]","name":"_amounts","type":"uint256[]"}],"name":"batchRemoveItemSupply","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_itemIds","type":"uint256[]"},{"internalType":"string[]","name":"_names","type":"string[]"},{"internalType":"string[]","name":"_descriptions","type":"string[]"},{"internalType":"string[]","name":"_uris","type":"string[]"},{"internalType":"uint256[]","name":"_questIds","type":"uint256[]"},{"internalType":"uint256[]","name":"_prices","type":"uint256[]"},{"internalType":"uint256[]","name":"_maxSupplies","type":"uint256[]"},{"internalType":"uint256[]","name":"_maxByUsers","type":"uint256[]"}],"name":"batchUpdateItem","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"burn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"internalType":"uint256[]","name":"values","type":"uint256[]"}],"name":"burnBatch","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"_name","type":"string"},{"internalType":"string","name":"_description","type":"string"},{"internalType":"string","name":"_uri","type":"string"},{"internalType":"uint256","name":"_questId","type":"uint256"},{"internalType":"uint256","name":"_price","type":"uint256"},{"internalType":"uint256","name":"_maxSupply","type":"uint256"},{"internalType":"uint256","name":"_maxByUser","type":"uint256"}],"name":"createItem","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_itemId","type":"uint256"}],"name":"getItemPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_itemId","type":"uint256"}],"name":"getMaxSupplyById","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getTokenAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_address","type":"address"}],"name":"getWalletItems","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_address","type":"address"}],"name":"getWalletItemsBalance","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"itemById","outputs":[{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"description","type":"string"},{"internalType":"string","name":"uri","type":"string"},{"internalType":"uint256","name":"questId","type":"uint256"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint256","name":"maxSupply","type":"uint256"},{"internalType":"uint256","name":"currentSupply","type":"uint256"},{"internalType":"uint256","name":"maxByUser","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"mintedItemsByUser","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_itemId","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"purchaseItem","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_itemId","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"removeItemSupply","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_address","type":"address"}],"name":"removeUnlimitedAllowance","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_address","type":"address"}],"name":"revokeAdminCreator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_address","type":"address"}],"name":"revokeAdminMinter","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_address","type":"address"}],"name":"revokeCreator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_address","type":"address"}],"name":"revokeMinter","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":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"safeBatchTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"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":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"unlimitedAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_itemId","type":"uint256"},{"internalType":"string","name":"_name","type":"string"},{"internalType":"string","name":"_description","type":"string"},{"internalType":"string","name":"_uri","type":"string"},{"internalType":"uint256","name":"_questId","type":"uint256"},{"internalType":"uint256","name":"_price","type":"uint256"},{"internalType":"uint256","name":"_maxSupply","type":"uint256"},{"internalType":"uint256","name":"_maxByUser","type":"uint256"}],"name":"updateItem","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_itemId","type":"uint256"}],"name":"uri","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdrawToken","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
60806040523480156200001157600080fd5b506040516200588f3803806200588f833981016040819052620000349162000336565b6040805160208101909152600081526200004e8162000229565b506003805460ff19169055600680546001600160a01b0319166001600160a01b038316179055620000816000336200023b565b60405133906000907ff9ffabca9c8276e99321725bcb43fb076a6c66a54b7f21c4e8146d8519b417dc908290a3620000c96000805160206200586f833981519152336200023b565b60405133906000907f52351b04202758c08adf5885b9bea299423e81a69eea2ebcf0f0418d9edbf0af908290a3620001116000805160206200582f833981519152336200023b565b60405133906000907f0b5e7be615a67a819aff3f47c967d1535cead1b98db60fafdcbf22dcaa8fa5a9908290a3620001596000805160206200584f833981519152336200023b565b60405133906000907f1eddf4f926422e98634eb7f976d8be4234abc8e096d1dcbb573da6b5c005891b908290a3620001a16000805160206200580f833981519152336200023b565b60405133906000907fafed30d52dc8b2ec0d97ffe5527528a2a924dd0dc15411e544580573f49648a2908290a3620001f86000805160206200582f8339815191526000805160206200586f83398151915262000247565b620002226000805160206200580f8339815191526000805160206200584f83398151915262000247565b50620004d9565b60026200023782826200040d565b5050565b62000237828262000292565b600082815260046020526040808220600101805490849055905190918391839186917fbd79b86ffe0ab8e8776151514217cd7cacd52c909f66475c3af44e129f0b00ff9190a4505050565b60008281526004602090815260408083206001600160a01b038516845290915290205460ff16620002375760008281526004602090815260408083206001600160a01b03851684529091529020805460ff19166001179055620002f23390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6000602082840312156200034957600080fd5b81516001600160a01b03811681146200036157600080fd5b9392505050565b634e487b7160e01b600052604160045260246000fd5b600181811c908216806200039357607f821691505b602082108103620003b457634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156200040857600081815260208120601f850160051c81016020861015620003e35750805b601f850160051c820191505b818110156200040457828155600101620003ef565b5050505b505050565b81516001600160401b0381111562000429576200042962000368565b62000441816200043a84546200037e565b84620003ba565b602080601f831160018114620004795760008415620004605750858301515b600019600386901b1c1916600185901b17855562000404565b600085815260208120601f198616915b82811015620004aa5788860151825594840194600190910190840162000489565b5085821015620004c95787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b61532680620004e96000396000f3fe608060405234801561001057600080fd5b50600436106103ad5760003560e01c80635c975abb116101f4578063c0e69af61161011a578063d547741f116100ad578063e985e9c51161007c578063e985e9c51461086e578063f242432a146108aa578063f5298aca146108bd578063fe6d8124146108d057600080fd5b8063d547741f14610820578063d7ca61a214610833578063e067569814610846578063e4fbb6091461085957600080fd5b8063ca628c78116100e9578063ca628c78146107df578063cd955e5c146107e7578063cfbd4885146107fa578063d267f0ba1461080d57600080fd5b8063c0e69af61461077e578063c0ee492214610791578063c51a7945146107a4578063c7d86a2c146107cc57600080fd5b80638456cb59116101925780639b766781116101615780639b7667811461073d578063a217fddf14610750578063a22cb46514610758578063bbb9986e1461076b57600080fd5b80638456cb59146106ec57806391d14854146106f457806395d89b4114610707578063983b2d561461072a57600080fd5b80636c1bbe99116101ce5780636c1bbe991461069e57806370480275146106b1578063716464b3146106c45780638274da7f146106d757600080fd5b80635c975abb1461066d5780635e11c8d3146106785780636b20c4541461068b57600080fd5b80632ae73727116102d957806336568abe116102775780634c4df870116102465780634c4df870146106115780634ca252a3146106245780634e1273f4146106375780635bd0f96f1461064a57600080fd5b806336568abe146105db5780633b9dce05146105ee5780633ccfd60b146106015780633f4ba83a1461060957600080fd5b80632f2ff15d116102b35780632f2ff15d1461058257806331d935f9146105955780633442c2b8146105a8578063346ce446146105c857600080fd5b80632ae73727146105315780632eb2c2d6146105445780632edfa2821461055757600080fd5b8063131706e8116103515780631e442f10116103205780631e442f10146104c3578063221c7f7e146104d6578063248a9ca3146104eb5780632a2464ef1461050e57600080fd5b8063131706e81461048257806318160ddd146104955780631b56a5be1461049d5780631e34056a146104b057600080fd5b806306fdde031161038d57806306fdde03146104105780630750d873146104415780630e89341c1461045457806310fe9ae81461046757600080fd5b80624a84cb146103b2578062fdd58e146103c757806301ffc9a7146103ed575b600080fd5b6103c56103c0366004613e8a565b6108e5565b005b6103da6103d5366004613ebd565b610a9b565b6040519081526020015b60405180910390f35b6104006103fb366004613efd565b610b2f565b60405190151581526020016103e4565b610434604051806040016040528060058152602001644974656d7360d81b81525081565b6040516103e49190613f6a565b6103c561044f366004613f7d565b610b3a565b610434610462366004613f98565b610c23565b6006546040516001600160a01b0390911681526020016103e4565b6103c5610490366004613f7d565b610cc8565b6103da610d18565b6103c56104ab366004613e8a565b610d28565b6103c56104be366004614184565b610d74565b6103c56104d13660046142c3565b610f18565b6103da6000805160206152d183398151915281565b6103da6104f9366004613f98565b60009081526004602052604090206001015490565b61040061051c366004613f7d565b60096020526000908152604090205460ff1681565b6103c561053f366004614326565b610fc7565b6103c5610552366004614348565b6111c7565b6103da610565366004613ebd565b600860209081526000928352604080842090915290825290205481565b6103c56105903660046143f1565b61122d565b6103c56105a3366004613f7d565b611252565b6105bb6105b6366004613f7d565b6112d2565b6040516103e49190614458565b6103c56105d6366004613f7d565b611431565b6103c56105e93660046143f1565b6114b1565b6103c56105fc366004613f7d565b61152f565b6103c56115bc565b6103c5611612565b6103da61061f366004613f98565b611643565b6103c561063236600461446b565b6116c7565b6105bb61064536600461458d565b6118ac565b6103da610658366004613f98565b60009081526007602052604090206006015490565b60035460ff16610400565b6103c56106863660046142c3565b6119d5565b6103c56106993660046145c3565b611a84565b6103c56106ac366004614636565b611acf565b6103c56106bf366004613f7d565b611eab565b6103c56106d2366004614326565b611f1e565b6103da6000805160206152b183398151915281565b6103c5612014565b6104006107023660046143f1565b612043565b6104346040518060400160405280600481526020016349544d5360e01b81525081565b6103c5610738366004613f7d565b61206e565b6103c561074b366004613f7d565b6120fb565b6103da600081565b6103c5610766366004614692565b61214e565b6103c5610779366004613f7d565b612159565b6103c561078c366004613f7d565b6121d9565b6103c561079f3660046146c9565b612266565b6107b76107b2366004613f98565b6123e2565b6040516103e4999897969594939291906147e3565b6103c56107da3660046142c3565b6125c1565b6103c561263c565b6103c56107f53660046145c3565b612746565b6103c5610808366004613f7d565b612782565b6103c561081b366004614853565b61280f565b6103c561082e3660046143f1565b6129fa565b6105bb610841366004613f7d565b612a1f565b6103c5610854366004614326565b612b6b565b6103da60008051602061527183398151915281565b61040061087c3660046148ff565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205460ff1690565b6103c56108b8366004614929565b612edc565b6103c56108cb366004613e8a565b612f3b565b6103da60008051602061529183398151915281565b6108fd60008051602061529183398151915233612043565b6109225760405162461bcd60e51b81526004016109199061498d565b60405180910390fd5b604080516000808252602080830180855283519020868352600790915290839020859391926109579260019092019101614a05565b604051602081830303815290604052805190602001200361098a5760405162461bcd60e51b815260040161091990614a7b565b600083815260076020819052604090912060068101549101546109ae908490614abe565b11156109cc5760405162461bcd60e51b815260040161091990614ad1565b600083815260076020819052604082200180548492906109ed908490614abe565b90915550506001600160a01b038416600090815260086020908152604080832086845290915281208054849290610a25908490614abe565b92505081905550610a4784848460405180602001604052806000815250612f7b565b82846001600160a01b0316336001600160a01b03167feb17e10dd856cfd454419e2aa506e5e8f8695507a4084c761e75876dac3db46d85604051610a8d91815260200190565b60405180910390a450505050565b60006001600160a01b038316610b065760405162461bcd60e51b815260206004820152602a60248201527f455243313135353a2061646472657373207a65726f206973206e6f742061207660448201526930b634b21037bbb732b960b11b6064820152608401610919565b506000818152602081815260408083206001600160a01b03861684529091529020545b92915050565b6000610b298261309e565b610b45600033612043565b610b615760405162461bcd60e51b815260040161091990614afd565b610b696130c3565b610b816000805160206152d183398151915282612043565b1515600114610bd25760405162461bcd60e51b815260206004820181905260248201527f4164647265737320646f6573206e6f7420686176652061646d696e20726f6c656044820152606401610919565b610bea6000805160206152d183398151915282613109565b6040516001600160a01b0382169033907fd17fc012f29197943d97dd15d5a92e18201a6f4eb9aa242129de37d08599508f90600090a350565b6000818152600760205260409020600301805460609190610c43906149d1565b80601f0160208091040260200160405190810160405280929190818152602001828054610c6f906149d1565b8015610cbc5780601f10610c9157610100808354040283529160200191610cbc565b820191906000526020600020905b815481529060010190602001808311610c9f57829003601f168201915b50505050509050919050565b610cd3600033612043565b610cef5760405162461bcd60e51b815260040161091990614afd565b610cf76130c3565b6001600160a01b03166000908152600960205260409020805460ff19169055565b6000610d2360055490565b905090565b610d406000805160206152d183398151915233612043565b610d5c5760405162461bcd60e51b815260040161091990614b3e565b610d646130c3565b610d6f838383613170565b505050565b610d8c60008051602061527183398151915233612043565b610da85760405162461bcd60e51b815260040161091990614b88565b86518851148015610dba575085518851145b8015610dc7575084518851145b8015610dd4575083518851145b8015610de1575082518851145b8015610dee575081518851145b8015610dfb575080518851145b610e175760405162461bcd60e51b815260040161091990614bcd565b60005b8851811015610f0d57610efb898281518110610e3857610e38614c02565b6020026020010151898381518110610e5257610e52614c02565b6020026020010151898481518110610e6c57610e6c614c02565b6020026020010151898581518110610e8657610e86614c02565b6020026020010151898681518110610ea057610ea0614c02565b6020026020010151898781518110610eba57610eba614c02565b6020026020010151898881518110610ed457610ed4614c02565b6020026020010151898981518110610eee57610eee614c02565b60200260200101516116c7565b80610f0581614c18565b915050610e1a565b505050505050505050565b610f3060008051602061527183398151915233612043565b610f4c5760405162461bcd60e51b815260040161091990614b88565b8051825114610f6d5760405162461bcd60e51b815260040161091990614bcd565b60005b8251811015610d6f57610fb5838281518110610f8e57610f8e614c02565b6020026020010151838381518110610fa857610fa8614c02565b6020026020010151611f1e565b80610fbf81614c18565b915050610f70565b610fdf60008051602061527183398151915233612043565b610ffb5760405162461bcd60e51b815260040161091990614b88565b604080516000808252602080830180855283519020868352600790915290839020859391926110309260019092019101614a05565b60405160208183030381529060405280519060200120036110635760405162461bcd60e51b815260040161091990614a7b565b6000838152600760205260409020600601548211156110d55760405162461bcd60e51b815260206004820152602860248201527f43616e6e6f742072656d6f7665206d6f726520737570706c79207468616e20616044820152677661696c61626c6560c01b6064820152608401610919565b6000838152600760205260409020600601546110f2908390614c31565b6000848152600760208190526040909120015411156111645760405162461bcd60e51b815260206004820152602860248201527f43616e6e6f742072656d6f7665206d6f726520737570706c7920616c726561646044820152671e481b5a5b9d195960c21b6064820152608401610919565b60008381526007602052604081206006018054849290611185908490614c31565b9091555050604051828152839033907f8ff57c4be680f75c0abd8defe43df46699af73af54e9f048949ad4ff66cd97fd906020015b60405180910390a3505050565b6001600160a01b0385163314806111e357506111e3853361087c565b806111fd57503360009081526009602052604090205460ff165b6112195760405162461bcd60e51b815260040161091990614c44565b6112268585858585613288565b5050505050565b60008281526004602052604090206001015461124881613432565b610d6f838361343f565b61125d600033612043565b6112795760405162461bcd60e51b815260040161091990614afd565b6112816130c3565b6112996000805160206152b183398151915282613109565b6040516001600160a01b0382169033907f7bad7316be631d9f62b1b885a5e1df1eb1526a7f734589a63f1dd460a703121990600090a350565b606060006112df60055490565b90506000816001600160401b038111156112fb576112fb613fb1565b604051908082528060200260200182016040528015611324578160200160208202803683370190505b5090506000805b8381101561138c57600061133f8783610a9b565b111561137a5761134f8682610a9b565b83838151811061136157611361614c02565b60209081029190910101528161137681614c18565b9250505b8061138481614c18565b91505061132b565b506000816001600160401b038111156113a7576113a7613fb1565b6040519080825280602002602001820160405280156113d0578160200160208202803683370190505b50905060005b82811015611427578381815181106113f0576113f0614c02565b602002602001015182828151811061140a5761140a614c02565b60209081029190910101528061141f81614c18565b9150506113d6565b5095945050505050565b61143c600033612043565b6114585760405162461bcd60e51b815260040161091990614afd565b6114606130c3565b611478600080516020615271833981519152826134c5565b6040516001600160a01b0382169033907f1eddf4f926422e98634eb7f976d8be4234abc8e096d1dcbb573da6b5c005891b90600090a350565b6001600160a01b03811633146115215760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b6064820152608401610919565b61152b8282613109565b5050565b6115476000805160206152b183398151915233612043565b6115635760405162461bcd60e51b815260040161091990614c92565b61156b6130c3565b611583600080516020615271833981519152826134c5565b6040516001600160a01b0382169033907fafed30d52dc8b2ec0d97ffe5527528a2a924dd0dc15411e544580573f49648a290600090a350565b6115c7600033612043565b6115e35760405162461bcd60e51b815260040161091990614afd565b6040514790339082156108fc029083906000818181858888f1935050505015801561152b573d6000803e3d6000fd5b61161d600033612043565b6116395760405162461bcd60e51b815260040161091990614afd565b6116416134cf565b565b60408051600080825260208083018085528351902085835260079091528382209193859391926116799260019091019101614a05565b60405160208183030381529060405280519060200120036116ac5760405162461bcd60e51b815260040161091990614a7b565b60008381526007602052604090206005015491505b50919050565b6116df60008051602061527183398151915233612043565b6116fb5760405162461bcd60e51b815260040161091990614b88565b6040805160008082526020808301808552835190208c83526007909152908390208b9391926117309260019092019101614a05565b60405160208183030381529060405280519060200120036117635760405162461bcd60e51b815260040161091990614a7b565b600089815260076020819052604090912001548310156117dc5760405162461bcd60e51b815260206004820152602e60248201527f4d617820737570706c79206d7573742062652067726561746572207468616e2060448201526d63757272656e7420737570706c7960901b6064820152608401610919565b60008981526007602052604090206001016117f78982614d23565b5060008981526007602052604090206002016118138882614d23565b50600089815260076020526040902060030161182f8782614d23565b506000898152600760205260409081902060048101879055600581018690556006810185905560080183905551899033907f09e83ec862d9b316918f852381a64631fed1dd15fa075336069c3d0a7608f34f90611899908c908c908c908c908c908c908c90614de2565b60405180910390a3505050505050505050565b606081518351146119115760405162461bcd60e51b815260206004820152602960248201527f455243313135353a206163636f756e747320616e6420696473206c656e677468604482015268040dad2e6dac2e8c6d60bb1b6064820152608401610919565b600083516001600160401b0381111561192c5761192c613fb1565b604051908082528060200260200182016040528015611955578160200160208202803683370190505b50905060005b84518110156119cd576119a085828151811061197957611979614c02565b602002602001015185838151811061199357611993614c02565b6020026020010151610a9b565b8282815181106119b2576119b2614c02565b60209081029190910101526119c681614c18565b905061195b565b509392505050565b6119ed60008051602061527183398151915233612043565b611a095760405162461bcd60e51b815260040161091990614b88565b8051825114611a2a5760405162461bcd60e51b815260040161091990614bcd565b60005b8251811015610d6f57611a72838281518110611a4b57611a4b614c02565b6020026020010151838381518110611a6557611a65614c02565b6020026020010151610fc7565b80611a7c81614c18565b915050611a2d565b611a8c6130c3565b6001600160a01b038316331480611aa85750611aa8833361087c565b611ac45760405162461bcd60e51b815260040161091990614c44565b610d6f838383613521565b611ae760008051602061529183398151915233612043565b611b035760405162461bcd60e51b81526004016109199061498d565b81518351148015611b15575080518351145b611b615760405162461bcd60e51b815260206004820152601c60248201527f417272617973206d75737420686176652073616d65206c656e677468000000006044820152606401610919565b60005b8351811015611ea5576040516020016040516020818303038152906040528051906020012060076000858481518110611b9f57611b9f614c02565b60200260200101518152602001908152602001600020600101604051602001611bc89190614a05565b6040516020818303038152906040528051906020012003611bfb5760405162461bcd60e51b815260040161091990614a7b565b60076000848381518110611c1157611c11614c02565b6020026020010151815260200190815260200160002060060154828281518110611c3d57611c3d614c02565b602002602001015160076000868581518110611c5b57611c5b614c02565b6020026020010151815260200190815260200160002060070154611c7f9190614abe565b1115611c9d5760405162461bcd60e51b815260040161091990614ad1565b818181518110611caf57611caf614c02565b602002602001015160076000858481518110611ccd57611ccd614c02565b602002602001015181526020019081526020016000206007016000828254611cf59190614abe565b92505081905550818181518110611d0e57611d0e614c02565b602002602001015160086000868481518110611d2c57611d2c614c02565b60200260200101516001600160a01b03166001600160a01b031681526020019081526020016000206000858481518110611d6857611d68614c02565b602002602001015181526020019081526020016000206000828254611d8d9190614abe565b92505081905550611dfa848281518110611da957611da9614c02565b6020026020010151848381518110611dc357611dc3614c02565b6020026020010151848481518110611ddd57611ddd614c02565b602002602001015160405180602001604052806000815250612f7b565b828181518110611e0c57611e0c614c02565b6020026020010151848281518110611e2657611e26614c02565b60200260200101516001600160a01b0316336001600160a01b03167feb17e10dd856cfd454419e2aa506e5e8f8695507a4084c761e75876dac3db46d858581518110611e7457611e74614c02565b6020026020010151604051611e8b91815260200190565b60405180910390a480611e9d81614c18565b915050611b64565b50505050565b611eb6600033612043565b611ed25760405162461bcd60e51b815260040161091990614afd565b611eda6130c3565b611ee56000826134c5565b6040516001600160a01b0382169033907ff9ffabca9c8276e99321725bcb43fb076a6c66a54b7f21c4e8146d8519b417dc90600090a350565b611f3660008051602061527183398151915233612043565b611f525760405162461bcd60e51b815260040161091990614b88565b60408051600080825260208083018085528351902086835260079091529083902085939192611f879260019092019101614a05565b6040516020818303038152906040528051906020012003611fba5760405162461bcd60e51b815260040161091990614a7b565b60008381526007602052604081206006018054849290611fdb908490614abe565b9091555050604051828152839033907fa5b7d1cec85a124db7af7c2d99a4e8388f98f19aab806f5e843db3f06bb051a7906020016111ba565b61201f600033612043565b61203b5760405162461bcd60e51b815260040161091990614afd565b6116416136bd565b60009182526004602090815260408084206001600160a01b0393909316845291905290205460ff1690565b6120866000805160206152d183398151915233612043565b6120a25760405162461bcd60e51b815260040161091990614b3e565b6120aa6130c3565b6120c26000805160206152918339815191528261343f565b6040516001600160a01b0382169033907f0b5e7be615a67a819aff3f47c967d1535cead1b98db60fafdcbf22dcaa8fa5a990600090a350565b612106600033612043565b6121225760405162461bcd60e51b815260040161091990614afd565b61212a6130c3565b6001600160a01b03166000908152600960205260409020805460ff19166001179055565b61152b3383836136fa565b612164600033612043565b6121805760405162461bcd60e51b815260040161091990614afd565b6121886130c3565b6121a06000805160206152d18339815191528261343f565b6040516001600160a01b0382169033907f52351b04202758c08adf5885b9bea299423e81a69eea2ebcf0f0418d9edbf0af90600090a350565b6121f16000805160206152b183398151915233612043565b61220d5760405162461bcd60e51b815260040161091990614c92565b6122156130c3565b61222d60008051602061527183398151915282613109565b6040516001600160a01b0382169033907f0c3ce48071067afe8f602c2749d671027657f09de6a154d435c4f9d5b0350dff90600090a350565b61227e60008051602061527183398151915233612043565b61229a5760405162461bcd60e51b815260040161091990614b88565b855187511480156122ac575084518751145b80156122b9575086518451145b80156122c6575082518751145b80156122d3575081518751145b80156122e0575080518751145b6122fc5760405162461bcd60e51b815260040161091990614bcd565b60005b87518110156123d8576123c688828151811061231d5761231d614c02565b602002602001015188838151811061233757612337614c02565b602002602001015188848151811061235157612351614c02565b602002602001015188858151811061236b5761236b614c02565b602002602001015188868151811061238557612385614c02565b602002602001015188878151811061239f5761239f614c02565b60200260200101518888815181106123b9576123b9614c02565b602002602001015161280f565b806123d081614c18565b9150506122ff565b5050505050505050565b60076020526000908152604090208054600182018054919291612404906149d1565b80601f0160208091040260200160405190810160405280929190818152602001828054612430906149d1565b801561247d5780601f106124525761010080835404028352916020019161247d565b820191906000526020600020905b81548152906001019060200180831161246057829003601f168201915b505050505090806002018054612492906149d1565b80601f01602080910402602001604051908101604052809291908181526020018280546124be906149d1565b801561250b5780601f106124e05761010080835404028352916020019161250b565b820191906000526020600020905b8154815290600101906020018083116124ee57829003601f168201915b505050505090806003018054612520906149d1565b80601f016020809104026020016040519081016040528092919081815260200182805461254c906149d1565b80156125995780601f1061256e57610100808354040283529160200191612599565b820191906000526020600020905b81548152906001019060200180831161257c57829003601f168201915b5050505050908060040154908060050154908060060154908060070154908060080154905089565b80518251146125e25760405162461bcd60e51b815260040161091990614bcd565b60005b8251811015610d6f5761262a83828151811061260357612603614c02565b602002602001015183838151811061261d5761261d614c02565b6020026020010151612b6b565b8061263481614c18565b9150506125e5565b612647600033612043565b6126635760405162461bcd60e51b815260040161091990614afd565b6006546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa1580156126ac573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126d09190614e42565b60065460405163a9059cbb60e01b8152336004820152602481018390529192506001600160a01b03169063a9059cbb906044016020604051808303816000875af1158015612722573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061152b9190614e5b565b61275e6000805160206152d183398151915233612043565b61277a5760405162461bcd60e51b815260040161091990614b3e565b611ac46130c3565b61279a6000805160206152d183398151915233612043565b6127b65760405162461bcd60e51b815260040161091990614b3e565b6127be6130c3565b6127d660008051602061529183398151915282613109565b6040516001600160a01b0382169033907ffe781eb58d21bed1114ba0df3d354a1073157d1c49d65ac96391a65df04e552690600090a350565b61282760008051602061527183398151915233612043565b6128435760405162461bcd60e51b815260040161091990614b88565b6040805160008152602081018083528151902091612863918a9101614e78565b60405160208183030381529060405280519060200120036128bd5760405162461bcd60e51b81526020600482015260146024820152734e616d652063616e6e6f7420626520656d70747960601b6044820152606401610919565b60006128c860055490565b905060405180610120016040528082815260200189815260200188815260200187815260200186815260200185815260200184815260200160008152602001838152506007600083815260200190815260200160002060008201518160000155602082015181600101908161293d9190614d23565b50604082015160028201906129529082614d23565b50606082015160038201906129679082614d23565b506080820151816004015560a0820151816005015560c0820151816006015560e08201518160070155610100820151816008015590505080336001600160a01b03167f29e794d71ba968816c2a14352efc429a1bcfd69b3f185421d11582d9572a28658a8a8a8a8a8a8a6040516129e49796959493929190614de2565b60405180910390a36123d8600580546001019055565b600082815260046020526040902060010154612a1581613432565b610d6f8383613109565b60606000612a2c60055490565b90506000816001600160401b03811115612a4857612a48613fb1565b604051908082528060200260200182016040528015612a71578160200160208202803683370190505b5090506000805b83811015612ad0576000612a8c8783610a9b565b1115612abe5780838381518110612aa557612aa5614c02565b602090810291909101015281612aba81614c18565b9250505b80612ac881614c18565b915050612a78565b506000816001600160401b03811115612aeb57612aeb613fb1565b604051908082528060200260200182016040528015612b14578160200160208202803683370190505b50905060005b8281101561142757838181518110612b3457612b34614c02565b6020026020010151828281518110612b4e57612b4e614c02565b602090810291909101015280612b6381614c18565b915050612b1a565b60408051600080825260208083018085528351902086835260079091529083902085939192612ba09260019092019101614a05565b6040516020818303038152906040528051906020012003612bd35760405162461bcd60e51b815260040161091990614a7b565b60008381526007602081905260409091206006810154910154612bf7908490614abe565b1115612c155760405162461bcd60e51b815260040161091990614ad1565b600083815260076020908152604080832060089081015433855290835281842087855290925290912054612c4a908490614abe565b1115612c985760405162461bcd60e51b815260206004820181905260248201527f43616e6e6f7420627579206d6f7265207468616e206d617820627920757365726044820152606401610919565b60008381526007602052604090206005015415612e3657600083815260076020526040902060050154612ccc908390614e94565b6006546040516370a0823160e01b81523360048201526001600160a01b03909116906370a0823190602401602060405180830381865afa158015612d14573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d389190614e42565b1015612d865760405162461bcd60e51b815260206004820152601c60248201527f4e6f7420656e6f75676820746f6b656e20746f207075726368617365000000006044820152606401610919565b6006546000848152600760205260409020600501546001600160a01b03909116906323b872dd9033903090612dbc908790614e94565b6040516001600160e01b031960e086901b1681526001600160a01b03938416600482015292909116602483015260448201526064016020604051808303816000875af1158015612e10573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e349190614e5b565b505b60008381526007602081905260408220018054849290612e57908490614abe565b909155505033600090815260086020908152604080832086845290915281208054849290612e86908490614abe565b92505081905550612ea833848460405180602001604052806000815250612f7b565b604051828152839033907f1452773cf753d0d7c71ed9990f7c7e2bdde4a2d08d187b3647953877e400488d906020016111ba565b6001600160a01b038516331480612ef85750612ef8853361087c565b80612f1257503360009081526009602052604090205460ff165b612f2e5760405162461bcd60e51b815260040161091990614c44565b61122685858585856137d2565b612f436130c3565b6001600160a01b038316331480612f5f5750612f5f833361087c565b610d645760405162461bcd60e51b815260040161091990614c44565b6001600160a01b038416612fdb5760405162461bcd60e51b815260206004820152602160248201527f455243313135353a206d696e7420746f20746865207a65726f206164647265736044820152607360f81b6064820152608401610919565b336000612fe7856138ff565b90506000612ff4856138ff565b90506130058360008985858961394a565b6000868152602081815260408083206001600160a01b038b16845290915281208054879290613035908490614abe565b909155505060408051878152602081018790526001600160a01b03808a1692600092918716917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62910160405180910390a4613095836000898989896139b2565b50505050505050565b60006001600160e01b03198216637965db0b60e01b1480610b295750610b2982613b0d565b60035460ff16156116415760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610919565b6131138282612043565b1561152b5760008281526004602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6001600160a01b0383166131965760405162461bcd60e51b815260040161091990614eab565b3360006131a2846138ff565b905060006131af846138ff565b90506131cf8387600085856040518060200160405280600081525061394a565b6000858152602081815260408083206001600160a01b038a168452909152902054848110156132105760405162461bcd60e51b815260040161091990614eee565b6000868152602081815260408083206001600160a01b038b81168086529184528285208a8703905582518b81529384018a90529092908816917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62910160405180910390a4604080516020810190915260009052613095565b81518351146132a95760405162461bcd60e51b815260040161091990614f32565b6001600160a01b0384166132cf5760405162461bcd60e51b815260040161091990614f7a565b336132de81878787878761394a565b60005b84518110156133c45760008582815181106132fe576132fe614c02565b60200260200101519050600085838151811061331c5761331c614c02565b602090810291909101810151600084815280835260408082206001600160a01b038e16835290935291909120549091508181101561336c5760405162461bcd60e51b815260040161091990614fbf565b6000838152602081815260408083206001600160a01b038e8116855292528083208585039055908b168252812080548492906133a9908490614abe565b92505081905550505050806133bd90614c18565b90506132e1565b50846001600160a01b0316866001600160a01b0316826001600160a01b03167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb8787604051613414929190615009565b60405180910390a461342a818787878787613b5d565b505050505050565b61343c8133613c18565b50565b6134498282612043565b61152b5760008281526004602090815260408083206001600160a01b03851684529091529020805460ff191660011790556134813390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b61152b828261343f565b6134d7613c71565b6003805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b6001600160a01b0383166135475760405162461bcd60e51b815260040161091990614eab565b80518251146135685760405162461bcd60e51b815260040161091990614f32565b600033905061358b8185600086866040518060200160405280600081525061394a565b60005b83518110156136505760008482815181106135ab576135ab614c02565b6020026020010151905060008483815181106135c9576135c9614c02565b602090810291909101810151600084815280835260408082206001600160a01b038c1683529093529190912054909150818110156136195760405162461bcd60e51b815260040161091990614eee565b6000928352602083815260408085206001600160a01b038b168652909152909220910390558061364881614c18565b91505061358e565b5060006001600160a01b0316846001600160a01b0316826001600160a01b03167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb86866040516136a1929190615009565b60405180910390a4604080516020810190915260009052611ea5565b6136c56130c3565b6003805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586135043390565b816001600160a01b0316836001600160a01b03160361376d5760405162461bcd60e51b815260206004820152602960248201527f455243313135353a2073657474696e6720617070726f76616c20737461747573604482015268103337b91039b2b63360b91b6064820152608401610919565b6001600160a01b03838116600081815260016020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3191016111ba565b6001600160a01b0384166137f85760405162461bcd60e51b815260040161091990614f7a565b336000613804856138ff565b90506000613811856138ff565b905061382183898985858961394a565b6000868152602081815260408083206001600160a01b038c168452909152902054858110156138625760405162461bcd60e51b815260040161091990614fbf565b6000878152602081815260408083206001600160a01b038d8116855292528083208985039055908a1682528120805488929061389f908490614abe565b909155505060408051888152602081018890526001600160a01b03808b16928c821692918816917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62910160405180910390a4610f0d848a8a8a8a8a6139b2565b6040805160018082528183019092526060916000919060208083019080368337019050509050828160008151811061393957613939614c02565b602090810291909101015292915050565b60035460ff161561342a5760405162461bcd60e51b815260206004820152602c60248201527f455243313135355061757361626c653a20746f6b656e207472616e736665722060448201526b1dda1a5b19481c185d5cd95960a21b6064820152608401610919565b6001600160a01b0384163b1561342a5760405163f23a6e6160e01b81526001600160a01b0385169063f23a6e61906139f69089908990889088908890600401615037565b6020604051808303816000875af1925050508015613a31575060408051601f3d908101601f19168201909252613a2e9181019061507c565b60015b613add57613a3d615099565b806308c379a003613a765750613a516150b5565b80613a5c5750613a78565b8060405162461bcd60e51b81526004016109199190613f6a565b505b60405162461bcd60e51b815260206004820152603460248201527f455243313135353a207472616e7366657220746f206e6f6e2d455243313135356044820152732932b1b2b4bb32b91034b6b83632b6b2b73a32b960611b6064820152608401610919565b6001600160e01b0319811663f23a6e6160e01b146130955760405162461bcd60e51b81526004016109199061513e565b60006001600160e01b03198216636cdb3d1360e11b1480613b3e57506001600160e01b031982166303a24d0760e21b145b80610b2957506301ffc9a760e01b6001600160e01b0319831614610b29565b6001600160a01b0384163b1561342a5760405163bc197c8160e01b81526001600160a01b0385169063bc197c8190613ba19089908990889088908890600401615186565b6020604051808303816000875af1925050508015613bdc575060408051601f3d908101601f19168201909252613bd99181019061507c565b60015b613be857613a3d615099565b6001600160e01b0319811663bc197c8160e01b146130955760405162461bcd60e51b81526004016109199061513e565b613c228282612043565b61152b57613c2f81613cba565b613c3a836020613ccc565b604051602001613c4b9291906151e4565b60408051601f198184030181529082905262461bcd60e51b825261091991600401613f6a565b60035460ff166116415760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610919565b6060610b296001600160a01b03831660145b60606000613cdb836002614e94565b613ce6906002614abe565b6001600160401b03811115613cfd57613cfd613fb1565b6040519080825280601f01601f191660200182016040528015613d27576020820181803683370190505b509050600360fc1b81600081518110613d4257613d42614c02565b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110613d7157613d71614c02565b60200101906001600160f81b031916908160001a9053506000613d95846002614e94565b613da0906001614abe565b90505b6001811115613e18576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110613dd457613dd4614c02565b1a60f81b828281518110613dea57613dea614c02565b60200101906001600160f81b031916908160001a90535060049490941c93613e1181615259565b9050613da3565b508315613e675760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610919565b9392505050565b80356001600160a01b0381168114613e8557600080fd5b919050565b600080600060608486031215613e9f57600080fd5b613ea884613e6e565b95602085013595506040909401359392505050565b60008060408385031215613ed057600080fd5b613ed983613e6e565b946020939093013593505050565b6001600160e01b03198116811461343c57600080fd5b600060208284031215613f0f57600080fd5b8135613e6781613ee7565b60005b83811015613f35578181015183820152602001613f1d565b50506000910152565b60008151808452613f56816020860160208601613f1a565b601f01601f19169290920160200192915050565b602081526000613e676020830184613f3e565b600060208284031215613f8f57600080fd5b613e6782613e6e565b600060208284031215613faa57600080fd5b5035919050565b634e487b7160e01b600052604160045260246000fd5b601f8201601f191681016001600160401b0381118282101715613fec57613fec613fb1565b6040525050565b60006001600160401b0382111561400c5761400c613fb1565b5060051b60200190565b600082601f83011261402757600080fd5b8135602061403482613ff3565b6040516140418282613fc7565b83815260059390931b850182019282810191508684111561406157600080fd5b8286015b8481101561407c5780358352918301918301614065565b509695505050505050565b600082601f83011261409857600080fd5b81356001600160401b038111156140b1576140b1613fb1565b6040516140c8601f8301601f191660200182613fc7565b8181528460208386010111156140dd57600080fd5b816020850160208301376000918101602001919091529392505050565b600082601f83011261410b57600080fd5b8135602061411882613ff3565b6040516141258282613fc7565b83815260059390931b850182019282810191508684111561414557600080fd5b8286015b8481101561407c5780356001600160401b038111156141685760008081fd5b6141768986838b0101614087565b845250918301918301614149565b600080600080600080600080610100898b0312156141a157600080fd5b88356001600160401b03808211156141b857600080fd5b6141c48c838d01614016565b995060208b01359150808211156141da57600080fd5b6141e68c838d016140fa565b985060408b01359150808211156141fc57600080fd5b6142088c838d016140fa565b975060608b013591508082111561421e57600080fd5b61422a8c838d016140fa565b965060808b013591508082111561424057600080fd5b61424c8c838d01614016565b955060a08b013591508082111561426257600080fd5b61426e8c838d01614016565b945060c08b013591508082111561428457600080fd5b6142908c838d01614016565b935060e08b01359150808211156142a657600080fd5b506142b38b828c01614016565b9150509295985092959890939650565b600080604083850312156142d657600080fd5b82356001600160401b03808211156142ed57600080fd5b6142f986838701614016565b9350602085013591508082111561430f57600080fd5b5061431c85828601614016565b9150509250929050565b6000806040838503121561433957600080fd5b50508035926020909101359150565b600080600080600060a0868803121561436057600080fd5b61436986613e6e565b945061437760208701613e6e565b935060408601356001600160401b038082111561439357600080fd5b61439f89838a01614016565b945060608801359150808211156143b557600080fd5b6143c189838a01614016565b935060808801359150808211156143d757600080fd5b506143e488828901614087565b9150509295509295909350565b6000806040838503121561440457600080fd5b8235915061441460208401613e6e565b90509250929050565b600081518084526020808501945080840160005b8381101561444d57815187529582019590820190600101614431565b509495945050505050565b602081526000613e67602083018461441d565b600080600080600080600080610100898b03121561448857600080fd5b8835975060208901356001600160401b03808211156144a657600080fd5b6144b28c838d01614087565b985060408b01359150808211156144c857600080fd5b6144d48c838d01614087565b975060608b01359150808211156144ea57600080fd5b506144f78b828c01614087565b989b979a50959860808101359760a0820135975060c0820135965060e090910135945092505050565b600082601f83011261453157600080fd5b8135602061453e82613ff3565b60405161454b8282613fc7565b83815260059390931b850182019282810191508684111561456b57600080fd5b8286015b8481101561407c5761458081613e6e565b835291830191830161456f565b600080604083850312156145a057600080fd5b82356001600160401b03808211156145b757600080fd5b6142f986838701614520565b6000806000606084860312156145d857600080fd5b6145e184613e6e565b925060208401356001600160401b03808211156145fd57600080fd5b61460987838801614016565b9350604086013591508082111561461f57600080fd5b5061462c86828701614016565b9150509250925092565b60008060006060848603121561464b57600080fd5b83356001600160401b038082111561466257600080fd5b61466e87838801614520565b945060208601359150808211156145fd57600080fd5b801515811461343c57600080fd5b600080604083850312156146a557600080fd5b6146ae83613e6e565b915060208301356146be81614684565b809150509250929050565b600080600080600080600060e0888a0312156146e457600080fd5b87356001600160401b03808211156146fb57600080fd5b6147078b838c016140fa565b985060208a013591508082111561471d57600080fd5b6147298b838c016140fa565b975060408a013591508082111561473f57600080fd5b61474b8b838c016140fa565b965060608a013591508082111561476157600080fd5b61476d8b838c01614016565b955060808a013591508082111561478357600080fd5b61478f8b838c01614016565b945060a08a01359150808211156147a557600080fd5b6147b18b838c01614016565b935060c08a01359150808211156147c757600080fd5b506147d48a828b01614016565b91505092959891949750929550565b60006101208b83528060208401526147fd8184018c613f3e565b90508281036040840152614811818b613f3e565b90508281036060840152614825818a613f3e565b6080840198909852505060a081019490945260c084019290925260e083015261010090910152949350505050565b600080600080600080600060e0888a03121561486e57600080fd5b87356001600160401b038082111561488557600080fd5b6148918b838c01614087565b985060208a01359150808211156148a757600080fd5b6148b38b838c01614087565b975060408a01359150808211156148c957600080fd5b506148d68a828b01614087565b979a96995096976060810135975060808101359660a0820135965060c090910135945092505050565b6000806040838503121561491257600080fd5b61491b83613e6e565b915061441460208401613e6e565b600080600080600060a0868803121561494157600080fd5b61494a86613e6e565b945061495860208701613e6e565b9350604086013592506060860135915060808601356001600160401b0381111561498157600080fd5b6143e488828901614087565b60208082526024908201527f4f6e6c7920274d494e544552272063616e2063616c6c20746869732066756e636040820152633a34b7b760e11b606082015260800190565b600181811c908216806149e557607f821691505b6020821081036116c157634e487b7160e01b600052602260045260246000fd5b6000808354614a13816149d1565b60018281168015614a2b5760018114614a4057614a6f565b60ff1984168752821515830287019450614a6f565b8760005260208060002060005b85811015614a665781548a820152908401908201614a4d565b50505082870194505b50929695505050505050565b602080825260139082015272125d195b48191bd95cc81b9bdd08195e1a5cdd606a1b604082015260600190565b634e487b7160e01b600052601160045260246000fd5b80820180821115610b2957610b29614aa8565b6020808252601290820152714e6f206974656d7320617661696c61626c6560701b604082015260600190565b60208082526021908201527f4f6e6c792061646d696e2063616e2063616c6c20746869732066756e6374696f6040820152603760f91b606082015260800190565b6020808252602a908201527f4f6e6c79202741444d494e5f4d494e544552272063616e2063616c6c207468696040820152693990333ab731ba34b7b760b11b606082015260800190565b60208082526025908201527f4f6e6c79202743524541544f52272063616e2063616c6c20746869732066756e60408201526431ba34b7b760d91b606082015260800190565b6020808252818101527f417272617973206d7573742068617665207468652073616d65206c656e677468604082015260600190565b634e487b7160e01b600052603260045260246000fd5b600060018201614c2a57614c2a614aa8565b5060010190565b81810381811115610b2957610b29614aa8565b6020808252602e908201527f455243313135353a2063616c6c6572206973206e6f7420746f6b656e206f776e60408201526d195c881bdc88185c1c1c9bdd995960921b606082015260800190565b6020808252602b908201527f4f6e6c79202741444d494e5f43524541544f52272063616e2063616c6c20746860408201526a34b990333ab731ba34b7b760a91b606082015260800190565b601f821115610d6f57600081815260208120601f850160051c81016020861015614d045750805b601f850160051c820191505b8181101561342a57828155600101614d10565b81516001600160401b03811115614d3c57614d3c613fb1565b614d5081614d4a84546149d1565b84614cdd565b602080601f831160018114614d855760008415614d6d5750858301515b600019600386901b1c1916600185901b17855561342a565b600085815260208120601f198616915b82811015614db457888601518255948401946001909101908401614d95565b5085821015614dd25787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b60e081526000614df560e083018a613f3e565b8281036020840152614e07818a613f3e565b90508281036040840152614e1b8189613f3e565b9150508560608301528460808301528360a08301528260c083015298975050505050505050565b600060208284031215614e5457600080fd5b5051919050565b600060208284031215614e6d57600080fd5b8151613e6781614684565b60008251614e8a818460208701613f1a565b9190910192915050565b8082028115828204841417610b2957610b29614aa8565b60208082526023908201527f455243313135353a206275726e2066726f6d20746865207a65726f206164647260408201526265737360e81b606082015260800190565b60208082526024908201527f455243313135353a206275726e20616d6f756e7420657863656564732062616c604082015263616e636560e01b606082015260800190565b60208082526028908201527f455243313135353a2069647320616e6420616d6f756e7473206c656e677468206040820152670dad2e6dac2e8c6d60c31b606082015260800190565b60208082526025908201527f455243313135353a207472616e7366657220746f20746865207a65726f206164604082015264647265737360d81b606082015260800190565b6020808252602a908201527f455243313135353a20696e73756666696369656e742062616c616e636520666f60408201526939103a3930b739b332b960b11b606082015260800190565b60408152600061501c604083018561441d565b828103602084015261502e818561441d565b95945050505050565b6001600160a01b03868116825285166020820152604081018490526060810183905260a06080820181905260009061507190830184613f3e565b979650505050505050565b60006020828403121561508e57600080fd5b8151613e6781613ee7565b600060033d11156150b25760046000803e5060005160e01c5b90565b600060443d10156150c35790565b6040516003193d81016004833e81513d6001600160401b0381602484011181841117156150f257505050505090565b828501915081518181111561510a5750505050505090565b843d87010160208285010111156151245750505050505090565b61513360208286010187613fc7565b509095945050505050565b60208082526028908201527f455243313135353a204552433131353552656365697665722072656a656374656040820152676420746f6b656e7360c01b606082015260800190565b6001600160a01b0386811682528516602082015260a0604082018190526000906151b29083018661441d565b82810360608401526151c4818661441d565b905082810360808401526151d88185613f3e565b98975050505050505050565b7f416363657373436f6e74726f6c3a206163636f756e742000000000000000000081526000835161521c816017850160208801613f1a565b7001034b99036b4b9b9b4b733903937b6329607d1b601791840191820152835161524d816028840160208801613f1a565b01602801949350505050565b60008161526857615268614aa8565b50600019019056fe3c2519c4487d47714872f92cf90a50c25f5deaec2789dc2a497b1272df611db6f0887ba65ee2024ea881d91b74c2450ef19e1557f03bed3ea9f16b037cbe2dc997b108406cb1e375bd0f05a7345b4a1e35e533af66462f3b8af7b12205769b58e4e1d534b29f734db3c89d9b2f0c1fc752676594e7638f45cd3bc44c4dc5e280a2646970667358221220236f161be51c91c4210ffa7d3f9771fa966d29c8b98d97201454fecc197c784b64736f6c634300081100333c2519c4487d47714872f92cf90a50c25f5deaec2789dc2a497b1272df611db6f0887ba65ee2024ea881d91b74c2450ef19e1557f03bed3ea9f16b037cbe2dc997b108406cb1e375bd0f05a7345b4a1e35e533af66462f3b8af7b12205769b58e4e1d534b29f734db3c89d9b2f0c1fc752676594e7638f45cd3bc44c4dc5e280000000000000000000000000c043137a6616222bd2ee87457bbe868d862351cb
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000c043137a6616222bd2ee87457bbe868d862351cb
-----Decoded View---------------
Arg [0] : _tokenAddress (address): 0xc043137a6616222bd2ee87457bbe868d862351cb
-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 000000000000000000000000c043137a6616222bd2ee87457bbe868d862351cb