creation_sourcecode: {{
    "language": "Solidity",
    "sources": {
      "@openzeppelin/contracts/token/ERC1155/IERC1155.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC1155/IERC1155.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC165} from \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Required interface of an ERC1155 compliant contract, as defined in the\n * https://eips.ethereum.org/EIPS/eip-1155[EIP].\n */\ninterface IERC1155 is IERC165 {\n    /**\n     * @dev Emitted when `value` amount of tokens of type `id` are transferred from `from` to `to` by `operator`.\n     */\n    event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);\n\n    /**\n     * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all\n     * transfers.\n     */\n    event TransferBatch(\n        address indexed operator,\n        address indexed from,\n        address indexed to,\n        uint256[] ids,\n        uint256[] values\n    );\n\n    /**\n     * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to\n     * `approved`.\n     */\n    event ApprovalForAll(address indexed account, address indexed operator, bool approved);\n\n    /**\n     * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI.\n     *\n     * If an {URI} event was emitted for `id`, the standard\n     * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value\n     * returned by {IERC1155MetadataURI-uri}.\n     */\n    event URI(string value, uint256 indexed id);\n\n    /**\n     * @dev Returns the value of tokens of token type `id` owned by `account`.\n     *\n     * Requirements:\n     *\n     * - `account` cannot be the zero address.\n     */\n    function balanceOf(address account, uint256 id) external view returns (uint256);\n\n    /**\n     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}.\n     *\n     * Requirements:\n     *\n     * - `accounts` and `ids` must have the same length.\n     */\n    function balanceOfBatch(\n        address[] calldata accounts,\n        uint256[] calldata ids\n    ) external view returns (uint256[] memory);\n\n    /**\n     * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`,\n     *\n     * Emits an {ApprovalForAll} event.\n     *\n     * Requirements:\n     *\n     * - `operator` cannot be the caller.\n     */\n    function setApprovalForAll(address operator, bool approved) external;\n\n    /**\n     * @dev Returns true if `operator` is approved to transfer ``account``'s tokens.\n     *\n     * See {setApprovalForAll}.\n     */\n    function isApprovedForAll(address account, address operator) external view returns (bool);\n\n    /**\n     * @dev Transfers a `value` amount of tokens of type `id` from `from` to `to`.\n     *\n     * WARNING: This function can potentially allow a reentrancy attack when transferring tokens\n     * to an untrusted contract, when invoking {onERC1155Received} on the receiver.\n     * Ensure to follow the checks-effects-interactions pattern and consider employing\n     * reentrancy guards when interacting with untrusted contracts.\n     *\n     * Emits a {TransferSingle} event.\n     *\n     * Requirements:\n     *\n     * - `to` cannot be the zero address.\n     * - If the caller is not `from`, it must have been approved to spend ``from``'s tokens via {setApprovalForAll}.\n     * - `from` must have a balance of tokens of type `id` of at least `value` amount.\n     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the\n     * acceptance magic value.\n     */\n    function safeTransferFrom(address from, address to, uint256 id, uint256 value, bytes calldata data) external;\n\n    /**\n     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.\n     *\n     *\n     * WARNING: This function can potentially allow a reentrancy attack when transferring tokens\n     * to an untrusted contract, when invoking {onERC1155BatchReceived} on the receiver.\n     * Ensure to follow the checks-effects-interactions pattern and consider employing\n     * reentrancy guards when interacting with untrusted contracts.\n     *\n     * Emits a {TransferBatch} event.\n     *\n     * Requirements:\n     *\n     * - `ids` and `values` must have the same length.\n     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the\n     * acceptance magic value.\n     */\n    function safeBatchTransferFrom(\n        address from,\n        address to,\n        uint256[] calldata ids,\n        uint256[] calldata values,\n        bytes calldata data\n    ) external;\n}\n"
      },
      "@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC1155/IERC1155Receiver.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC165} from \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Interface that must be implemented by smart contracts in order to receive\n * ERC-1155 token transfers.\n */\ninterface IERC1155Receiver is IERC165 {\n    /**\n     * @dev Handles the receipt of a single ERC1155 token type. This function is\n     * called at the end of a `safeTransferFrom` after the balance has been updated.\n     *\n     * NOTE: To accept the transfer, this must return\n     * `bytes4(keccak256(\"onERC1155Received(address,address,uint256,uint256,bytes)\"))`\n     * (i.e. 0xf23a6e61, or its own function selector).\n     *\n     * @param operator The address which initiated the transfer (i.e. msg.sender)\n     * @param from The address which previously owned the token\n     * @param id The ID of the token being transferred\n     * @param value The amount of tokens being transferred\n     * @param data Additional data with no specified format\n     * @return `bytes4(keccak256(\"onERC1155Received(address,address,uint256,uint256,bytes)\"))` if transfer is allowed\n     */\n    function onERC1155Received(\n        address operator,\n        address from,\n        uint256 id,\n        uint256 value,\n        bytes calldata data\n    ) external returns (bytes4);\n\n    /**\n     * @dev Handles the receipt of a multiple ERC1155 token types. This function\n     * is called at the end of a `safeBatchTransferFrom` after the balances have\n     * been updated.\n     *\n     * NOTE: To accept the transfer(s), this must return\n     * `bytes4(keccak256(\"onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)\"))`\n     * (i.e. 0xbc197c81, or its own function selector).\n     *\n     * @param operator The address which initiated the batch transfer (i.e. msg.sender)\n     * @param from The address which previously owned the token\n     * @param ids An array containing ids of each token being transferred (order and length must match values array)\n     * @param values An array containing amounts of each token being transferred (order and length must match ids array)\n     * @param data Additional data with no specified format\n     * @return `bytes4(keccak256(\"onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)\"))` if transfer is allowed\n     */\n    function onERC1155BatchReceived(\n        address operator,\n        address from,\n        uint256[] calldata ids,\n        uint256[] calldata values,\n        bytes calldata data\n    ) external returns (bytes4);\n}\n"
      },
      "@openzeppelin/contracts/token/ERC1155/utils/ERC1155Holder.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC1155/utils/ERC1155Holder.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC165, ERC165} from \"../../../utils/introspection/ERC165.sol\";\nimport {IERC1155Receiver} from \"../IERC1155Receiver.sol\";\n\n/**\n * @dev Simple implementation of `IERC1155Receiver` that will allow a contract to hold ERC1155 tokens.\n *\n * IMPORTANT: When inheriting this contract, you must include a way to use the received tokens, otherwise they will be\n * stuck.\n */\nabstract contract ERC1155Holder is ERC165, IERC1155Receiver {\n    /**\n     * @dev See {IERC165-supportsInterface}.\n     */\n    function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {\n        return interfaceId == type(IERC1155Receiver).interfaceId || super.supportsInterface(interfaceId);\n    }\n\n    function onERC1155Received(\n        address,\n        address,\n        uint256,\n        uint256,\n        bytes memory\n    ) public virtual override returns (bytes4) {\n        return this.onERC1155Received.selector;\n    }\n\n    function onERC1155BatchReceived(\n        address,\n        address,\n        uint256[] memory,\n        uint256[] memory,\n        bytes memory\n    ) public virtual override returns (bytes4) {\n        return this.onERC1155BatchReceived.selector;\n    }\n}\n"
      },
      "@openzeppelin/contracts/token/ERC721/IERC721.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/IERC721.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC165} from \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Required interface of an ERC721 compliant contract.\n */\ninterface IERC721 is IERC165 {\n    /**\n     * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\n     */\n    event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n\n    /**\n     * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\n     */\n    event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\n\n    /**\n     * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\n     */\n    event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n    /**\n     * @dev Returns the number of tokens in ``owner``'s account.\n     */\n    function balanceOf(address owner) external view returns (uint256 balance);\n\n    /**\n     * @dev Returns the owner of the `tokenId` token.\n     *\n     * Requirements:\n     *\n     * - `tokenId` must exist.\n     */\n    function ownerOf(uint256 tokenId) external view returns (address owner);\n\n    /**\n     * @dev Safely transfers `tokenId` token from `from` to `to`.\n     *\n     * Requirements:\n     *\n     * - `from` cannot be the zero address.\n     * - `to` cannot be the zero address.\n     * - `tokenId` token must exist and be owned by `from`.\n     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon\n     *   a safe transfer.\n     *\n     * Emits a {Transfer} event.\n     */\n    function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;\n\n    /**\n     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n     * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n     *\n     * Requirements:\n     *\n     * - `from` cannot be the zero address.\n     * - `to` cannot be the zero address.\n     * - `tokenId` token must exist and be owned by `from`.\n     * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or\n     *   {setApprovalForAll}.\n     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon\n     *   a safe transfer.\n     *\n     * Emits a {Transfer} event.\n     */\n    function safeTransferFrom(address from, address to, uint256 tokenId) external;\n\n    /**\n     * @dev Transfers `tokenId` token from `from` to `to`.\n     *\n     * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721\n     * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must\n     * understand this adds an external call which potentially creates a reentrancy vulnerability.\n     *\n     * Requirements:\n     *\n     * - `from` cannot be the zero address.\n     * - `to` cannot be the zero address.\n     * - `tokenId` token must be owned by `from`.\n     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transferFrom(address from, address to, uint256 tokenId) external;\n\n    /**\n     * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n     * The approval is cleared when the token is transferred.\n     *\n     * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\n     *\n     * Requirements:\n     *\n     * - The caller must own the token or be an approved operator.\n     * - `tokenId` must exist.\n     *\n     * Emits an {Approval} event.\n     */\n    function approve(address to, uint256 tokenId) external;\n\n    /**\n     * @dev Approve or remove `operator` as an operator for the caller.\n     * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\n     *\n     * Requirements:\n     *\n     * - The `operator` cannot be the address zero.\n     *\n     * Emits an {ApprovalForAll} event.\n     */\n    function setApprovalForAll(address operator, bool approved) external;\n\n    /**\n     * @dev Returns the account approved for `tokenId` token.\n     *\n     * Requirements:\n     *\n     * - `tokenId` must exist.\n     */\n    function getApproved(uint256 tokenId) external view returns (address operator);\n\n    /**\n     * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n     *\n     * See {setApprovalForAll}\n     */\n    function isApprovedForAll(address owner, address operator) external view returns (bool);\n}\n"
      },
      "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/IERC721Receiver.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @title ERC721 token receiver interface\n * @dev Interface for any contract that wants to support safeTransfers\n * from ERC721 asset contracts.\n */\ninterface IERC721Receiver {\n    /**\n     * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\n     * by `operator` from `from`, this function is called.\n     *\n     * It must return its Solidity selector to confirm the token transfer.\n     * If any other value is returned or the interface is not implemented by the recipient, the transfer will be\n     * reverted.\n     *\n     * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.\n     */\n    function onERC721Received(\n        address operator,\n        address from,\n        uint256 tokenId,\n        bytes calldata data\n    ) external returns (bytes4);\n}\n"
      },
      "@openzeppelin/contracts/utils/Address.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n    /**\n     * @dev The ETH balance of the account is not enough to perform the operation.\n     */\n    error AddressInsufficientBalance(address account);\n\n    /**\n     * @dev There's no code at `target` (it is not a contract).\n     */\n    error AddressEmptyCode(address target);\n\n    /**\n     * @dev A call to an address target failed. The target may have reverted.\n     */\n    error FailedInnerCall();\n\n    /**\n     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n     * `recipient`, forwarding all available gas and reverting on errors.\n     *\n     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n     * of certain opcodes, possibly making contracts go over the 2300 gas limit\n     * imposed by `transfer`, making them unable to receive funds via\n     * `transfer`. {sendValue} removes this limitation.\n     *\n     * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n     *\n     * IMPORTANT: because control is transferred to `recipient`, care must be\n     * taken to not create reentrancy vulnerabilities. Consider using\n     * {ReentrancyGuard} or the\n     * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n     */\n    function sendValue(address payable recipient, uint256 amount) internal {\n        if (address(this).balance < amount) {\n            revert AddressInsufficientBalance(address(this));\n        }\n\n        (bool success, ) = recipient.call{value: amount}(\"\");\n        if (!success) {\n            revert FailedInnerCall();\n        }\n    }\n\n    /**\n     * @dev Performs a Solidity function call using a low level `call`. A\n     * plain `call` is an unsafe replacement for a function call: use this\n     * function instead.\n     *\n     * If `target` reverts with a revert reason or custom error, it is bubbled\n     * up by this function (like regular Solidity function calls). However, if\n     * the call reverted with no returned reason, this function reverts with a\n     * {FailedInnerCall} error.\n     *\n     * Returns the raw returned data. To convert to the expected return value,\n     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n     *\n     * Requirements:\n     *\n     * - `target` must be a contract.\n     * - calling `target` with `data` must not revert.\n     */\n    function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, 0);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but also transferring `value` wei to `target`.\n     *\n     * Requirements:\n     *\n     * - the calling contract must have an ETH balance of at least `value`.\n     * - the called Solidity function must be `payable`.\n     */\n    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n        if (address(this).balance < value) {\n            revert AddressInsufficientBalance(address(this));\n        }\n        (bool success, bytes memory returndata) = target.call{value: value}(data);\n        return verifyCallResultFromTarget(target, success, returndata);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but performing a static call.\n     */\n    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n        (bool success, bytes memory returndata) = target.staticcall(data);\n        return verifyCallResultFromTarget(target, success, returndata);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but performing a delegate call.\n     */\n    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n        (bool success, bytes memory returndata) = target.delegatecall(data);\n        return verifyCallResultFromTarget(target, success, returndata);\n    }\n\n    /**\n     * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target\n     * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an\n     * unsuccessful call.\n     */\n    function verifyCallResultFromTarget(\n        address target,\n        bool success,\n        bytes memory returndata\n    ) internal view returns (bytes memory) {\n        if (!success) {\n            _revert(returndata);\n        } else {\n            // only check if target is a contract if the call was successful and the return data is empty\n            // otherwise we already know that it was a contract\n            if (returndata.length == 0 && target.code.length == 0) {\n                revert AddressEmptyCode(target);\n            }\n            return returndata;\n        }\n    }\n\n    /**\n     * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the\n     * revert reason or with a default {FailedInnerCall} error.\n     */\n    function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {\n        if (!success) {\n            _revert(returndata);\n        } else {\n            return returndata;\n        }\n    }\n\n    /**\n     * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.\n     */\n    function _revert(bytes memory returndata) private pure {\n        // Look for revert reason and bubble it up if present\n        if (returndata.length > 0) {\n            // The easiest way to bubble the revert reason is using memory via assembly\n            /// @solidity memory-safe-assembly\n            assembly {\n                let returndata_size := mload(returndata)\n                revert(add(32, returndata), returndata_size)\n            }\n        } else {\n            revert FailedInnerCall();\n        }\n    }\n}\n"
      },
      "@openzeppelin/contracts/utils/introspection/ERC165.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC165} from \"./IERC165.sol\";\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n */\nabstract contract ERC165 is IERC165 {\n    /**\n     * @dev See {IERC165-supportsInterface}.\n     */\n    function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {\n        return interfaceId == type(IERC165).interfaceId;\n    }\n}\n"
      },
      "@openzeppelin/contracts/utils/introspection/IERC165.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n    /**\n     * @dev Returns true if this contract implements the interface defined by\n     * `interfaceId`. See the corresponding\n     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n     * to learn more about how these ids are created.\n     *\n     * This function call must use less than 30 000 gas.\n     */\n    function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n"
      },
      "contracts/CloneFactory.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// from https://github.com/optionality/clone-factory\npragma solidity 0.8.20;\n\n/*\n    The MIT License (MIT)\n    Copyright (c) 2018 Murray Software, LLC.\n    Permission is hereby granted, free of charge, to any person obtaining\n    a copy of this software and associated documentation files (the\n    \"Software\"), to deal in the Software without restriction, including\n    without limitation the rights to use, copy, modify, merge, publish,\n    distribute, sublicense, and/or sell copies of the Software, and to\n    permit persons to whom the Software is furnished to do so, subject to\n    the following conditions:\n    The above copyright notice and this permission notice shall be included\n    in all copies or substantial portions of the Software.\n    THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n    OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\n    IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\n    CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\n    TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n    SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n*/\n//solhint-disable max-line-length\n//solhint-disable no-inline-assembly\n\ncontract CloneFactory {\n  function createClone(address target, bytes32 salt)\n    internal\n    returns (address payable result)\n  {\n    bytes20 targetBytes = bytes20(target);\n    assembly {\n      // load the next free memory slot as a place to store the clone contract data\n      let clone := mload(0x40)\n\n      // The bytecode block below is responsible for contract initialization\n      // during deployment, it is worth noting the proxied contract constructor will not be called during\n      // the cloning procedure and that is why an initialization function needs to be called after the\n      // clone is created\n      mstore(\n        clone,\n        0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000\n      )\n\n      // This stores the address location of the implementation contract\n      // so that the proxy knows where to delegate call logic to\n      mstore(add(clone, 0x14), targetBytes)\n\n      // The bytecode block is the actual code that is deployed for each clone created.\n      // It forwards all calls to the already deployed implementation via a delegatecall\n      mstore(\n        add(clone, 0x28),\n        0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000\n      )\n\n      // deploy the contract using the CREATE2 opcode\n      // this deploys the minimal proxy defined above, which will proxy all\n      // calls to use the logic defined in the implementation contract `target`\n      result := create2(0, clone, 0x37, salt)\n    }\n  }\n\n  function isClone(address target, address query)\n    internal\n    view\n    returns (bool result)\n  {\n    bytes20 targetBytes = bytes20(target);\n    assembly {\n      // load the next free memory slot as a place to store the comparison clone\n      let clone := mload(0x40)\n\n      // The next three lines store the expected bytecode for a miniml proxy\n      // that targets `target` as its implementation contract\n      mstore(\n        clone,\n        0x363d3d373d3d3d363d7300000000000000000000000000000000000000000000\n      )\n      mstore(add(clone, 0xa), targetBytes)\n      mstore(\n        add(clone, 0x1e),\n        0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000\n      )\n\n      // the next two lines store the bytecode of the contract that we are checking in memory\n      let other := add(clone, 0x40)\n      extcodecopy(query, other, 0, 0x2d)\n\n      // Check if the expected bytecode equals the actual bytecode and return the result\n      result := and(\n        eq(mload(clone), mload(other)),\n        eq(mload(add(clone, 0xd)), mload(add(other, 0xd)))\n      )\n    }\n  }\n}\n"
      },
      "contracts/ERC20Interface.sol": {
        "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity 0.8.20;\n\n/**\n * Contract that exposes the needed erc20 token functions\n */\n\nabstract contract ERC20Interface {\n  // Send _value amount of tokens to address _to\n  function transfer(address _to, uint256 _value)\n    public\n    virtual\n    returns (bool success);\n\n  // Get the account balance of another account with address _owner\n  function balanceOf(address _owner)\n    public\n    view\n    virtual\n    returns (uint256 balance);\n}\n"
      },
      "contracts/ForwarderFactoryV4.sol": {
        "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.20;\nimport './ForwarderV4.sol';\nimport './CloneFactory.sol';\n\n/**\n * @title ForwarderFactoryV4\n * @notice This contract will deploy new forwarder contracts using the create2 opcode\n */\ncontract ForwarderFactoryV4 is CloneFactory {\n  address public immutable implementationAddress;\n\n  /**\n   * @notice Event triggered when a new forwarder is deployed\n   * @param newForwarderAddress Address of the newly deployed forwarder\n   * @param parentAddress Address to which the funds should be forwarded\n   * @param feeAddress Address which is allowed to call methods on forwarder contract alongwith the parentAddress\n   * @param shouldAutoFlushERC721 Whether to automatically flush ERC721 tokens or not\n   * @param shouldAutoFlushERC1155 Whether to automatically flush ERC1155 tokens or not\n   */\n  event ForwarderCreated(\n    address newForwarderAddress,\n    address parentAddress,\n    address feeAddress,\n    bool shouldAutoFlushERC721,\n    bool shouldAutoFlushERC1155\n  );\n\n  /**\n   * @notice Initializes the factory with the address of the current forwarder implementation\n   * @param _implementationAddress Address of the current forwarder implementation\n   */\n  constructor(address _implementationAddress) {\n    implementationAddress = _implementationAddress;\n  }\n\n  /**\n   * @notice Creates a new forwarder contract\n   * @param parent Address to which the funds should be forwarded\n   * @param feeAddress Address which is allowed to call methods on forwarder contract alongwith the parentAddress\n   * @param salt Salt to be used while deploying the contract\n   */\n  function createForwarder(\n    address parent,\n    address feeAddress,\n    bytes32 salt\n  ) external {\n    this.createForwarder(parent, feeAddress, salt, true, true);\n  }\n\n  /**\n   * @notice Creates a new forwarder contract\n   * @param parent Address to which the funds should be forwarded\n   * @param feeAddress Address which is allowed to call methods on forwarder contract alongwith the parentAddress\n   * @param salt Salt to be used while deploying the contract\n   * @param shouldAutoFlushERC721 Whether to automatically flush ERC721 tokens or not\n   * @param shouldAutoFlushERC1155 Whether to automatically flush ERC1155 tokens or not\n   */\n  function createForwarder(\n    address parent,\n    address feeAddress,\n    bytes32 salt,\n    bool shouldAutoFlushERC721,\n    bool shouldAutoFlushERC1155\n  ) external {\n    /// include the parent and fee address in the salt so any contract deployed directly relies on the parent address and the fee address\n    bytes32 finalSalt = keccak256(abi.encodePacked(parent, feeAddress, salt));\n\n    address payable clone = createClone(implementationAddress, finalSalt);\n    emit ForwarderCreated(\n      clone,\n      parent,\n      feeAddress,\n      shouldAutoFlushERC721,\n      shouldAutoFlushERC1155\n    );\n    ForwarderV4(clone).init(\n      parent,\n      feeAddress,\n      shouldAutoFlushERC721,\n      shouldAutoFlushERC1155\n    );\n  }\n}\n"
      },
      "contracts/ForwarderV4.sol": {
        "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.20;\nimport '@openzeppelin/contracts/token/ERC1155/IERC1155.sol';\nimport '@openzeppelin/contracts/token/ERC721/IERC721.sol';\nimport '@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol';\nimport '@openzeppelin/contracts/token/ERC1155/utils/ERC1155Holder.sol';\nimport './ERC20Interface.sol';\nimport './TransferHelper.sol';\nimport './IForwarderV4.sol';\n\n/**\n * @title ForwarderV4\n * @notice This contract will forward any incoming Ether or token to the parent address of the contract\n */\ncontract ForwarderV4 is IERC721Receiver, ERC1155Holder, IForwarderV4 {\n  /// @notice Any funds sent to this contract will be forwarded to this address\n  address public parentAddress;\n  /// @notice Address which is allowed to call methods on this contract alongwith the parentAddress\n  address public feeAddress;\n  bool public autoFlush721 = true;\n  bool public autoFlush1155 = true;\n\n  /**\n   * @notice Event triggered when a deposit is received in the forwarder\n   * @param from Address from which the deposit is received\n   * @param value Amount of Ether received\n   * @param data Data sent along with the deposit\n   */\n  event ForwarderDeposited(address from, uint256 value, bytes data);\n\n  /**\n   * @notice Modifier that will execute internal code block only if the sender is from the allowed addresses\n   */\n  modifier onlyAllowedAddress() {\n    require(\n      msg.sender == parentAddress || msg.sender == feeAddress,\n      'Address is not allowed'\n    );\n    _;\n  }\n\n  /**\n   * @notice Modifier that will execute internal code block only if the contract has not been initialized yet\n   */\n  modifier onlyUninitialized() {\n    require(parentAddress == address(0x0), 'Already initialized');\n    _;\n  }\n\n  /**\n   * @notice Default function; Gets called when Ether is deposited with no data, and forwards it to the parent address\n   */\n  receive() external payable {\n    flush();\n  }\n\n  /**\n   * @notice Default function; Gets called when data is sent but does not match any other function\n   */\n  fallback() external payable {\n    flush();\n  }\n\n  /**\n   * @notice Initialize the contract, and sets the destination address to that of the parent address\n   * @param _parentAddress Address to which the funds should be forwarded\n   * @param _feeAddress Address which is allowed to call methods on this contract alongwith the parentAddress\n   * @param _autoFlush721 Whether to automatically flush ERC721 tokens or not\n   * @param _autoFlush1155 Whether to automatically flush ERC1155 tokens or not\n   */\n  function init(\n    address _parentAddress,\n    address _feeAddress,\n    bool _autoFlush721,\n    bool _autoFlush1155\n  ) external onlyUninitialized {\n    require(_parentAddress != address(0x0), 'Invalid parent address');\n    parentAddress = _parentAddress;\n    require(_feeAddress != address(0x0), 'Invalid fee address');\n    feeAddress = _feeAddress;\n\n    uint256 value = address(this).balance;\n\n    /// @notice set whether we want to automatically flush erc721/erc1155 tokens or not\n    autoFlush721 = _autoFlush721;\n    autoFlush1155 = _autoFlush1155;\n\n    if (value == 0) {\n      return;\n    }\n\n    /**\n     * Since we are forwarding on initialization,\n     * we don't have the context of the original sender.\n     * We still emit an event about the forwarding but set\n     * the sender to the forwarder itself\n     */\n    emit ForwarderDeposited(address(this), value, msg.data);\n    (bool success, ) = parentAddress.call{ value: value }('');\n    require(success, 'Flush failed');\n  }\n\n  /**\n   * @inheritdoc IForwarderV4\n   */\n  function setAutoFlush721(bool autoFlush)\n    external\n    virtual\n    override\n    onlyAllowedAddress\n  {\n    autoFlush721 = autoFlush;\n  }\n\n  /**\n   * @inheritdoc IForwarderV4\n   */\n  function setAutoFlush1155(bool autoFlush)\n    external\n    virtual\n    override\n    onlyAllowedAddress\n  {\n    autoFlush1155 = autoFlush;\n  }\n\n  /**\n   * ERC721 standard callback function for when a ERC721 is transfered. The forwarder will send the nft\n   * to the base wallet once the nft contract invokes this method after transfering the nft.\n   *\n   * @param _operator The address which called `safeTransferFrom` function\n   * @param _from The address of the sender\n   * @param _tokenId The token id of the nft\n   * @param data Additional data with no specified format, sent in call to `_to`\n   */\n  function onERC721Received(\n    address _operator,\n    address _from,\n    uint256 _tokenId,\n    bytes memory data\n  ) external virtual override returns (bytes4) {\n    if (autoFlush721) {\n      IERC721 instance = IERC721(msg.sender);\n      require(\n        instance.supportsInterface(type(IERC721).interfaceId),\n        'The caller does not support the ERC721 interface'\n      );\n      /// this won't work for ERC721 re-entrancy\n      instance.safeTransferFrom(address(this), parentAddress, _tokenId, data);\n    }\n\n    return this.onERC721Received.selector;\n  }\n\n  /**\n   * @notice Method to allow for calls to other contracts. This method can only be called by the parent address\n   * @param target The target contract address whose method needs to be called\n   * @param value The amount of Ether to be sent\n   * @param data The calldata to be sent\n   */\n  function callFromParent(\n    address target,\n    uint256 value,\n    bytes calldata data\n  ) external returns (bytes memory) {\n    require(msg.sender == parentAddress, 'Only Parent');\n    (bool success, bytes memory returnedData) = target.call{ value: value }(\n      data\n    );\n    require(success, 'Parent call execution failed');\n\n    return returnedData;\n  }\n\n  /**\n   * @inheritdoc ERC1155Holder\n   */\n  function onERC1155Received(\n    address _operator,\n    address _from,\n    uint256 id,\n    uint256 value,\n    bytes memory data\n  ) public virtual override returns (bytes4) {\n    IERC1155 instance = IERC1155(msg.sender);\n    require(\n      instance.supportsInterface(type(IERC1155).interfaceId),\n      'The caller does not support the IERC1155 interface'\n    );\n\n    if (autoFlush1155) {\n      instance.safeTransferFrom(address(this), parentAddress, id, value, data);\n    }\n\n    return this.onERC1155Received.selector;\n  }\n\n  /**\n   * @inheritdoc ERC1155Holder\n   */\n  function onERC1155BatchReceived(\n    address _operator,\n    address _from,\n    uint256[] memory ids,\n    uint256[] memory values,\n    bytes memory data\n  ) public virtual override returns (bytes4) {\n    IERC1155 instance = IERC1155(msg.sender);\n    require(\n      instance.supportsInterface(type(IERC1155).interfaceId),\n      'The caller does not support the IERC1155 interface'\n    );\n\n    if (autoFlush1155) {\n      instance.safeBatchTransferFrom(\n        address(this),\n        parentAddress,\n        ids,\n        values,\n        data\n      );\n    }\n\n    return this.onERC1155BatchReceived.selector;\n  }\n\n  /**\n   * @inheritdoc IForwarderV4\n   */\n  function flushTokens(address tokenContractAddress)\n    external\n    virtual\n    override\n    onlyAllowedAddress\n  {\n    ERC20Interface instance = ERC20Interface(tokenContractAddress);\n    address forwarderAddress = address(this);\n    uint256 forwarderBalance = instance.balanceOf(forwarderAddress);\n    if (forwarderBalance == 0) {\n      return;\n    }\n\n    TransferHelper.safeTransfer(\n      tokenContractAddress,\n      parentAddress,\n      forwarderBalance\n    );\n  }\n\n  /**\n   * @inheritdoc IForwarderV4\n   */\n  function flushERC721Token(address tokenContractAddress, uint256 tokenId)\n    external\n    virtual\n    override\n    onlyAllowedAddress\n  {\n    IERC721 instance = IERC721(tokenContractAddress);\n    require(\n      instance.supportsInterface(type(IERC721).interfaceId),\n      'The tokenContractAddress does not support the ERC721 interface'\n    );\n\n    address ownerAddress = instance.ownerOf(tokenId);\n    instance.transferFrom(ownerAddress, parentAddress, tokenId);\n  }\n\n  /**\n   * @inheritdoc IForwarderV4\n   */\n  function flushERC1155Tokens(address tokenContractAddress, uint256 tokenId)\n    external\n    virtual\n    override\n    onlyAllowedAddress\n  {\n    IERC1155 instance = IERC1155(tokenContractAddress);\n    require(\n      instance.supportsInterface(type(IERC1155).interfaceId),\n      'The caller does not support the IERC1155 interface'\n    );\n\n    address forwarderAddress = address(this);\n    uint256 forwarderBalance = instance.balanceOf(forwarderAddress, tokenId);\n\n    instance.safeTransferFrom(\n      forwarderAddress,\n      parentAddress,\n      tokenId,\n      forwarderBalance,\n      ''\n    );\n  }\n\n  /**\n   * @inheritdoc IForwarderV4\n   */\n  function batchFlushERC1155Tokens(\n    address tokenContractAddress,\n    uint256[] calldata tokenIds\n  ) external virtual override onlyAllowedAddress {\n    IERC1155 instance = IERC1155(tokenContractAddress);\n    require(\n      instance.supportsInterface(type(IERC1155).interfaceId),\n      'The caller does not support the IERC1155 interface'\n    );\n\n    address forwarderAddress = address(this);\n    uint256 length = tokenIds.length;\n    uint256[] memory amounts = new uint256[](tokenIds.length);\n    for (uint256 i; i < length; i++) {\n      amounts[i] = instance.balanceOf(forwarderAddress, tokenIds[i]);\n    }\n\n    instance.safeBatchTransferFrom(\n      forwarderAddress,\n      parentAddress,\n      tokenIds,\n      amounts,\n      ''\n    );\n  }\n\n  /**\n   * @inheritdoc IForwarderV4\n   */\n  function batchFlushERC20Tokens(address[] calldata tokenContractAddresses)\n    external\n    virtual\n    override\n    onlyAllowedAddress\n  {\n    address forwarderAddress = address(this);\n    uint256 length = tokenContractAddresses.length;\n    for (uint256 i; i < length; i++) {\n      ERC20Interface instance = ERC20Interface(tokenContractAddresses[i]);\n      uint256 forwarderBalance = instance.balanceOf(forwarderAddress);\n      if (forwarderBalance == 0) {\n        continue;\n      }\n\n      TransferHelper.safeTransfer(\n        tokenContractAddresses[i],\n        parentAddress,\n        forwarderBalance\n      );\n    }\n  }\n\n  /**\n   * @notice Flush the entire balance of the contract to the parent address.\n   */\n  function flush() public {\n    uint256 value = address(this).balance;\n\n    if (value == 0) {\n      return;\n    }\n\n    emit ForwarderDeposited(msg.sender, value, msg.data);\n    (bool success, ) = parentAddress.call{ value: value }('');\n    require(success, 'Flush failed');\n  }\n\n  /**\n   * @inheritdoc IERC165\n   */\n  function supportsInterface(bytes4 interfaceId)\n    public\n    view\n    virtual\n    override(ERC1155Holder, IERC165)\n    returns (bool)\n  {\n    return\n      interfaceId == type(IForwarderV4).interfaceId ||\n      super.supportsInterface(interfaceId);\n  }\n}\n"
      },
      "contracts/IForwarderV4.sol": {
        "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.20;\n\nimport '@openzeppelin/contracts/utils/introspection/IERC165.sol';\n\ninterface IForwarderV4 is IERC165 {\n  /**\n   * Sets the autoflush721 parameter.\n   *\n   * @param autoFlush whether to autoflush erc721 tokens\n   */\n  function setAutoFlush721(bool autoFlush) external;\n\n  /**\n   * Sets the autoflush1155 parameter.\n   *\n   * @param autoFlush whether to autoflush erc1155 tokens\n   */\n  function setAutoFlush1155(bool autoFlush) external;\n\n  /**\n   * Execute a token transfer of the full balance from the forwarder to the parent address\n   *\n   * @param tokenContractAddress the address of the erc20 token contract\n   */\n  function flushTokens(address tokenContractAddress) external;\n\n  /**\n   * Execute a nft transfer from the forwarder to the parent address\n   *\n   * @param tokenContractAddress the address of the ERC721 NFT contract\n   * @param tokenId The token id of the nft\n   */\n  function flushERC721Token(address tokenContractAddress, uint256 tokenId)\n    external;\n\n  /**\n   * Execute a nft transfer from the forwarder to the parent address.\n   *\n   * @param tokenContractAddress the address of the ERC1155 NFT contract\n   * @param tokenId The token id of the nft\n   */\n  function flushERC1155Tokens(address tokenContractAddress, uint256 tokenId)\n    external;\n\n  /**\n   * Execute a batch nft transfer from the forwarder to the parent address.\n   *\n   * @param tokenContractAddress the address of the ERC1155 NFT contract\n   * @param tokenIds The token ids of the nfts\n   */\n  function batchFlushERC1155Tokens(\n    address tokenContractAddress,\n    uint256[] calldata tokenIds\n  ) external;\n\n  /**\n   * Execute a batch erc20 transfer from the forwarder to the parent address.\n   *\n   * @param tokenContractAddresses the addresses of the ERC20 token contracts\n   */\n  function batchFlushERC20Tokens(address[] calldata tokenContractAddresses)\n    external;\n}\n"
      },
      "contracts/TransferHelper.sol": {
        "content": "// SPDX-License-Identifier: GPL-3.0-or-later\n// source: https://github.com/Uniswap/solidity-lib/blob/master/contracts/libraries/TransferHelper.sol\npragma solidity 0.8.20;\n\nimport '@openzeppelin/contracts/utils/Address.sol';\n\n// helper methods for interacting with ERC20 tokens and sending ETH that do not consistently return true/false\nlibrary TransferHelper {\n  function safeTransfer(\n    address token,\n    address to,\n    uint256 value\n  ) internal {\n    // bytes4(keccak256(bytes('transfer(address,uint256)')));\n    (bool success, bytes memory data) = token.call(\n      abi.encodeWithSelector(0xa9059cbb, to, value)\n    );\n    require(\n      success && (data.length == 0 || abi.decode(data, (bool))),\n      'TransferHelper::safeTransfer: transfer failed'\n    );\n  }\n\n  function safeTransferFrom(\n    address token,\n    address from,\n    address to,\n    uint256 value\n  ) internal {\n    // bytes4(keccak256(bytes('transferFrom(address,address,uint256)')));\n    (bool success, bytes memory returndata) = token.call(\n      abi.encodeWithSelector(0x23b872dd, from, to, value)\n    );\n    Address.verifyCallResult(success, returndata);\n  }\n}\n"
      }
    },
    "settings": {
      "evmVersion": "paris",
      "optimizer": {
        "enabled": true,
        "runs": 1000
      },
      "outputSelection": {
        "*": {
          "*": [
            "evm.bytecode",
            "evm.deployedBytecode",
            "devdoc",
            "userdoc",
            "metadata",
            "abi"
          ]
        }
      },
      "libraries": {}
    }
  }}