Transaction Hash:
Block:
14267167 at Feb-24-2022 06:30:50 AM +UTC
Transaction Fee:
0.02224291835533524 ETH
$53.47
Gas Used:
171,016 Gas / 130.063376265 Gwei
Emitted Events:
209 |
ELEMENTAL.Approval( owner=[Sender] 0x902b02a3ab094f62f2682c256f99e9f4939d4022, approved=0x00000000...000000000, tokenId=554 )
|
210 |
ELEMENTAL.Transfer( from=[Sender] 0x902b02a3ab094f62f2682c256f99e9f4939d4022, to=0xB78A290b...9c238e536, tokenId=554 )
|
211 |
ELEMENTAL.Approval( owner=[Sender] 0x902b02a3ab094f62f2682c256f99e9f4939d4022, approved=0x00000000...000000000, tokenId=1284 )
|
212 |
ELEMENTAL.Transfer( from=[Sender] 0x902b02a3ab094f62f2682c256f99e9f4939d4022, to=0xB78A290b...9c238e536, tokenId=1284 )
|
213 |
ELEMENTAL.Approval( owner=[Sender] 0x902b02a3ab094f62f2682c256f99e9f4939d4022, approved=0x00000000...000000000, tokenId=1604 )
|
214 |
ELEMENTAL.Transfer( from=[Sender] 0x902b02a3ab094f62f2682c256f99e9f4939d4022, to=0xB78A290b...9c238e536, tokenId=1604 )
|
Account State Difference:
Address | Before | After | State Difference | ||
---|---|---|---|---|---|
0x7F101fE4...353f2B90c
Miner
| (Flexpool.io) | 5,399.974398483296961696 Eth | 5,399.974655007296961696 Eth | 0.000256524 | |
0x902b02a3...4939d4022 |
0.11064409767715723 Eth
Nonce: 126
|
0.08840117932182199 Eth
Nonce: 127
| 0.02224291835533524 | ||
0xC9677Cd8...f8D7A0425 |
Execution Trace
OwnableDelegateProxy.3f801f91( )
AuthenticatedProxy.proxyAssert( dest=0xC99f70bFD82fb7c8f8191fdfbFB735606b15e5c5, howToCall=1, calldata=0x68F0BCAA00000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000C9677CD8E9652F1B1AADD3429769B0EF8D7A0425000000000000000000000000C9677CD8E9652F1B1AADD3429769B0EF8D7A0425000000000000000000000000C9677CD8E9652F1B1AADD3429769B0EF8D7A042500000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006400000000000000000000000000000000000000000000000000000000000000640000000000000000000000000000000000000000000000000000000000000064000000000000000000000000000000000000000000000000000000000000012C23B872DD000000000000000000000000902B02A3AB094F62F2682C256F99E9F4939D4022000000000000000000000000B78A290B75709AAF66EEA479263EB7E9C238E536000000000000000000000000000000000000000000000000000000000000022A23B872DD000000000000000000000000902B02A3AB094F62F2682C256F99E9F4939D4022000000000000000000000000B78A290B75709AAF66EEA479263EB7E9C238E536000000000000000000000000000000000000000000000000000000000000050423B872DD000000000000000000000000902B02A3AB094F62F2682C256F99E9F4939D4022000000000000000000000000B78A290B75709AAF66EEA479263EB7E9C238E53600000000000000000000000000000000000000000000000000000000000006440000000000000000000000000000000000000000 )
WyvernAtomicizer.atomicize( addrs=[0xC9677Cd8e9652F1b1aaDd3429769b0Ef8D7A0425, 0xC9677Cd8e9652F1b1aaDd3429769b0Ef8D7A0425, 0xC9677Cd8e9652F1b1aaDd3429769b0Ef8D7A0425], values=[0, 0, 0], calldataLengths=[100, 100, 100], calldatas=0x23B872DD000000000000000000000000902B02A3AB094F62F2682C256F99E9F4939D4022000000000000000000000000B78A290B75709AAF66EEA479263EB7E9C238E536000000000000000000000000000000000000000000000000000000000000022A23B872DD000000000000000000000000902B02A3AB094F62F2682C256F99E9F4939D4022000000000000000000000000B78A290B75709AAF66EEA479263EB7E9C238E536000000000000000000000000000000000000000000000000000000000000050423B872DD000000000000000000000000902B02A3AB094F62F2682C256F99E9F4939D4022000000000000000000000000B78A290B75709AAF66EEA479263EB7E9C238E5360000000000000000000000000000000000000000000000000000000000000644 )
-
ELEMENTAL.transferFrom( from=0x902b02a3ab094f62f2682C256f99e9F4939d4022, to=0xB78A290b75709AaF66EeA479263Eb7E9c238e536, tokenId=554 )
-
ELEMENTAL.transferFrom( from=0x902b02a3ab094f62f2682C256f99e9F4939d4022, to=0xB78A290b75709AaF66EeA479263Eb7E9c238e536, tokenId=1284 )
-
ELEMENTAL.transferFrom( from=0x902b02a3ab094f62f2682C256f99e9F4939d4022, to=0xB78A290b75709AaF66EeA479263Eb7E9c238e536, tokenId=1604 )
-
File 1 of 4: OwnableDelegateProxy
File 2 of 4: ELEMENTAL
File 3 of 4: AuthenticatedProxy
File 4 of 4: WyvernAtomicizer
contract OwnedUpgradeabilityStorage { // Current implementation address internal _implementation; // Owner of the contract address private _upgradeabilityOwner; /** * @dev Tells the address of the owner * @return the address of the owner */ function upgradeabilityOwner() public view returns (address) { return _upgradeabilityOwner; } /** * @dev Sets the address of the owner */ function setUpgradeabilityOwner(address newUpgradeabilityOwner) internal { _upgradeabilityOwner = newUpgradeabilityOwner; } /** * @dev Tells the address of the current implementation * @return address of the current implementation */ function implementation() public view returns (address) { return _implementation; } /** * @dev Tells the proxy type (EIP 897) * @return Proxy type, 2 for forwarding proxy */ function proxyType() public pure returns (uint256 proxyTypeId) { return 2; } } contract Proxy { /** * @dev Tells the address of the implementation where every call will be delegated. * @return address of the implementation to which it will be delegated */ function implementation() public view returns (address); /** * @dev Tells the type of proxy (EIP 897) * @return Type of proxy, 2 for upgradeable proxy */ function proxyType() public pure returns (uint256 proxyTypeId); /** * @dev Fallback function allowing to perform a delegatecall to the given implementation. * This function will return whatever the implementation call returns */ function () payable public { address _impl = implementation(); require(_impl != address(0)); assembly { let ptr := mload(0x40) calldatacopy(ptr, 0, calldatasize) let result := delegatecall(gas, _impl, ptr, calldatasize, 0, 0) let size := returndatasize returndatacopy(ptr, 0, size) switch result case 0 { revert(ptr, size) } default { return(ptr, size) } } } } contract OwnedUpgradeabilityProxy is Proxy, OwnedUpgradeabilityStorage { /** * @dev Event to show ownership has been transferred * @param previousOwner representing the address of the previous owner * @param newOwner representing the address of the new owner */ event ProxyOwnershipTransferred(address previousOwner, address newOwner); /** * @dev This event will be emitted every time the implementation gets upgraded * @param implementation representing the address of the upgraded implementation */ event Upgraded(address indexed implementation); /** * @dev Upgrades the implementation address * @param implementation representing the address of the new implementation to be set */ function _upgradeTo(address implementation) internal { require(_implementation != implementation); _implementation = implementation; emit Upgraded(implementation); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyProxyOwner() { require(msg.sender == proxyOwner()); _; } /** * @dev Tells the address of the proxy owner * @return the address of the proxy owner */ function proxyOwner() public view returns (address) { return upgradeabilityOwner(); } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function transferProxyOwnership(address newOwner) public onlyProxyOwner { require(newOwner != address(0)); emit ProxyOwnershipTransferred(proxyOwner(), newOwner); setUpgradeabilityOwner(newOwner); } /** * @dev Allows the upgradeability owner to upgrade the current implementation of the proxy. * @param implementation representing the address of the new implementation to be set. */ function upgradeTo(address implementation) public onlyProxyOwner { _upgradeTo(implementation); } /** * @dev Allows the upgradeability owner to upgrade the current implementation of the proxy * and delegatecall the new implementation for initialization. * @param implementation representing the address of the new implementation to be set. * @param data represents the msg.data to bet sent in the low level call. This parameter may include the function * signature of the implementation to be called with the needed payload */ function upgradeToAndCall(address implementation, bytes data) payable public onlyProxyOwner { upgradeTo(implementation); require(address(this).delegatecall(data)); } } contract OwnableDelegateProxy is OwnedUpgradeabilityProxy { constructor(address owner, address initialImplementation, bytes calldata) public { setUpgradeabilityOwner(owner); _upgradeTo(initialImplementation); require(initialImplementation.delegatecall(calldata)); } }
File 2 of 4: ELEMENTAL
{"Address.sol":{"content":"// SPDX-License-Identifier: MIT\r\n\r\npragma solidity ^0.8.0;\r\n\r\n/**\r\n * @dev Collection of functions related to the address type\r\n */\r\nlibrary Address {\r\n /**\r\n * @dev Returns true if `account` is a contract.\r\n *\r\n * [IMPORTANT]\r\n * ====\r\n * It is unsafe to assume that an address for which this function returns\r\n * false is an externally-owned account (EOA) and not a contract.\r\n *\r\n * Among others, `isContract` will return false for the following\r\n * types of addresses:\r\n *\r\n * - an externally-owned account\r\n * - a contract in construction\r\n * - an address where a contract will be created\r\n * - an address where a contract lived, but was destroyed\r\n * ====\r\n */\r\n function isContract(address account) internal view returns (bool) {\r\n // This method relies on extcodesize, which returns 0 for contracts in\r\n // construction, since the code is only stored at the end of the\r\n // constructor execution.\r\n\r\n uint256 size;\r\n assembly {\r\n size := extcodesize(account)\r\n }\r\n return size \u003e 0;\r\n }\r\n\r\n /**\r\n * @dev Replacement for Solidity\u0027s `transfer`: sends `amount` wei to\r\n * `recipient`, forwarding all available gas and reverting on errors.\r\n *\r\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\r\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\r\n * imposed by `transfer`, making them unable to receive funds via\r\n * `transfer`. {sendValue} removes this limitation.\r\n *\r\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\r\n *\r\n * IMPORTANT: because control is transferred to `recipient`, care must be\r\n * taken to not create reentrancy vulnerabilities. Consider using\r\n * {ReentrancyGuard} or the\r\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\r\n */\r\n function sendValue(address payable recipient, uint256 amount) internal {\r\n require(address(this).balance \u003e= amount, \"Address: insufficient balance\");\r\n\r\n (bool success, ) = recipient.call{value: amount}(\"\");\r\n require(success, \"Address: unable to send value, recipient may have reverted\");\r\n }\r\n\r\n /**\r\n * @dev Performs a Solidity function call using a low level `call`. A\r\n * plain `call` is an unsafe replacement for a function call: use this\r\n * function instead.\r\n *\r\n * If `target` reverts with a revert reason, it is bubbled up by this\r\n * function (like regular Solidity function calls).\r\n *\r\n * Returns the raw returned data. To convert to the expected return value,\r\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\r\n *\r\n * Requirements:\r\n *\r\n * - `target` must be a contract.\r\n * - calling `target` with `data` must not revert.\r\n *\r\n * _Available since v3.1._\r\n */\r\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\r\n return functionCall(target, data, \"Address: low-level call failed\");\r\n }\r\n\r\n /**\r\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\r\n * `errorMessage` as a fallback revert reason when `target` reverts.\r\n *\r\n * _Available since v3.1._\r\n */\r\n function functionCall(\r\n address target,\r\n bytes memory data,\r\n string memory errorMessage\r\n ) internal returns (bytes memory) {\r\n return functionCallWithValue(target, data, 0, errorMessage);\r\n }\r\n\r\n /**\r\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\r\n * but also transferring `value` wei to `target`.\r\n *\r\n * Requirements:\r\n *\r\n * - the calling contract must have an ETH balance of at least `value`.\r\n * - the called Solidity function must be `payable`.\r\n *\r\n * _Available since v3.1._\r\n */\r\n function functionCallWithValue(\r\n address target,\r\n bytes memory data,\r\n uint256 value\r\n ) internal returns (bytes memory) {\r\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\r\n }\r\n\r\n /**\r\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\r\n * with `errorMessage` as a fallback revert reason when `target` reverts.\r\n *\r\n * _Available since v3.1._\r\n */\r\n function functionCallWithValue(\r\n address target,\r\n bytes memory data,\r\n uint256 value,\r\n string memory errorMessage\r\n ) internal returns (bytes memory) {\r\n require(address(this).balance \u003e= value, \"Address: insufficient balance for call\");\r\n require(isContract(target), \"Address: call to non-contract\");\r\n\r\n (bool success, bytes memory returndata) = target.call{value: value}(data);\r\n return verifyCallResult(success, returndata, errorMessage);\r\n }\r\n\r\n /**\r\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\r\n * but performing a static call.\r\n *\r\n * _Available since v3.3._\r\n */\r\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\r\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\r\n }\r\n\r\n /**\r\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\r\n * but performing a static call.\r\n *\r\n * _Available since v3.3._\r\n */\r\n function functionStaticCall(\r\n address target,\r\n bytes memory data,\r\n string memory errorMessage\r\n ) internal view returns (bytes memory) {\r\n require(isContract(target), \"Address: static call to non-contract\");\r\n\r\n (bool success, bytes memory returndata) = target.staticcall(data);\r\n return verifyCallResult(success, returndata, errorMessage);\r\n }\r\n\r\n /**\r\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\r\n * but performing a delegate call.\r\n *\r\n * _Available since v3.4._\r\n */\r\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\r\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\r\n }\r\n\r\n /**\r\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\r\n * but performing a delegate call.\r\n *\r\n * _Available since v3.4._\r\n */\r\n function functionDelegateCall(\r\n address target,\r\n bytes memory data,\r\n string memory errorMessage\r\n ) internal returns (bytes memory) {\r\n require(isContract(target), \"Address: delegate call to non-contract\");\r\n\r\n (bool success, bytes memory returndata) = target.delegatecall(data);\r\n return verifyCallResult(success, returndata, errorMessage);\r\n }\r\n\r\n /**\r\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn\u0027t, either by bubbling the\r\n * revert reason using the provided one.\r\n *\r\n * _Available since v4.3._\r\n */\r\n function verifyCallResult(\r\n bool success,\r\n bytes memory returndata,\r\n string memory errorMessage\r\n ) internal pure returns (bytes memory) {\r\n if (success) {\r\n return returndata;\r\n } else {\r\n // Look for revert reason and bubble it up if present\r\n if (returndata.length \u003e 0) {\r\n // The easiest way to bubble the revert reason is using memory via assembly\r\n\r\n assembly {\r\n let returndata_size := mload(returndata)\r\n revert(add(32, returndata), returndata_size)\r\n }\r\n } else {\r\n revert(errorMessage);\r\n }\r\n }\r\n }\r\n}"},"Context.sol":{"content":"// SPDX-License-Identifier: MIT\r\n\r\npragma solidity ^0.8.0;\r\n\r\n/**\r\n * @dev Provides information about the current execution context, including the\r\n * sender of the transaction and its data. While these are generally available\r\n * via msg.sender and msg.data, they should not be accessed in such a direct\r\n * manner, since when dealing with meta-transactions the account sending and\r\n * paying for execution may not be the actual sender (as far as an application\r\n * is concerned).\r\n *\r\n * This contract is only required for intermediate, library-like contracts.\r\n */\r\nabstract contract Context {\r\n function _msgSender() internal view virtual returns (address) {\r\n return msg.sender;\r\n }\r\n\r\n function _msgData() internal view virtual returns (bytes calldata) {\r\n return msg.data;\r\n }\r\n}"},"ECDSA.sol":{"content":"// SPDX-License-Identifier: MIT\r\n// OpenZeppelin Contracts v4.4.1 (utils/cryptography/ECDSA.sol)\r\n\r\npragma solidity ^0.8.0;\r\n\r\nimport \"./Strings.sol\";\r\n\r\n/**\r\n * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.\r\n *\r\n * These functions can be used to verify that a message was signed by the holder\r\n * of the private keys of a given address.\r\n */\r\nlibrary ECDSA {\r\n enum RecoverError {\r\n NoError,\r\n InvalidSignature,\r\n InvalidSignatureLength,\r\n InvalidSignatureS,\r\n InvalidSignatureV\r\n }\r\n\r\n function _throwError(RecoverError error) private pure {\r\n if (error == RecoverError.NoError) {\r\n return; // no error: do nothing\r\n } else if (error == RecoverError.InvalidSignature) {\r\n revert(\"ECDSA: invalid signature\");\r\n } else if (error == RecoverError.InvalidSignatureLength) {\r\n revert(\"ECDSA: invalid signature length\");\r\n } else if (error == RecoverError.InvalidSignatureS) {\r\n revert(\"ECDSA: invalid signature \u0027s\u0027 value\");\r\n } else if (error == RecoverError.InvalidSignatureV) {\r\n revert(\"ECDSA: invalid signature \u0027v\u0027 value\");\r\n }\r\n }\r\n\r\n /**\r\n * @dev Returns the address that signed a hashed message (`hash`) with\r\n * `signature` or error string. This address can then be used for verification purposes.\r\n *\r\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\r\n * this function rejects them by requiring the `s` value to be in the lower\r\n * half order, and the `v` value to be either 27 or 28.\r\n *\r\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\r\n * verification to be secure: it is possible to craft signatures that\r\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\r\n * this is by receiving a hash of the original message (which may otherwise\r\n * be too long), and then calling {toEthSignedMessageHash} on it.\r\n *\r\n * Documentation for signature generation:\r\n * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]\r\n * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]\r\n *\r\n * _Available since v4.3._\r\n */\r\n function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {\r\n // Check the signature length\r\n // - case 65: r,s,v signature (standard)\r\n // - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._\r\n if (signature.length == 65) {\r\n bytes32 r;\r\n bytes32 s;\r\n uint8 v;\r\n // ecrecover takes the signature parameters, and the only way to get them\r\n // currently is to use assembly.\r\n assembly {\r\n r := mload(add(signature, 0x20))\r\n s := mload(add(signature, 0x40))\r\n v := byte(0, mload(add(signature, 0x60)))\r\n }\r\n return tryRecover(hash, v, r, s);\r\n } else if (signature.length == 64) {\r\n bytes32 r;\r\n bytes32 vs;\r\n // ecrecover takes the signature parameters, and the only way to get them\r\n // currently is to use assembly.\r\n assembly {\r\n r := mload(add(signature, 0x20))\r\n vs := mload(add(signature, 0x40))\r\n }\r\n return tryRecover(hash, r, vs);\r\n } else {\r\n return (address(0), RecoverError.InvalidSignatureLength);\r\n }\r\n }\r\n\r\n /**\r\n * @dev Returns the address that signed a hashed message (`hash`) with\r\n * `signature`. This address can then be used for verification purposes.\r\n *\r\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\r\n * this function rejects them by requiring the `s` value to be in the lower\r\n * half order, and the `v` value to be either 27 or 28.\r\n *\r\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\r\n * verification to be secure: it is possible to craft signatures that\r\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\r\n * this is by receiving a hash of the original message (which may otherwise\r\n * be too long), and then calling {toEthSignedMessageHash} on it.\r\n */\r\n function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {\r\n (address recovered, RecoverError error) = tryRecover(hash, signature);\r\n _throwError(error);\r\n return recovered;\r\n }\r\n\r\n /**\r\n * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.\r\n *\r\n * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]\r\n *\r\n * _Available since v4.3._\r\n */\r\n function tryRecover(\r\n bytes32 hash,\r\n bytes32 r,\r\n bytes32 vs\r\n ) internal pure returns (address, RecoverError) {\r\n bytes32 s = vs \u0026 bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);\r\n uint8 v = uint8((uint256(vs) \u003e\u003e 255) + 27);\r\n return tryRecover(hash, v, r, s);\r\n }\r\n\r\n /**\r\n * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.\r\n *\r\n * _Available since v4.2._\r\n */\r\n function recover(\r\n bytes32 hash,\r\n bytes32 r,\r\n bytes32 vs\r\n ) internal pure returns (address) {\r\n (address recovered, RecoverError error) = tryRecover(hash, r, vs);\r\n _throwError(error);\r\n return recovered;\r\n }\r\n\r\n /**\r\n * @dev Overload of {ECDSA-tryRecover} that receives the `v`,\r\n * `r` and `s` signature fields separately.\r\n *\r\n * _Available since v4.3._\r\n */\r\n function tryRecover(\r\n bytes32 hash,\r\n uint8 v,\r\n bytes32 r,\r\n bytes32 s\r\n ) internal pure returns (address, RecoverError) {\r\n // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\r\n // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\r\n // the valid range for s in (301): 0 \u003c s \u003c secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most\r\n // signatures from current libraries generate a unique signature with an s-value in the lower half order.\r\n //\r\n // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value\r\n // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or\r\n // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept\r\n // these malleable signatures as well.\r\n if (uint256(s) \u003e 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\r\n return (address(0), RecoverError.InvalidSignatureS);\r\n }\r\n if (v != 27 \u0026\u0026 v != 28) {\r\n return (address(0), RecoverError.InvalidSignatureV);\r\n }\r\n\r\n // If the signature is valid (and not malleable), return the signer address\r\n address signer = ecrecover(hash, v, r, s);\r\n if (signer == address(0)) {\r\n return (address(0), RecoverError.InvalidSignature);\r\n }\r\n\r\n return (signer, RecoverError.NoError);\r\n }\r\n\r\n /**\r\n * @dev Overload of {ECDSA-recover} that receives the `v`,\r\n * `r` and `s` signature fields separately.\r\n */\r\n function recover(\r\n bytes32 hash,\r\n uint8 v,\r\n bytes32 r,\r\n bytes32 s\r\n ) internal pure returns (address) {\r\n (address recovered, RecoverError error) = tryRecover(hash, v, r, s);\r\n _throwError(error);\r\n return recovered;\r\n }\r\n\r\n /**\r\n * @dev Returns an Ethereum Signed Message, created from a `hash`. This\r\n * produces hash corresponding to the one signed with the\r\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\r\n * JSON-RPC method as part of EIP-191.\r\n *\r\n * See {recover}.\r\n */\r\n function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {\r\n // 32 is the length in bytes of hash,\r\n // enforced by the type signature above\r\n return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n32\", hash));\r\n }\r\n\r\n /**\r\n * @dev Returns an Ethereum Signed Message, created from `s`. This\r\n * produces hash corresponding to the one signed with the\r\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\r\n * JSON-RPC method as part of EIP-191.\r\n *\r\n * See {recover}.\r\n */\r\n function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {\r\n return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n\", Strings.toString(s.length), s));\r\n }\r\n\r\n /**\r\n * @dev Returns an Ethereum Signed Typed Data, created from a\r\n * `domainSeparator` and a `structHash`. This produces hash corresponding\r\n * to the one signed with the\r\n * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]\r\n * JSON-RPC method as part of EIP-712.\r\n *\r\n * See {recover}.\r\n */\r\n function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {\r\n return keccak256(abi.encodePacked(\"\\x19\\x01\", domainSeparator, structHash));\r\n }\r\n}"},"EIP712.sol":{"content":"// SPDX-License-Identifier: MIT\r\n// OpenZeppelin Contracts v4.4.1 (utils/cryptography/draft-EIP712.sol)\r\n\r\npragma solidity ^0.8.0;\r\n\r\nimport \"./ECDSA.sol\";\r\n\r\n/**\r\n * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data.\r\n *\r\n * The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible,\r\n * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding\r\n * they need in their contracts using a combination of `abi.encode` and `keccak256`.\r\n *\r\n * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding\r\n * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA\r\n * ({_hashTypedDataV4}).\r\n *\r\n * The implementation of the domain separator was designed to be as efficient as possible while still properly updating\r\n * the chain id to protect against replay attacks on an eventual fork of the chain.\r\n *\r\n * NOTE: This contract implements the version of the encoding known as \"v4\", as implemented by the JSON RPC method\r\n * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].\r\n *\r\n * _Available since v3.4._\r\n */\r\nabstract contract EIP712 {\r\n /* solhint-disable var-name-mixedcase */\r\n // Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to\r\n // invalidate the cached domain separator if the chain id changes.\r\n bytes32 private immutable _CACHED_DOMAIN_SEPARATOR;\r\n uint256 private immutable _CACHED_CHAIN_ID;\r\n address private immutable _CACHED_THIS;\r\n\r\n bytes32 private immutable _HASHED_NAME;\r\n bytes32 private immutable _HASHED_VERSION;\r\n bytes32 private immutable _TYPE_HASH;\r\n\r\n /* solhint-enable var-name-mixedcase */\r\n\r\n /**\r\n * @dev Initializes the domain separator and parameter caches.\r\n *\r\n * The meaning of `name` and `version` is specified in\r\n * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]:\r\n *\r\n * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.\r\n * - `version`: the current major version of the signing domain.\r\n *\r\n * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart\r\n * contract upgrade].\r\n */\r\n constructor(string memory name, string memory version) {\r\n bytes32 hashedName = keccak256(bytes(name));\r\n bytes32 hashedVersion = keccak256(bytes(version));\r\n bytes32 typeHash = keccak256(\r\n \"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\"\r\n );\r\n _HASHED_NAME = hashedName;\r\n _HASHED_VERSION = hashedVersion;\r\n _CACHED_CHAIN_ID = block.chainid;\r\n _CACHED_DOMAIN_SEPARATOR = _buildDomainSeparator(typeHash, hashedName, hashedVersion);\r\n _CACHED_THIS = address(this);\r\n _TYPE_HASH = typeHash;\r\n }\r\n\r\n /**\r\n * @dev Returns the domain separator for the current chain.\r\n */\r\n function _domainSeparatorV4() internal view returns (bytes32) {\r\n if (address(this) == _CACHED_THIS \u0026\u0026 block.chainid == _CACHED_CHAIN_ID) {\r\n return _CACHED_DOMAIN_SEPARATOR;\r\n } else {\r\n return _buildDomainSeparator(_TYPE_HASH, _HASHED_NAME, _HASHED_VERSION);\r\n }\r\n }\r\n\r\n function _buildDomainSeparator(\r\n bytes32 typeHash,\r\n bytes32 nameHash,\r\n bytes32 versionHash\r\n ) private view returns (bytes32) {\r\n return keccak256(abi.encode(typeHash, nameHash, versionHash, block.chainid, address(this)));\r\n }\r\n\r\n /**\r\n * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this\r\n * function returns the hash of the fully encoded EIP712 message for this domain.\r\n *\r\n * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:\r\n *\r\n * ```solidity\r\n * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(\r\n * keccak256(\"Mail(address to,string contents)\"),\r\n * mailTo,\r\n * keccak256(bytes(mailContents))\r\n * )));\r\n * address signer = ECDSA.recover(digest, signature);\r\n * ```\r\n */\r\n function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {\r\n return ECDSA.toTypedDataHash(_domainSeparatorV4(), structHash);\r\n }\r\n}"},"Elemental.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.2;\n\nimport \"./ERC721A.sol\";\nimport \"./Ownable.sol\";\nimport \"./ECDSA.sol\";\nimport \"./EIP712.sol\";\nimport \"./Payment.sol\";\n\ncontract ELEMENTAL is ERC721A, EIP712, Ownable, Payment {\n using Strings for uint256;\n string public baseURI;\n\n //starting ipfs hash to be changed using chainlink VRF (https://ipfs.io/ipfs/QmVqHFqSgw9kKLDZfcjGs5WGg1dtrQVzagX2kLgMfY2YfX/)\n\tstring public constant ipfs = \"QmVqHFqSgw9kKLDZfcjGs5WGg1dtrQVzagX2kLgMfY2YfX\";\n\n //signature\n string private constant SINGING_DOMAIN = \"ELEMENTAL\";\n string private constant SIGNATURE_VERSION = \"1\";\n\n //settings\n \tuint256 public maxSupply = 2022;\n\tbool public OGStatus = false;\n\tbool public allowlistStatus = false;\n\tbool public publicStatus = false;\n\tuint256 private priceOG = 0.2 ether;\n\tuint256 private priceAllowlist = 0.2 ether;\n\tuint256 private pricePublic = 0.3 ether;\n\tuint256 public maxMintPerTxOG = 2;\n\tuint256 public maxMintPerTxAllowlist = 1;\n\tuint256 public maxMintPerTxPublic = 3;\n uint256 public maxMintPerWalletOG = 2;\n\tuint256 public maxMintPerWalletAllowlist = 1;\n uint256 public maxMintPerWalletPublic = 3;\n\n //mappings\n mapping(address =\u003e uint256) private mintCountMapOG;\n mapping(address =\u003e uint256) private mintCountMapAllowlist;\n\t mapping(address =\u003e uint256) private mintCountMapPublic;\n mapping(address =\u003e uint256) private allowedMintCountMapOG;\n mapping(address =\u003e uint256) private allowedMintCountMapAllowlist;\n mapping(address =\u003e uint256) private allowedMintCountMapPublic;\n\n //shares\n\taddress[] private addressList = [\n\t\t0xb1270a3D1F50440B32d62D088Aa30556Dcc8F950,\n\t\t0x41Fb9227c703086B2d908E177A692EdCD3d7DE2C,\n\t\t0xEcc03efB7C0A7BD09A5cC7e954Ac42E8f949A0B5\n\t];\n\tuint[] private shareList = [70,\n\t\t\t\t\t\t\t\t25,\n\t\t\t\t\t\t\t\t5];\n\n constructor(\n \tstring memory _name,\n\tstring memory _symbol,\n\tstring memory _initBaseURI\n ) \n ERC721(_name, _symbol) \n EIP712(SINGING_DOMAIN, SIGNATURE_VERSION) \n Payment(addressList, shareList) {\n setURI(_initBaseURI); \n }\n\n\n \tfunction mintOG(uint256 _tokenAmount, string memory name, bytes memory signature) public payable {\n \tuint256 s = totalSupply();\n require(check(name, signature) == msg.sender, \"Signature Invalid\"); //server side signature\n require(OGStatus,\"OG sale is not active\");\n require(_tokenAmount \u003e 0, \"Mint more than 0\" );\n\t require(_tokenAmount \u003c= maxMintPerTxOG, \"Mint less\");\n\t require( s + _tokenAmount \u003c= maxSupply, \"Mint less\");\n\t require(msg.value \u003e= priceOG * _tokenAmount, \"ETH input is wrong\");\n require(allowedMintCountOG(msg.sender) \u003e= _tokenAmount,\"You minted too many\");\n\t\trequire(tx.origin == msg.sender);\n for (uint256 i = 0; i \u003c _tokenAmount; ++i) {\n _safeMint(msg.sender, s + i, \"\");\n \t}\n delete s;\n updateMintCountOG(msg.sender, _tokenAmount);\n }\n\n function mintAllowlist(uint256 _tokenAmount, string memory name, bytes memory signature) public payable {\n \tuint256 s = totalSupply();\n require(check(name, signature) == msg.sender, \"Signature Invalid\"); //server side signature\n require(allowlistStatus,\"Allowlist sale is not active\");\n require(_tokenAmount \u003e 0, \"Mint more than 0\" );\n\t require(_tokenAmount \u003c= maxMintPerTxAllowlist, \"Mint less\");\n\t require( s + _tokenAmount \u003c= maxSupply, \"Mint less\");\n\t require(msg.value \u003e= priceOG * _tokenAmount, \"ETH input is wrong\");\n require(allowedMintCountAllowlist(msg.sender) \u003e= _tokenAmount,\"You minted too many\");\n \trequire(tx.origin == msg.sender);\n\t for (uint256 i = 0; i \u003c _tokenAmount; ++i) {\n _safeMint(msg.sender, s + i, \"\");\n \t}\n delete s;\n updateMintCountAllowlist(msg.sender, _tokenAmount);\n }\n\n function mintPublic(uint256 _tokenAmount) public payable {\n \tuint256 s = totalSupply();\n require(publicStatus,\"Public sale is not active\");\n require(_tokenAmount \u003e 0, \"Mint more than 0\" );\n\t require(_tokenAmount \u003c= maxMintPerTxPublic, \"Mint less\");\n\t require( s + _tokenAmount \u003c= maxSupply, \"Mint less\");\n\t require(msg.value \u003e= pricePublic * _tokenAmount, \"ETH input is wrong\");\n require(allowedMintCountPublic(msg.sender) \u003e= _tokenAmount,\"You minted too many\");\n \trequire(tx.origin == msg.sender);\n\t for (uint256 i = 0; i \u003c _tokenAmount; ++i) {\n _safeMint(msg.sender, s + i, \"\");\n \t}\n delete s;\n\t updateMintCountPublic(msg.sender, _tokenAmount);\n }\n\n \t// admin minting\n\tfunction gift(uint[] calldata gifts, address[] calldata recipient) external onlyOwner{\n\trequire(gifts.length == recipient.length);\n\t\tuint g = 0;\n\t\tuint256 s = totalSupply();\n\t\t\tfor(uint i = 0; i \u003c gifts.length; ++i){\n\t\t\tg += gifts[i];\n\t\t}\n\trequire( s + g \u003c= maxSupply, \"Too many\" );\n\t\tdelete g;\n\t\t\tfor(uint i = 0; i \u003c recipient.length; ++i){\n\t\t\tfor(uint j = 0; j \u003c gifts[i]; ++j){\n\t\t_safeMint( recipient[i], s++, \"\" );\n\t\t\t}\n\t\t}\n\t\tdelete s;\t\n\t}\n\n function check(string memory name, bytes memory signature) public view returns (address) {\n return _verify( name, signature);\n }\n\n function _verify(string memory name, bytes memory signature) internal view returns (address) {\n bytes32 digest = _hash(name);\n return ECDSA.recover(digest, signature);\n }\n\n function _hash(string memory name) internal view returns (bytes32) {\n return _hashTypedDataV4(keccak256(abi.encode(\n keccak256(\"Web3Struct(string name)\"),\n keccak256(bytes(name))\n )));\n }\n\n\t//allow list + max per wallet counters\n function allowedMintCountOG(address minter) public view returns (uint256) {\n \treturn maxMintPerWalletOG - mintCountMapOG[minter];\n }\n\tfunction allowedMintCountAllowlist(address minter) public view returns (uint256) {\n \treturn maxMintPerWalletAllowlist - mintCountMapAllowlist[minter];\n }\n\tfunction allowedMintCountPublic(address minter) public view returns (uint256) {\n \treturn maxMintPerWalletPublic - mintCountMapPublic[minter];\n }\n\tfunction updateMintCountOG(address minter, uint256 count) private {\n \tmintCountMapOG[minter] += count;\n }\n\tfunction updateMintCountAllowlist(address minter, uint256 count) private {\n \tmintCountMapAllowlist[minter] += count;\n }\n\tfunction updateMintCountPublic(address minter, uint256 count) private {\n \tmintCountMapPublic[minter] += count;\n }\n\n\t//read metadata\n\tfunction _baseURI() internal view virtual returns (string memory) {\n\t\treturn baseURI;\n\t}\n\tfunction tokenURI(uint256 tokenId) public view virtual override returns (string memory) {\n\t\trequire(tokenId \u003c= maxSupply);\n\t\tstring memory currentBaseURI = _baseURI();\n\t\t\treturn bytes(currentBaseURI).length \u003e 0\t? string(abi.encodePacked(currentBaseURI, tokenId.toString())) : \"\";\n\t}\n\n\n //price switch\n\n\tfunction setPriceOG(uint256 _newPrice) public onlyOwner {\n\t\tpriceOG = _newPrice;\n\t}\n\tfunction setPriceAllowlist(uint256 _newPrice) public onlyOwner {\n\t\tpriceAllowlist = _newPrice;\n\t}\n\tfunction setPricePublic(uint256 _newPrice) public onlyOwner {\n\t\tpricePublic = _newPrice;\n\t}\n\n\t//max switch\n\tfunction setMaxPerTxAllowlist(uint256 _newMaxMintAmount) public onlyOwner {\n\t\tmaxMintPerTxAllowlist = _newMaxMintAmount;\n\t}\n\tfunction setMaxPerTxOG(uint256 _newMaxMintAmount) public onlyOwner {\n\t\tmaxMintPerTxOG = _newMaxMintAmount;\n\t}\n\tfunction setMaxPerTxPublic(uint256 _newMaxMintAmount) public onlyOwner {\n\t\tmaxMintPerTxPublic = _newMaxMintAmount;\n\t}\n\n //max switch\n\tfunction setMaxPerWalletOG(uint256 _newMaxMintAmount) public onlyOwner {\n\tmaxMintPerWalletOG = _newMaxMintAmount;\n\t}\n\tfunction setMaxPerWalletAllowlist(uint256 _newMaxMintAmount) public onlyOwner {\n\tmaxMintPerWalletAllowlist = _newMaxMintAmount;\n\t}\n\tfunction setMaxPerWalletPublic(uint256 _newMaxMintAmount) public onlyOwner {\n\tmaxMintPerWalletPublic = _newMaxMintAmount;\n\t}\n\n //onoff switch\n\tfunction setOG(bool _wlstatus) public onlyOwner {\n\t\tOGStatus = _wlstatus;\n\t}\n\tfunction setAllowlist(bool _wlstatus) public onlyOwner {\n\t\tallowlistStatus = _wlstatus;\n\t}\n\tfunction setP(bool _pstatus) public onlyOwner {\n\t\tpublicStatus = _pstatus;\n\t}\n\n\t//write metadata\n\tfunction setURI(string memory _newBaseURI) public onlyOwner {\n\t\tbaseURI = _newBaseURI;\n\t}\n\n}"},"ERC165.sol":{"content":"// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./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 *\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}"},"ERC721.sol":{"content":"// SPDX-License-Identifier: GPL-3.0\r\npragma solidity ^0.8.10;\r\nimport \"./IERC721.sol\";\r\nimport \"./IERC721Receiver.sol\";\r\nimport \"./IERC721Metadata.sol\";\r\nimport \"./Address.sol\";\r\nimport \"./Context.sol\";\r\nimport \"./ERC165.sol\";\r\n\r\nabstract contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {\r\n using Address for address;\r\n string private _name;\r\n string private _symbol;\r\n address[] internal _owners;\r\n mapping(uint256 =\u003e address) private _tokenApprovals;\r\n mapping(address =\u003e mapping(address =\u003e bool)) private _operatorApprovals; \r\n constructor(string memory name_, string memory symbol_) {\r\n _name = name_;\r\n _symbol = symbol_;\r\n } \r\n function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {\r\n return\r\n interfaceId == type(IERC721).interfaceId ||\r\n interfaceId == type(IERC721Metadata).interfaceId ||\r\n super.supportsInterface(interfaceId);\r\n }\r\n function balanceOf(address owner) public view virtual override returns (uint256) {\r\n require(owner != address(0), \"ERC721: balance query for the zero address\");\r\n uint count = 0;\r\n uint length = _owners.length;\r\n for( uint i = 0; i \u003c length; ++i ){\r\n if( owner == _owners[i] ){\r\n ++count;\r\n }\r\n }\r\n delete length;\r\n return count;\r\n }\r\n function ownerOf(uint256 tokenId) public view virtual override returns (address) {\r\n address owner = _owners[tokenId];\r\n require(owner != address(0), \"ERC721: owner query for nonexistent token\");\r\n return owner;\r\n }\r\n function name() public view virtual override returns (string memory) {\r\n return _name;\r\n }\r\n function symbol() public view virtual override returns (string memory) {\r\n return _symbol;\r\n }\r\n function approve(address to, uint256 tokenId) public virtual override {\r\n address owner = ERC721.ownerOf(tokenId);\r\n require(to != owner, \"ERC721: approval to current owner\");\r\n\r\n require(\r\n _msgSender() == owner || isApprovedForAll(owner, _msgSender()),\r\n \"ERC721: approve caller is not owner nor approved for all\"\r\n );\r\n\r\n _approve(to, tokenId);\r\n }\r\n function getApproved(uint256 tokenId) public view virtual override returns (address) {\r\n require(_exists(tokenId), \"ERC721: approved query for nonexistent token\");\r\n\r\n return _tokenApprovals[tokenId];\r\n }\r\n function setApprovalForAll(address operator, bool approved) public virtual override {\r\n require(operator != _msgSender(), \"ERC721: approve to caller\");\r\n\r\n _operatorApprovals[_msgSender()][operator] = approved;\r\n emit ApprovalForAll(_msgSender(), operator, approved);\r\n }\r\n function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {\r\n return _operatorApprovals[owner][operator];\r\n }\r\n function transferFrom(\r\n address from,\r\n address to,\r\n uint256 tokenId\r\n ) public virtual override {\r\n //solhint-disable-next-line max-line-length\r\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: transfer caller is not owner nor approved\");\r\n\r\n _transfer(from, to, tokenId);\r\n }\r\n function safeTransferFrom(\r\n address from,\r\n address to,\r\n uint256 tokenId\r\n ) public virtual override {\r\n safeTransferFrom(from, to, tokenId, \"\");\r\n }\r\n function safeTransferFrom(\r\n address from,\r\n address to,\r\n uint256 tokenId,\r\n bytes memory _data\r\n ) public virtual override {\r\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: transfer caller is not owner nor approved\");\r\n _safeTransfer(from, to, tokenId, _data);\r\n } \r\n function _safeTransfer(\r\n address from,\r\n address to,\r\n uint256 tokenId,\r\n bytes memory _data\r\n ) internal virtual {\r\n _transfer(from, to, tokenId);\r\n require(_checkOnERC721Received(from, to, tokenId, _data), \"ERC721: transfer to non ERC721Receiver implementer\");\r\n }\r\n\tfunction _exists(uint256 tokenId) internal view virtual returns (bool) {\r\n return tokenId \u003c _owners.length \u0026\u0026 _owners[tokenId] != address(0);\r\n }\r\n\tfunction _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {\r\n require(_exists(tokenId), \"ERC721: operator query for nonexistent token\");\r\n address owner = ERC721.ownerOf(tokenId);\r\n return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender));\r\n }\r\n\tfunction _safeMint(address to, uint256 tokenId) internal virtual {\r\n _safeMint(to, tokenId, \"\");\r\n }\r\n\tfunction _safeMint(\r\n address to,\r\n uint256 tokenId,\r\n bytes memory _data\r\n ) internal virtual {\r\n _mint(to, tokenId);\r\n require(\r\n _checkOnERC721Received(address(0), to, tokenId, _data),\r\n \"ERC721: transfer to non ERC721Receiver implementer\"\r\n );\r\n }\r\n\tfunction _mint(address to, uint256 tokenId) internal virtual {\r\n require(to != address(0), \"ERC721: mint to the zero address\");\r\n require(!_exists(tokenId), \"ERC721: token already minted\");\r\n\r\n _beforeTokenTransfer(address(0), to, tokenId);\r\n _owners.push(to);\r\n\r\n emit Transfer(address(0), to, tokenId);\r\n }\r\n\tfunction _burn(uint256 tokenId) internal virtual {\r\n address owner = ERC721.ownerOf(tokenId);\r\n\r\n _beforeTokenTransfer(owner, address(0), tokenId);\r\n\r\n // Clear approvals\r\n _approve(address(0), tokenId);\r\n _owners[tokenId] = address(0);\r\n\r\n emit Transfer(owner, address(0), tokenId);\r\n }\r\n\tfunction _transfer(\r\n address from,\r\n address to,\r\n uint256 tokenId\r\n ) internal virtual {\r\n require(ERC721.ownerOf(tokenId) == from, \"ERC721: transfer of token that is not own\");\r\n require(to != address(0), \"ERC721: transfer to the zero address\");\r\n\r\n _beforeTokenTransfer(from, to, tokenId);\r\n\r\n // Clear approvals from the previous owner\r\n _approve(address(0), tokenId);\r\n _owners[tokenId] = to;\r\n\r\n emit Transfer(from, to, tokenId);\r\n }\r\n\tfunction _approve(address to, uint256 tokenId) internal virtual {\r\n _tokenApprovals[tokenId] = to;\r\n emit Approval(ERC721.ownerOf(tokenId), to, tokenId);\r\n }\r\n\tfunction _checkOnERC721Received(\r\n address from,\r\n address to,\r\n uint256 tokenId,\r\n bytes memory _data\r\n ) private returns (bool) {\r\n if (to.isContract()) {\r\n try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {\r\n return retval == IERC721Receiver.onERC721Received.selector;\r\n } catch (bytes memory reason) {\r\n if (reason.length == 0) {\r\n revert(\"ERC721: transfer to non ERC721Receiver implementer\");\r\n } else {\r\n assembly {\r\n revert(add(32, reason), mload(reason))\r\n }\r\n }\r\n }\r\n } else {\r\n return true;\r\n }\r\n }\r\n\tfunction _beforeTokenTransfer(\r\n address from,\r\n address to,\r\n uint256 tokenId\r\n ) internal virtual {}\r\n}"},"ERC721A.sol":{"content":"// SPDX-License-Identifier: GPL-3.0\r\npragma solidity ^0.8.10;\r\nimport \"./ERC721.sol\";\r\nimport \"./IERC721Enumerable.sol\";\r\nabstract contract ERC721A is ERC721, IERC721Enumerable {\r\n function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) {\r\n return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId);\r\n }\r\n function tokenOfOwnerByIndex(address owner, uint256 index) public view override returns (uint256 tokenId) {\r\n require(index \u003c ERC721.balanceOf(owner), \"ERC721Enum: owner ioob\");\r\n uint count;\r\n for( uint i; i \u003c _owners.length; ++i ){\r\n if( owner == _owners[i] ){\r\n if( count == index )\r\n return i;\r\n else\r\n ++count;\r\n }\r\n }\r\n require(false, \"ERC721Enum: owner ioob\");\r\n }\r\n function tokensOfOwner(address owner) public view returns (uint256[] memory) {\r\n require(0 \u003c ERC721.balanceOf(owner), \"ERC721Enum: owner ioob\");\r\n uint256 tokenCount = balanceOf(owner);\r\n uint256[] memory tokenIds = new uint256[](tokenCount);\r\n for (uint256 i = 0; i \u003c tokenCount; i++) {\r\n tokenIds[i] = tokenOfOwnerByIndex(owner, i);\r\n }\r\n return tokenIds;\r\n }\r\n function totalSupply() public view virtual override returns (uint256) {\r\n return _owners.length;\r\n }\r\n function tokenByIndex(uint256 index) public view virtual override returns (uint256) {\r\n require(index \u003c ERC721A.totalSupply(), \"ERC721Enum: global ioob\");\r\n return index;\r\n }\r\n}"},"Guard.sol":{"content":"// SPDX-License-Identifier: MIT\r\n\r\npragma solidity ^0.8.0;\r\n\r\n/**\r\n * @dev Contract module that helps prevent reentrant calls to a function.\r\n *\r\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\r\n * available, which can be applied to functions to make sure there are no nested\r\n * (reentrant) calls to them.\r\n *\r\n * Note that because there is a single `nonReentrant` guard, functions marked as\r\n * `nonReentrant` may not call one another. This can be worked around by making\r\n * those functions `private`, and then adding `external` `nonReentrant` entry\r\n * points to them.\r\n *\r\n * TIP: If you would like to learn more about reentrancy and alternative ways\r\n * to protect against it, check out our blog post\r\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\r\n */\r\nabstract contract Guard {\r\n // Booleans are more expensive than uint256 or any type that takes up a full\r\n // word because each write operation emits an extra SLOAD to first read the\r\n // slot\u0027s contents, replace the bits taken up by the boolean, and then write\r\n // back. This is the compiler\u0027s defense against contract upgrades and\r\n // pointer aliasing, and it cannot be disabled.\r\n\r\n // The values being non-zero value makes deployment a bit more expensive,\r\n // but in exchange the refund on every call to nonReentrant will be lower in\r\n // amount. Since refunds are capped to a percentage of the total\r\n // transaction\u0027s gas, it is best to keep them low in cases like this one, to\r\n // increase the likelihood of the full refund coming into effect.\r\n uint256 private constant _NOT_ENTERED = 1;\r\n uint256 private constant _ENTERED = 2;\r\n\r\n uint256 private _status;\r\n\r\n constructor() {\r\n _status = _NOT_ENTERED;\r\n }\r\n\r\n /**\r\n * @dev Prevents a contract from calling itself, directly or indirectly.\r\n * Calling a `nonReentrant` function from another `nonReentrant`\r\n * function is not supported. It is possible to prevent this from happening\r\n * by making the `nonReentrant` function external, and make it call a\r\n * `private` function that does the actual work.\r\n */\r\n modifier noRentry() {\r\n // On the first call to nonReentrant, _notEntered will be true\r\n require(_status != _ENTERED, \"ReentrancyGuard: reentrant call\");\r\n\r\n // Any calls to nonReentrant after this point will fail\r\n _status = _ENTERED;\r\n\r\n _;\r\n\r\n // By storing the original value once again, a refund is triggered (see\r\n // https://eips.ethereum.org/EIPS/eip-2200)\r\n _status = _NOT_ENTERED;\r\n }\r\n}"},"IERC165.sol":{"content":"// SPDX-License-Identifier: MIT\r\n\r\npragma solidity ^0.8.0;\r\n\r\n/**\r\n * @dev Interface of the ERC165 standard, as defined in the\r\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\r\n *\r\n * Implementers can declare support of contract interfaces, which can then be\r\n * queried by others ({ERC165Checker}).\r\n *\r\n * For an implementation, see {ERC165}.\r\n */\r\ninterface IERC165 {\r\n /**\r\n * @dev Returns true if this contract implements the interface defined by\r\n * `interfaceId`. See the corresponding\r\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\r\n * to learn more about how these ids are created.\r\n *\r\n * This function call must use less than 30 000 gas.\r\n */\r\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\r\n}"},"IERC721.sol":{"content":"// SPDX-License-Identifier: MIT\r\n\r\npragma solidity ^0.8.0;\r\n\r\nimport \"./IERC165.sol\";\r\n\r\n/**\r\n * @dev Required interface of an ERC721 compliant contract.\r\n */\r\ninterface IERC721 is IERC165 {\r\n /**\r\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\r\n */\r\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\r\n\r\n /**\r\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\r\n */\r\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\r\n\r\n /**\r\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\r\n */\r\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\r\n\r\n /**\r\n * @dev Returns the number of tokens in ``owner``\u0027s account.\r\n */\r\n function balanceOf(address owner) external view returns (uint256 balance);\r\n\r\n /**\r\n * @dev Returns the owner of the `tokenId` token.\r\n *\r\n * Requirements:\r\n *\r\n * - `tokenId` must exist.\r\n */\r\n function ownerOf(uint256 tokenId) external view returns (address owner);\r\n\r\n /**\r\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\r\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\r\n *\r\n * Requirements:\r\n *\r\n * - `from` cannot be the zero address.\r\n * - `to` cannot be the zero address.\r\n * - `tokenId` token must exist and be owned by `from`.\r\n * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.\r\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\r\n *\r\n * Emits a {Transfer} event.\r\n */\r\n function safeTransferFrom(\r\n address from,\r\n address to,\r\n uint256 tokenId\r\n ) external;\r\n\r\n /**\r\n * @dev Transfers `tokenId` token from `from` to `to`.\r\n *\r\n * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.\r\n *\r\n * Requirements:\r\n *\r\n * - `from` cannot be the zero address.\r\n * - `to` cannot be the zero address.\r\n * - `tokenId` token must be owned by `from`.\r\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\r\n *\r\n * Emits a {Transfer} event.\r\n */\r\n function transferFrom(\r\n address from,\r\n address to,\r\n uint256 tokenId\r\n ) external;\r\n\r\n /**\r\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\r\n * The approval is cleared when the token is transferred.\r\n *\r\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\r\n *\r\n * Requirements:\r\n *\r\n * - The caller must own the token or be an approved operator.\r\n * - `tokenId` must exist.\r\n *\r\n * Emits an {Approval} event.\r\n */\r\n function approve(address to, uint256 tokenId) external;\r\n\r\n /**\r\n * @dev Returns the account approved for `tokenId` token.\r\n *\r\n * Requirements:\r\n *\r\n * - `tokenId` must exist.\r\n */\r\n function getApproved(uint256 tokenId) external view returns (address operator);\r\n\r\n /**\r\n * @dev Approve or remove `operator` as an operator for the caller.\r\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\r\n *\r\n * Requirements:\r\n *\r\n * - The `operator` cannot be the caller.\r\n *\r\n * Emits an {ApprovalForAll} event.\r\n */\r\n function setApprovalForAll(address operator, bool _approved) external;\r\n\r\n /**\r\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\r\n *\r\n * See {setApprovalForAll}\r\n */\r\n function isApprovedForAll(address owner, address operator) external view returns (bool);\r\n\r\n /**\r\n * @dev Safely transfers `tokenId` token from `from` to `to`.\r\n *\r\n * Requirements:\r\n *\r\n * - `from` cannot be the zero address.\r\n * - `to` cannot be the zero address.\r\n * - `tokenId` token must exist and be owned by `from`.\r\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\r\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\r\n *\r\n * Emits a {Transfer} event.\r\n */\r\n function safeTransferFrom(\r\n address from,\r\n address to,\r\n uint256 tokenId,\r\n bytes calldata data\r\n ) external;\r\n}"},"IERC721Enumerable.sol":{"content":"// SPDX-License-Identifier: MIT\r\n\r\npragma solidity ^0.8.0;\r\n\r\nimport \"./IERC721.sol\";\r\n\r\n/**\r\n * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension\r\n * @dev See https://eips.ethereum.org/EIPS/eip-721\r\n */\r\ninterface IERC721Enumerable is IERC721 {\r\n /**\r\n * @dev Returns the total amount of tokens stored by the contract.\r\n */\r\n function totalSupply() external view returns (uint256);\r\n\r\n /**\r\n * @dev Returns a token ID owned by `owner` at a given `index` of its token list.\r\n * Use along with {balanceOf} to enumerate all of ``owner``\u0027s tokens.\r\n */\r\n function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId);\r\n\r\n /**\r\n * @dev Returns a token ID at a given `index` of all the tokens stored by the contract.\r\n * Use along with {totalSupply} to enumerate all tokens.\r\n */\r\n function tokenByIndex(uint256 index) external view returns (uint256);\r\n}"},"IERC721Metadata.sol":{"content":"// SPDX-License-Identifier: MIT\r\n\r\npragma solidity ^0.8.0;\r\n\r\nimport \"./IERC721.sol\";\r\n\r\n/**\r\n * @title ERC-721 Non-Fungible Token Standard, optional metadata extension\r\n * @dev See https://eips.ethereum.org/EIPS/eip-721\r\n */\r\ninterface IERC721Metadata is IERC721 {\r\n /**\r\n * @dev Returns the token collection name.\r\n */\r\n function name() external view returns (string memory);\r\n\r\n /**\r\n * @dev Returns the token collection symbol.\r\n */\r\n function symbol() external view returns (string memory);\r\n\r\n /**\r\n * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.\r\n */\r\n function tokenURI(uint256 tokenId) external view returns (string memory);\r\n}"},"IERC721Receiver.sol":{"content":"// SPDX-License-Identifier: MIT\r\n\r\npragma solidity ^0.8.0;\r\n\r\n/**\r\n * @title ERC721 token receiver interface\r\n * @dev Interface for any contract that wants to support safeTransfers\r\n * from ERC721 asset contracts.\r\n */\r\ninterface IERC721Receiver {\r\n /**\r\n * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\r\n * by `operator` from `from`, this function is called.\r\n *\r\n * It must return its Solidity selector to confirm the token transfer.\r\n * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.\r\n *\r\n * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`.\r\n */\r\n function onERC721Received(\r\n address operator,\r\n address from,\r\n uint256 tokenId,\r\n bytes calldata data\r\n ) external returns (bytes4);\r\n}"},"Ownable.sol":{"content":"// SPDX-License-Identifier: MIT\r\n\r\npragma solidity ^0.8.0;\r\n\r\nimport \"./Context.sol\";\r\n\r\n/**\r\n * @dev Contract module which provides a basic access control mechanism, where\r\n * there is an account (an owner) that can be granted exclusive access to\r\n * specific functions.\r\n *\r\n * By default, the owner account will be the one that deploys the contract. This\r\n * can later be changed with {transferOwnership}.\r\n *\r\n * This module is used through inheritance. It will make available the modifier\r\n * `onlyOwner`, which can be applied to your functions to restrict their use to\r\n * the owner.\r\n */\r\nabstract contract Ownable is Context {\r\n address private _owner;\r\n\r\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\r\n\r\n /**\r\n * @dev Initializes the contract setting the deployer as the initial owner.\r\n */\r\n constructor() {\r\n _setOwner(_msgSender());\r\n }\r\n /**\r\n * @dev Returns the address of the current owner.\r\n */\r\n function owner() public view virtual returns (address) {\r\n return _owner;\r\n }\r\n\r\n /**\r\n * @dev Throws if called by any account other than the owner.\r\n */\r\n modifier onlyOwner() {\r\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\r\n _;\r\n }\r\n\r\n /**\r\n * @dev Leaves the contract without owner. It will not be possible to call\r\n * `onlyOwner` functions anymore. Can only be called by the current owner.\r\n *\r\n * NOTE: Renouncing ownership will leave the contract without an owner,\r\n * thereby removing any functionality that is only available to the owner.\r\n */\r\n function renounceOwnership() public virtual onlyOwner {\r\n _setOwner(address(0));\r\n }\r\n\r\n /**\r\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\r\n * Can only be called by the current owner.\r\n */\r\n function transferOwnership(address newOwner) public virtual onlyOwner {\r\n require(newOwner != address(0), \"Ownable: new owner is the zero address\");\r\n _setOwner(newOwner);\r\n }\r\n\r\n function _setOwner(address newOwner) private {\r\n address oldOwner = _owner;\r\n _owner = newOwner;\r\n emit OwnershipTransferred(oldOwner, newOwner);\r\n }\r\n}"},"Payment.sol":{"content":"// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./Address.sol\";\nimport \"./Context.sol\";\nimport \"./SafeMath.sol\";\n\n/**\n * @title PaymentSplitter\n * @dev This contract allows to split Ether payments among a group of accounts. The sender does not need to be aware\n * that the Ether will be split in this way, since it is handled transparently by the contract.\n *\n * The split can be in equal parts or in any other arbitrary proportion. The way this is specified is by assigning each\n * account to a number of shares. Of all the Ether that this contract receives, each account will then be able to claim\n * an amount proportional to the percentage of total shares they were assigned.\n *\n * `PaymentSplitter` follows a _pull payment_ model. This means that payments are not automatically forwarded to the\n * accounts but kept in this contract, and the actual transfer is triggered as a separate step by calling the {release}\n * function.\n */\ncontract Payment is Context {\n event PayeeAdded(address account, uint256 shares);\n event PaymentReleased(address to, uint256 amount);\n event PaymentReceived(address from, uint256 amount);\n\n uint256 private _totalShares;\n uint256 private _totalReleased;\n\n mapping(address =\u003e uint256) private _shares;\n mapping(address =\u003e uint256) private _released;\n address[] private _payees;\n\n /**\n * @dev Creates an instance of `PaymentSplitter` where each account in `payees` is assigned the number of shares at\n * the matching position in the `shares` array.\n *\n * All addresses in `payees` must be non-zero. Both arrays must have the same non-zero length, and there must be no\n * duplicates in `payees`.\n */\n constructor(address[] memory payees, uint256[] memory shares_) payable {\n require(payees.length == shares_.length, \"PaymentSplitter: payees and shares length mismatch\");\n require(payees.length \u003e 0, \"PaymentSplitter: no payees\");\n\n for (uint256 i = 0; i \u003c payees.length; i++) {\n _addPayee(payees[i], shares_[i]);\n }\n }\n\n /**\n * @dev The Ether received will be logged with {PaymentReceived} events. Note that these events are not fully\n * reliable: it\u0027s possible for a contract to receive Ether without triggering this function. This only affects the\n * reliability of the events, and not the actual splitting of Ether.\n *\n * To learn more about this see the Solidity documentation for\n * https://solidity.readthedocs.io/en/latest/contracts.html#fallback-function[fallback\n * functions].\n */\n receive() external payable virtual {\n emit PaymentReceived(_msgSender(), msg.value);\n }\n\n /**\n * @dev Getter for the total shares held by payees.\n */\n function totalShares() public view returns (uint256) {\n return _totalShares;\n }\n\n /**\n * @dev Getter for the total amount of Ether already released.\n */\n function totalReleased() public view returns (uint256) {\n return _totalReleased;\n }\n\n /**\n * @dev Getter for the amount of shares held by an account.\n */\n function shares(address account) public view returns (uint256) {\n return _shares[account];\n }\n\n /**\n * @dev Getter for the amount of Ether already released to a payee.\n */\n function released(address account) public view returns (uint256) {\n return _released[account];\n }\n\n /**\n * @dev Getter for the address of the payee number `index`.\n */\n function payee(uint256 index) public view returns (address) {\n return _payees[index];\n }\n\n /**\n * @dev Triggers a transfer to `account` of the amount of Ether they are owed, according to their percentage of the\n * total shares and their previous withdrawals.\n */\n function release(address payable account) public virtual {\n require(_shares[account] \u003e 0, \"PaymentSplitter: account has no shares\");\n\n uint256 totalReceived = address(this).balance + _totalReleased;\n uint256 payment = (totalReceived * _shares[account]) / _totalShares - _released[account];\n\n require(payment != 0, \"PaymentSplitter: account is not due payment\");\n\n _released[account] = _released[account] + payment;\n _totalReleased = _totalReleased + payment;\n\n Address.sendValue(account, payment);\n emit PaymentReleased(account, payment);\n }\n\n /**\n * @dev Add a new payee to the contract.\n * @param account The address of the payee to add.\n * @param shares_ The number of shares owned by the payee.\n */\n function _addPayee(address account, uint256 shares_) private {\n require(account != address(0), \"PaymentSplitter: account is the zero address\");\n require(shares_ \u003e 0, \"PaymentSplitter: shares are 0\");\n require(_shares[account] == 0, \"PaymentSplitter: account already has shares\");\n\n _payees.push(account);\n _shares[account] = shares_;\n _totalShares = _totalShares + shares_;\n emit PayeeAdded(account, shares_);\n }\n}"},"SafeMath.sol":{"content":"// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n// CAUTION\n// This version of SafeMath should only be used with Solidity 0.8 or later,\n// because it relies on the compiler\u0027s built in overflow checks.\n\n/**\n * @dev Wrappers over Solidity\u0027s arithmetic operations.\n *\n * NOTE: `SafeMath` is no longer needed starting with Solidity 0.8. The compiler\n * now has built in overflow checking.\n */\nlibrary SafeMath {\n /**\n * @dev Returns the addition of two unsigned integers, with an overflow flag.\n *\n * _Available since v3.4._\n */\n function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n unchecked {\n uint256 c = a + b;\n if (c \u003c a) return (false, 0);\n return (true, c);\n }\n }\n\n /**\n * @dev Returns the substraction of two unsigned integers, with an overflow flag.\n *\n * _Available since v3.4._\n */\n function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n unchecked {\n if (b \u003e a) return (false, 0);\n return (true, a - b);\n }\n }\n\n /**\n * @dev Returns the multiplication of two unsigned integers, with an overflow flag.\n *\n * _Available since v3.4._\n */\n function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n unchecked {\n // Gas optimization: this is cheaper than requiring \u0027a\u0027 not being zero, but the\n // benefit is lost if \u0027b\u0027 is also tested.\n // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\n if (a == 0) return (true, 0);\n uint256 c = a * b;\n if (c / a != b) return (false, 0);\n return (true, c);\n }\n }\n\n /**\n * @dev Returns the division of two unsigned integers, with a division by zero flag.\n *\n * _Available since v3.4._\n */\n function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n unchecked {\n if (b == 0) return (false, 0);\n return (true, a / b);\n }\n }\n\n /**\n * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.\n *\n * _Available since v3.4._\n */\n function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n unchecked {\n if (b == 0) return (false, 0);\n return (true, a % b);\n }\n }\n\n /**\n * @dev Returns the addition of two unsigned integers, reverting on\n * overflow.\n *\n * Counterpart to Solidity\u0027s `+` operator.\n *\n * Requirements:\n *\n * - Addition cannot overflow.\n */\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n return a + b;\n }\n\n /**\n * @dev Returns the subtraction of two unsigned integers, reverting on\n * overflow (when the result is negative).\n *\n * Counterpart to Solidity\u0027s `-` operator.\n *\n * Requirements:\n *\n * - Subtraction cannot overflow.\n */\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n return a - b;\n }\n\n /**\n * @dev Returns the multiplication of two unsigned integers, reverting on\n * overflow.\n *\n * Counterpart to Solidity\u0027s `*` operator.\n *\n * Requirements:\n *\n * - Multiplication cannot overflow.\n */\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n return a * b;\n }\n\n /**\n * @dev Returns the integer division of two unsigned integers, reverting on\n * division by zero. The result is rounded towards zero.\n *\n * Counterpart to Solidity\u0027s `/` operator.\n *\n * Requirements:\n *\n * - The divisor cannot be zero.\n */\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n return a / b;\n }\n\n /**\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\n * reverting when dividing by zero.\n *\n * Counterpart to Solidity\u0027s `%` operator. This function uses a `revert`\n * opcode (which leaves remaining gas untouched) while Solidity uses an\n * invalid opcode to revert (consuming all remaining gas).\n *\n * Requirements:\n *\n * - The divisor cannot be zero.\n */\n function mod(uint256 a, uint256 b) internal pure returns (uint256) {\n return a % b;\n }\n\n /**\n * @dev Returns the subtraction of two unsigned integers, reverting with custom message on\n * overflow (when the result is negative).\n *\n * CAUTION: This function is deprecated because it requires allocating memory for the error\n * message unnecessarily. For custom revert reasons use {trySub}.\n *\n * Counterpart to Solidity\u0027s `-` operator.\n *\n * Requirements:\n *\n * - Subtraction cannot overflow.\n */\n function sub(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n unchecked {\n require(b \u003c= a, errorMessage);\n return a - b;\n }\n }\n\n /**\n * @dev Returns the integer division of two unsigned integers, reverting with custom message on\n * division by zero. The result is rounded towards zero.\n *\n * Counterpart to Solidity\u0027s `/` operator. Note: this function uses a\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\n * uses an invalid opcode to revert (consuming all remaining gas).\n *\n * Requirements:\n *\n * - The divisor cannot be zero.\n */\n function div(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n unchecked {\n require(b \u003e 0, errorMessage);\n return a / b;\n }\n }\n\n /**\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\n * reverting with custom message when dividing by zero.\n *\n * CAUTION: This function is deprecated because it requires allocating memory for the error\n * message unnecessarily. For custom revert reasons use {tryMod}.\n *\n * Counterpart to Solidity\u0027s `%` operator. This function uses a `revert`\n * opcode (which leaves remaining gas untouched) while Solidity uses an\n * invalid opcode to revert (consuming all remaining gas).\n *\n * Requirements:\n *\n * - The divisor cannot be zero.\n */\n function mod(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n unchecked {\n require(b \u003e 0, errorMessage);\n return a % b;\n }\n }\n}"},"Strings.sol":{"content":"// SPDX-License-Identifier: MIT\r\n\r\npragma solidity ^0.8.0;\r\n\r\n/**\r\n * @dev String operations.\r\n */\r\nlibrary Strings {\r\n bytes16 private constant _HEX_SYMBOLS = \"0123456789abcdef\";\r\n\r\n /**\r\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\r\n */\r\n function toString(uint256 value) internal pure returns (string memory) {\r\n // Inspired by OraclizeAPI\u0027s implementation - MIT licence\r\n // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\r\n\r\n if (value == 0) {\r\n return \"0\";\r\n }\r\n uint256 temp = value;\r\n uint256 digits;\r\n while (temp != 0) {\r\n digits++;\r\n temp /= 10;\r\n }\r\n bytes memory buffer = new bytes(digits);\r\n while (value != 0) {\r\n digits -= 1;\r\n buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\r\n value /= 10;\r\n }\r\n return string(buffer);\r\n }\r\n\r\n /**\r\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\r\n */\r\n function toHexString(uint256 value) internal pure returns (string memory) {\r\n if (value == 0) {\r\n return \"0x00\";\r\n }\r\n uint256 temp = value;\r\n uint256 length = 0;\r\n while (temp != 0) {\r\n length++;\r\n temp \u003e\u003e= 8;\r\n }\r\n return toHexString(value, length);\r\n }\r\n\r\n /**\r\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\r\n */\r\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\r\n bytes memory buffer = new bytes(2 * length + 2);\r\n buffer[0] = \"0\";\r\n buffer[1] = \"x\";\r\n for (uint256 i = 2 * length + 1; i \u003e 1; --i) {\r\n buffer[i] = _HEX_SYMBOLS[value \u0026 0xf];\r\n value \u003e\u003e= 4;\r\n }\r\n require(value == 0, \"Strings: hex length insufficient\");\r\n return string(buffer);\r\n }\r\n}"}}
File 3 of 4: AuthenticatedProxy
pragma solidity ^0.4.13; contract Ownable { address public owner; event OwnershipRenounced(address indexed previousOwner); event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ constructor() public { owner = msg.sender; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner); _; } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } /** * @dev Allows the current owner to relinquish control of the contract. */ function renounceOwnership() public onlyOwner { emit OwnershipRenounced(owner); owner = address(0); } } contract ERC20Basic { function totalSupply() public view returns (uint256); function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public view returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval( address indexed owner, address indexed spender, uint256 value ); } contract ProxyRegistry is Ownable { /* DelegateProxy implementation contract. Must be initialized. */ address public delegateProxyImplementation; /* Authenticated proxies by user. */ mapping(address => OwnableDelegateProxy) public proxies; /* Contracts pending access. */ mapping(address => uint) public pending; /* Contracts allowed to call those proxies. */ mapping(address => bool) public contracts; /* Delay period for adding an authenticated contract. This mitigates a particular class of potential attack on the Wyvern DAO (which owns this registry) - if at any point the value of assets held by proxy contracts exceeded the value of half the WYV supply (votes in the DAO), a malicious but rational attacker could buy half the Wyvern and grant themselves access to all the proxy contracts. A delay period renders this attack nonthreatening - given two weeks, if that happened, users would have plenty of time to notice and transfer their assets. */ uint public DELAY_PERIOD = 2 weeks; /** * Start the process to enable access for specified contract. Subject to delay period. * * @dev ProxyRegistry owner only * @param addr Address to which to grant permissions */ function startGrantAuthentication (address addr) public onlyOwner { require(!contracts[addr] && pending[addr] == 0); pending[addr] = now; } /** * End the process to nable access for specified contract after delay period has passed. * * @dev ProxyRegistry owner only * @param addr Address to which to grant permissions */ function endGrantAuthentication (address addr) public onlyOwner { require(!contracts[addr] && pending[addr] != 0 && ((pending[addr] + DELAY_PERIOD) < now)); pending[addr] = 0; contracts[addr] = true; } /** * Revoke access for specified contract. Can be done instantly. * * @dev ProxyRegistry owner only * @param addr Address of which to revoke permissions */ function revokeAuthentication (address addr) public onlyOwner { contracts[addr] = false; } /** * Register a proxy contract with this registry * * @dev Must be called by the user which the proxy is for, creates a new AuthenticatedProxy * @return New AuthenticatedProxy contract */ function registerProxy() public returns (OwnableDelegateProxy proxy) { require(proxies[msg.sender] == address(0)); proxy = new OwnableDelegateProxy(msg.sender, delegateProxyImplementation, abi.encodeWithSignature("initialize(address,address)", msg.sender, address(this))); proxies[msg.sender] = proxy; return proxy; } } contract TokenRecipient { event ReceivedEther(address indexed sender, uint amount); event ReceivedTokens(address indexed from, uint256 value, address indexed token, bytes extraData); /** * @dev Receive tokens and generate a log event * @param from Address from which to transfer tokens * @param value Amount of tokens to transfer * @param token Address of token * @param extraData Additional data to log */ function receiveApproval(address from, uint256 value, address token, bytes extraData) public { ERC20 t = ERC20(token); require(t.transferFrom(from, this, value)); emit ReceivedTokens(from, value, token, extraData); } /** * @dev Receive Ether and generate a log event */ function () payable public { emit ReceivedEther(msg.sender, msg.value); } } contract OwnedUpgradeabilityStorage { // Current implementation address internal _implementation; // Owner of the contract address private _upgradeabilityOwner; /** * @dev Tells the address of the owner * @return the address of the owner */ function upgradeabilityOwner() public view returns (address) { return _upgradeabilityOwner; } /** * @dev Sets the address of the owner */ function setUpgradeabilityOwner(address newUpgradeabilityOwner) internal { _upgradeabilityOwner = newUpgradeabilityOwner; } /** * @dev Tells the address of the current implementation * @return address of the current implementation */ function implementation() public view returns (address) { return _implementation; } /** * @dev Tells the proxy type (EIP 897) * @return Proxy type, 2 for forwarding proxy */ function proxyType() public pure returns (uint256 proxyTypeId) { return 2; } } contract AuthenticatedProxy is TokenRecipient, OwnedUpgradeabilityStorage { /* Whether initialized. */ bool initialized = false; /* Address which owns this proxy. */ address public user; /* Associated registry with contract authentication information. */ ProxyRegistry public registry; /* Whether access has been revoked. */ bool public revoked; /* Delegate call could be used to atomically transfer multiple assets owned by the proxy contract with one order. */ enum HowToCall { Call, DelegateCall } /* Event fired when the proxy access is revoked or unrevoked. */ event Revoked(bool revoked); /** * Initialize an AuthenticatedProxy * * @param addrUser Address of user on whose behalf this proxy will act * @param addrRegistry Address of ProxyRegistry contract which will manage this proxy */ function initialize (address addrUser, ProxyRegistry addrRegistry) public { require(!initialized); initialized = true; user = addrUser; registry = addrRegistry; } /** * Set the revoked flag (allows a user to revoke ProxyRegistry access) * * @dev Can be called by the user only * @param revoke Whether or not to revoke access */ function setRevoke(bool revoke) public { require(msg.sender == user); revoked = revoke; emit Revoked(revoke); } /** * Execute a message call from the proxy contract * * @dev Can be called by the user, or by a contract authorized by the registry as long as the user has not revoked access * @param dest Address to which the call will be sent * @param howToCall Which kind of call to make * @param calldata Calldata to send * @return Result of the call (success or failure) */ function proxy(address dest, HowToCall howToCall, bytes calldata) public returns (bool result) { require(msg.sender == user || (!revoked && registry.contracts(msg.sender))); if (howToCall == HowToCall.Call) { result = dest.call(calldata); } else if (howToCall == HowToCall.DelegateCall) { result = dest.delegatecall(calldata); } return result; } /** * Execute a message call and assert success * * @dev Same functionality as `proxy`, just asserts the return value * @param dest Address to which the call will be sent * @param howToCall What kind of call to make * @param calldata Calldata to send */ function proxyAssert(address dest, HowToCall howToCall, bytes calldata) public { require(proxy(dest, howToCall, calldata)); } } contract Proxy { /** * @dev Tells the address of the implementation where every call will be delegated. * @return address of the implementation to which it will be delegated */ function implementation() public view returns (address); /** * @dev Tells the type of proxy (EIP 897) * @return Type of proxy, 2 for upgradeable proxy */ function proxyType() public pure returns (uint256 proxyTypeId); /** * @dev Fallback function allowing to perform a delegatecall to the given implementation. * This function will return whatever the implementation call returns */ function () payable public { address _impl = implementation(); require(_impl != address(0)); assembly { let ptr := mload(0x40) calldatacopy(ptr, 0, calldatasize) let result := delegatecall(gas, _impl, ptr, calldatasize, 0, 0) let size := returndatasize returndatacopy(ptr, 0, size) switch result case 0 { revert(ptr, size) } default { return(ptr, size) } } } } contract OwnedUpgradeabilityProxy is Proxy, OwnedUpgradeabilityStorage { /** * @dev Event to show ownership has been transferred * @param previousOwner representing the address of the previous owner * @param newOwner representing the address of the new owner */ event ProxyOwnershipTransferred(address previousOwner, address newOwner); /** * @dev This event will be emitted every time the implementation gets upgraded * @param implementation representing the address of the upgraded implementation */ event Upgraded(address indexed implementation); /** * @dev Upgrades the implementation address * @param implementation representing the address of the new implementation to be set */ function _upgradeTo(address implementation) internal { require(_implementation != implementation); _implementation = implementation; emit Upgraded(implementation); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyProxyOwner() { require(msg.sender == proxyOwner()); _; } /** * @dev Tells the address of the proxy owner * @return the address of the proxy owner */ function proxyOwner() public view returns (address) { return upgradeabilityOwner(); } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function transferProxyOwnership(address newOwner) public onlyProxyOwner { require(newOwner != address(0)); emit ProxyOwnershipTransferred(proxyOwner(), newOwner); setUpgradeabilityOwner(newOwner); } /** * @dev Allows the upgradeability owner to upgrade the current implementation of the proxy. * @param implementation representing the address of the new implementation to be set. */ function upgradeTo(address implementation) public onlyProxyOwner { _upgradeTo(implementation); } /** * @dev Allows the upgradeability owner to upgrade the current implementation of the proxy * and delegatecall the new implementation for initialization. * @param implementation representing the address of the new implementation to be set. * @param data represents the msg.data to bet sent in the low level call. This parameter may include the function * signature of the implementation to be called with the needed payload */ function upgradeToAndCall(address implementation, bytes data) payable public onlyProxyOwner { upgradeTo(implementation); require(address(this).delegatecall(data)); } } contract OwnableDelegateProxy is OwnedUpgradeabilityProxy { constructor(address owner, address initialImplementation, bytes calldata) public { setUpgradeabilityOwner(owner); _upgradeTo(initialImplementation); require(initialImplementation.delegatecall(calldata)); } }
File 4 of 4: WyvernAtomicizer
pragma solidity ^0.4.13; library WyvernAtomicizer { function atomicize (address[] addrs, uint[] values, uint[] calldataLengths, bytes calldatas) public { require(addrs.length == values.length && addrs.length == calldataLengths.length); uint j = 0; for (uint i = 0; i < addrs.length; i++) { bytes memory calldata = new bytes(calldataLengths[i]); for (uint k = 0; k < calldataLengths[i]; k++) { calldata[k] = calldatas[j]; j++; } require(addrs[i].call.value(values[i])(calldata)); } } }