ETH Price: $1,817.77 (+0.38%)

Transaction Decoder

Block:
20280810 at Jul-11-2024 04:15:23 AM +UTC
Transaction Fee:
0.000338208124856364 ETH $0.61
Gas Used:
119,637 Gas / 2.826952572 Gwei

Emitted Events:

128 StarNFTV4.Transfer( from=0x00000000...000000000, to=[Sender] 0x08a1bc786982ed20217bfd047d5194cd26452f51, tokenId=34317 )
129 SpaceStationV2.EventClaim( _cid=303822, _dummyId=821502615, _nftID=34317, _starNFT=StarNFTV4, _sender=[Sender] 0x08a1bc786982ed20217bfd047d5194cd26452f51 )

Account State Difference:

  Address   Before After State Difference Code
0x08A1bc78...d26452F51
0.009891135767039195 Eth
Nonce: 31
0.009552927642182831 Eth
Nonce: 32
0.000338208124856364
0x75cdA579...9AdBdc5a5
(Galxe: Space Station)
(MEV Builder: 0x88c...34A)
1.778403824053217536 Eth1.778461847998217536 Eth0.000058023945
0xbdC204B7...f3f3Da653

Execution Trace

SpaceStationV2.claim( _cid=303822, _starNFT=0xbdC204B7aCa2e98b69E0732b838505bf3f3Da653, _dummyId=821502615, _powah=303822, _signature=0xB7B5E0B2AB91B79FA14B613C06C81E0E3F1CF4AC6665F64A770CC4BC415E13B362286C8FC634E1A67B6B5BCE13F8C83EFE3A2031A079DC4D688A49AF03373B9C1B )
  • Null: 0x000...001.f8812a0d( )
  • StarNFTV4.mint( account=0x08A1bc786982ED20217bFD047D5194cd26452F51, cid=303822 ) => ( 34317 )
    File 1 of 2: SpaceStationV2
    {"Address.sol":{"content":"// SPDX-License-Identifier: MIT\n\npragma solidity \u003e= 0.6.2 \u003c 0.8.0;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n    /**\n     * @dev Returns true if `account` is a contract.\n     *\n     * [IMPORTANT]\n     * ====\n     * It is unsafe to assume that an address for which this function returns\n     * false is an externally-owned account (EOA) and not a contract.\n     *\n     * Among others, `isContract` will return false for the following\n     * types of addresses:\n     *\n     *  - an externally-owned account\n     *  - a contract in construction\n     *  - an address where a contract will be created\n     *  - an address where a contract lived, but was destroyed\n     * ====\n     */\n    function isContract(address account) internal view returns(bool) {\n        // This method relies on extcodesize, which returns 0 for contracts in\n        // construction, since the code is only stored at the end of the\n        // constructor execution.\n\n        uint256 size;\n        // solhint-disable-next-line no-inline-assembly\n        assembly { size:= extcodesize(account) }\n        return size \u003e 0;\n    }\n\n    /**\n     * @dev Replacement for Solidity\u0027s `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://diligence.consensys.net/posts/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.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n     */\n    function sendValue(address payable recipient, uint256 amount) internal {\n        require(address(this).balance \u003e= amount, \"Address: insufficient balance\");\n\n        // solhint-disable-next-line avoid-low-level-calls, avoid-call-value\n        (bool success, ) = recipient.call{ value: amount } (\"\");\n        require(success, \"Address: unable to send value, recipient may have reverted\");\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, it is bubbled up by this\n     * function (like regular Solidity function calls).\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     * _Available since v3.1._\n     */\n    function functionCall(address target, bytes memory data) internal returns(bytes memory) {\n        return functionCall(target, data, \"Address: low-level call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n     * `errorMessage` as a fallback revert reason when `target` reverts.\n     *\n     * _Available since v3.1._\n     */\n    function functionCall(address target, bytes memory data, string memory errorMessage) internal returns(bytes memory) {\n        return functionCallWithValue(target, data, 0, errorMessage);\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     * _Available since v3.1._\n     */\n    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns(bytes memory) {\n        return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n     * with `errorMessage` as a fallback revert reason when `target` reverts.\n     *\n     * _Available since v3.1._\n     */\n    function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns(bytes memory) {\n        require(address(this).balance \u003e= value, \"Address: insufficient balance for call\");\n        require(isContract(target), \"Address: call to non-contract\");\n\n        // solhint-disable-next-line avoid-low-level-calls\n        (bool success, bytes memory returndata) = target.call{ value: value } (data);\n        return _verifyCallResult(success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but performing a static call.\n     *\n     * _Available since v3.3._\n     */\n    function functionStaticCall(address target, bytes memory data) internal view returns(bytes memory) {\n        return functionStaticCall(target, data, \"Address: low-level static call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n     * but performing a static call.\n     *\n     * _Available since v3.3._\n     */\n    function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns(bytes memory) {\n        require(isContract(target), \"Address: static call to non-contract\");\n\n        // solhint-disable-next-line avoid-low-level-calls\n        (bool success, bytes memory returndata) = target.staticcall(data);\n        return _verifyCallResult(success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but performing a delegate call.\n     *\n     * _Available since v3.4._\n     */\n    function functionDelegateCall(address target, bytes memory data) internal returns(bytes memory) {\n        return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n     * but performing a delegate call.\n     *\n     * _Available since v3.4._\n     */\n    function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns(bytes memory) {\n        require(isContract(target), \"Address: delegate call to non-contract\");\n\n        // solhint-disable-next-line avoid-low-level-calls\n        (bool success, bytes memory returndata) = target.delegatecall(data);\n        return _verifyCallResult(success, returndata, errorMessage);\n    }\n\n    function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {\n        if (success) {\n            return returndata;\n        } else {\n            // Look for revert reason and bubble it up if present\n            if (returndata.length \u003e 0) {\n                // The easiest way to bubble the revert reason is using memory via assembly\n\n                // solhint-disable-next-line no-inline-assembly\n                assembly {\n                    let returndata_size:= mload(returndata)\n                    revert(add(32, returndata), returndata_size)\n                }\n            } else {\n                revert(errorMessage);\n            }\n        }\n    }\n}"},"ECDSA.sol":{"content":"// SPDX-License-Identifier: MIT\n\npragma solidity \u003e= 0.6.0 \u003c 0.8.0;\n\n/**\n * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.\n *\n * These functions can be used to verify that a message was signed by the holder\n * of the private keys of a given address.\n */\nlibrary ECDSA {\n    /**\n     * @dev Returns the address that signed a hashed message (`hash`) with\n     * `signature`. This address can then be used for verification purposes.\n     *\n     * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n     * this function rejects them by requiring the `s` value to be in the lower\n     * half order, and the `v` value to be either 27 or 28.\n     *\n     * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n     * verification to be secure: it is possible to craft signatures that\n     * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n     * this is by receiving a hash of the original message (which may otherwise\n     * be too long), and then calling {toEthSignedMessageHash} on it.\n     */\n    function recover(bytes32 hash, bytes memory signature) internal pure returns(address) {\n        // Check the signature length\n        if (signature.length != 65) {\n            revert(\"ECDSA: invalid signature length\");\n        }\n\n        // Divide the signature in r, s and v variables\n        bytes32 r;\n        bytes32 s;\n        uint8 v;\n\n        // ecrecover takes the signature parameters, and the only way to get them\n        // currently is to use assembly.\n        // solhint-disable-next-line no-inline-assembly\n        assembly {\n            r:= mload(add(signature, 0x20))\n            s:= mload(add(signature, 0x40))\n            v:= byte(0, mload(add(signature, 0x60)))\n        }\n\n        return recover(hash, v, r, s);\n    }\n\n    /**\n     * @dev Overload of {ECDSA-recover-bytes32-bytes-} that receives the `v`,\n     * `r` and `s` signature fields separately.\n     */\n    function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns(address) {\n        // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\n        // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\n        // the valid range for s in (281): 0 \u003c s \u003c secp256k1n ÷ 2 + 1, and for v in (282): v ∈ {27, 28}. Most\n        // signatures from current libraries generate a unique signature with an s-value in the lower half order.\n        //\n        // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value\n        // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or\n        // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept\n        // these malleable signatures as well.\n        require(uint256(s) \u003c= 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0, \"ECDSA: invalid signature \u0027s\u0027 value\");\n        require(v == 27 || v == 28, \"ECDSA: invalid signature \u0027v\u0027 value\");\n\n        // If the signature is valid (and not malleable), return the signer address\n        address signer = ecrecover(hash, v, r, s);\n        require(signer != address(0), \"ECDSA: invalid signature\");\n\n        return signer;\n    }\n\n    /**\n     * @dev Returns an Ethereum Signed Message, created from a `hash`. This\n     * replicates the behavior of the\n     * https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_sign[`eth_sign`]\n     * JSON-RPC method.\n     *\n     * See {recover}.\n     */\n    function toEthSignedMessageHash(bytes32 hash) internal pure returns(bytes32) {\n        // 32 is the length in bytes of hash,\n        // enforced by the type signature above\n        return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n32\", hash));\n    }\n}"},"EIP712.sol":{"content":"// SPDX-License-Identifier: MIT\n\npragma solidity \u003e=0.6.0 \u003c0.8.0;\n\n/**\n * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data.\n *\n * The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible,\n * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding\n * they need in their contracts using a combination of `abi.encode` and `keccak256`.\n *\n * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding\n * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA\n * ({_hashTypedDataV4}).\n *\n * The implementation of the domain separator was designed to be as efficient as possible while still properly updating\n * the chain id to protect against replay attacks on an eventual fork of the chain.\n *\n * NOTE: This contract implements the version of the encoding known as \"v4\", as implemented by the JSON RPC method\n * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].\n *\n * _Available since v3.4._\n */\nabstract contract EIP712 {\n    /* solhint-disable var-name-mixedcase */\n    // Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to\n    // invalidate the cached domain separator if the chain id changes.\n    bytes32 private immutable _CACHED_DOMAIN_SEPARATOR;\n    uint256 private immutable _CACHED_CHAIN_ID;\n\n    bytes32 private immutable _HASHED_NAME;\n    bytes32 private immutable _HASHED_VERSION;\n    bytes32 private immutable _TYPE_HASH;\n    /* solhint-enable var-name-mixedcase */\n\n    /**\n     * @dev Initializes the domain separator and parameter caches.\n     *\n     * The meaning of `name` and `version` is specified in\n     * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]:\n     *\n     * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.\n     * - `version`: the current major version of the signing domain.\n     *\n     * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart\n     * contract upgrade].\n     */\n    constructor(string memory name, string memory version) internal {\n        bytes32 hashedName = keccak256(bytes(name));\n        bytes32 hashedVersion = keccak256(bytes(version));\n        bytes32 typeHash = keccak256(\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\");\n        _HASHED_NAME = hashedName;\n        _HASHED_VERSION = hashedVersion;\n        _CACHED_CHAIN_ID = _getChainId();\n        _CACHED_DOMAIN_SEPARATOR = _buildDomainSeparator(typeHash, hashedName, hashedVersion);\n        _TYPE_HASH = typeHash;\n    }\n\n    /**\n     * @dev Returns the domain separator for the current chain.\n     */\n    function _domainSeparatorV4() internal view virtual returns (bytes32) {\n        if (_getChainId() == _CACHED_CHAIN_ID) {\n            return _CACHED_DOMAIN_SEPARATOR;\n        } else {\n            return _buildDomainSeparator(_TYPE_HASH, _HASHED_NAME, _HASHED_VERSION);\n        }\n    }\n\n    function _buildDomainSeparator(bytes32 typeHash, bytes32 name, bytes32 version) private view returns (bytes32) {\n        return keccak256(\n            abi.encode(\n                typeHash,\n                name,\n                version,\n                _getChainId(),\n                address(this)\n            )\n        );\n    }\n\n    /**\n     * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this\n     * function returns the hash of the fully encoded EIP712 message for this domain.\n     *\n     * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:\n     *\n     * ```solidity\n     * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(\n     *     keccak256(\"Mail(address to,string contents)\"),\n     *     mailTo,\n     *     keccak256(bytes(mailContents))\n     * )));\n     * address signer = ECDSA.recover(digest, signature);\n     * ```\n     */\n    function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {\n        return keccak256(abi.encodePacked(\"\\x19\\x01\", _domainSeparatorV4(), structHash));\n    }\n\n    function _getChainId() private view returns (uint256 chainId) {\n        this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691\n        // solhint-disable-next-line no-inline-assembly\n        assembly {\n            chainId := chainid()\n        }\n    }\n}"},"IERC20.sol":{"content":"// SPDX-License-Identifier: MIT\n\npragma solidity \u003e= 0.6.0 \u003c 0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n    /**\n     * @dev Returns the amount of tokens in existence.\n     */\n    function totalSupply() external view returns(uint256);\n\n/**\n * @dev Returns the amount of tokens owned by `account`.\n */\nfunction balanceOf(address account) external view returns(uint256);\n\n/**\n * @dev Moves `amount` tokens from the caller\u0027s account to `recipient`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\nfunction transfer(address recipient, uint256 amount) external returns(bool);\n\n/**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\nfunction allowance(address owner, address spender) external view returns(uint256);\n\n/**\n * @dev Sets `amount` as the allowance of `spender` over the caller\u0027s tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender\u0027s allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\nfunction approve(address spender, uint256 amount) external returns(bool);\n\n/**\n * @dev Moves `amount` tokens from `sender` to `recipient` using the\n * allowance mechanism. `amount` is then deducted from the caller\u0027s\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\nfunction transferFrom(address sender, address recipient, uint256 amount) external returns(bool);\n\n    /**\n     * @dev Emitted when `value` tokens are moved from one account (`from`) to\n     * another (`to`).\n     *\n     * Note that `value` may be zero.\n     */\n    event Transfer(address indexed from, address indexed to, uint256 value);\n\n    /**\n     * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n     * a call to {approve}. `value` is the new allowance.\n     */\n    event Approval(address indexed owner, address indexed spender, uint256 value);\n}"},"IStarNFT.sol":{"content":"/*\n    Copyright 2021 Project Galaxy.\n\n    Licensed under the Apache License, Version 2.0 (the \"License\");\n    you may not use this file except in compliance with the License.\n    You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n    Unless required by applicable law or agreed to in writing, software\n    distributed under the License is distributed on an \"AS IS\" BASIS,\n    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n    See the License for the specific language governing permissions and\n    limitations under the License.\n\n    SPDX-License-Identifier: Apache License, Version 2.0\n*/\npragma solidity 0.7.6;\n\n/**\n * @title IStarNFT\n * @author Galaxy Protocol\n *\n * Interface for operating with StarNFTs.\n */\ninterface IStarNFT {\n    /* ============ Events =============== */\n\n    /* ============ Functions ============ */\n\n    function isOwnerOf(address, uint256) external view returns (bool);\n    function getNumMinted() external view returns (uint256);\n    // mint\n    function mint(address account, uint256 powah) external returns (uint256);\n    function mintBatch(address account, uint256 amount, uint256[] calldata powahArr) external returns (uint256[] memory);\n    function burn(address account, uint256 id) external;\n    function burnBatch(address account, uint256[] calldata ids) external;\n}"},"SafeMath.sol":{"content":"// SPDX-License-Identifier: MIT\n\npragma solidity \u003e= 0.6.0 \u003c 0.8.0;\n\n/**\n * @dev Wrappers over Solidity\u0027s arithmetic operations with added overflow\n * checks.\n *\n * Arithmetic operations in Solidity wrap on overflow. This can easily result\n * in bugs, because programmers usually assume that an overflow raises an\n * error, which is the standard behavior in high level programming languages.\n * `SafeMath` restores this intuition by reverting the transaction when an\n * operation overflows.\n *\n * Using this library instead of the unchecked operations eliminates an entire\n * class of bugs, so it\u0027s recommended to use it always.\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        uint256 c = a + b;\n        if (c \u003c a) return (false, 0);\n        return (true, c);\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        if (b \u003e a) return (false, 0);\n        return (true, a - b);\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        // 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     * @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        if (b == 0) return (false, 0);\n        return (true, a / b);\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        if (b == 0) return (false, 0);\n        return (true, a % b);\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        uint256 c = a + b;\n        require(c \u003e= a, \"SafeMath: addition overflow\");\n        return c;\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        require(b \u003c= a, \"SafeMath: subtraction overflow\");\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        if (a == 0) return 0;\n        uint256 c = a * b;\n        require(c / a == b, \"SafeMath: multiplication overflow\");\n        return c;\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. 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(uint256 a, uint256 b) internal pure returns(uint256) {\n        require(b \u003e 0, \"SafeMath: division by zero\");\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        require(b \u003e 0, \"SafeMath: modulo by zero\");\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(uint256 a, uint256 b, string memory errorMessage) internal pure returns(uint256) {\n        require(b \u003c= a, errorMessage);\n        return a - b;\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     * CAUTION: This function is deprecated because it requires allocating memory for the error\n     * message unnecessarily. For custom revert reasons use {tryDiv}.\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(uint256 a, uint256 b, string memory errorMessage) internal pure returns(uint256) {\n        require(b \u003e 0, errorMessage);\n        return a / b;\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(uint256 a, uint256 b, string memory errorMessage) internal pure returns(uint256) {\n        require(b \u003e 0, errorMessage);\n        return a % b;\n    }\n}"},"SpaceStationV2.sol":{"content":"/*\n    Copyright 2021 Project Galaxy.\n\n    Licensed under the Apache License, Version 2.0 (the \"License\");\n    you may not use this file except in compliance with the License.\n    You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n    Unless required by applicable law or agreed to in writing, software\n    distributed under the License is distributed on an \"AS IS\" BASIS,\n    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n    See the License for the specific language governing permissions and\n    limitations under the License.\n\n    SPDX-License-Identifier: Apache License, Version 2.0\n*/\n\npragma solidity 0.7.6;\n\nimport {Address} from \"Address.sol\";\nimport {SafeMath} from \"SafeMath.sol\";\nimport {IERC20} from \"IERC20.sol\";\nimport {EIP712} from \"EIP712.sol\";\nimport {ECDSA} from \"ECDSA.sol\";\nimport {IStarNFT} from \"IStarNFT.sol\"; //0.7.6\n\n/**\n * @title SpaceStation\n * @author Galaxy Protocol\n *\n * Campaign contract that allows privileged DAOs to initiate campaigns for members to claim StarNFTs.\n */\ncontract SpaceStationV2 is EIP712 {\n    using Address for address;\n    using SafeMath for uint256;\n\n    /* ============ Events ============ */\n    event EventActivateCampaign(uint256 _cid);\n    event EventClaim(\n        uint256 _cid,\n        uint256 _dummyId,\n        uint256 _nftID,\n        IStarNFT _starNFT,\n        address _sender\n    );\n    event EventClaimCapped(\n        uint256 _cid,\n        uint256 _dummyId,\n        uint256 _nftID,\n        IStarNFT _starNFT,\n        address _sender,\n        uint256 _minted,\n        uint256 _cap\n    );\n    event EventClaimBatch(\n        uint256 _cid,\n        uint256[] _dummyIdArr,\n        uint256[] _nftIDArr,\n        IStarNFT _starNFT,\n        address _sender\n    );\n    event EventClaimBatchCapped(\n        uint256 _cid,\n        uint256[] _dummyIdArr,\n        uint256[] _nftIDArr,\n        IStarNFT _starNFT,\n        address _sender,\n        uint256 _minted,\n        uint256 _cap\n    );\n    event EventForge(\n        uint256 _cid,\n        uint256 _dummyId,\n        uint256 _nftID,\n        IStarNFT _starNFT,\n        address _sender\n    );\n\n    /* ============ Modifiers ============ */\n    /**\n     * Throws if the sender is not a campaign setter, gnosis\n     */\n    modifier onlyCampaignSetter() {\n        _validateOnlyCampaignSetter();\n        _;\n    }\n    /**\n     * Throws if the sender is not a manager: pauser_role and upgrader_role, gnosis\n     */\n    modifier onlyManager() {\n        _validateOnlyManager();\n        _;\n    }\n    /**\n     * Throws if the sender is not a Treasury\u0027s manager, gnosis safe\n     */\n    modifier onlyTreasuryManager() {\n        _validateOnlyTreasuryManager();\n        _;\n    }\n    /**\n     * Throws if the contract paused\n     */\n    modifier onlyNoPaused() {\n        _validateOnlyNotPaused();\n        _;\n    }\n\n    /* ============ Enums ================ */\n\n    /* ============ Structs ============ */\n\n    struct CampaignFeeConfig {\n        address erc20; // Address of token asset if required\n        uint256 erc20Fee; // Amount of token if required\n        uint256 platformFee; // Amount of fee for using the service if applicable\n    }\n\n    /* ============ State Variables ============ */\n    // Is contract paused.\n    bool public paused;\n\n    // The galaxy signer(EOA): used to verify EIP-712.\n    address public galaxy_signer;\n    // A campaign setter. TODO: mapping of EOAs to reduce multisig tx gas cost.\n    address public campaign_setter;\n    // The manager which has privilege to do upgrades, pause/unpause.\n    address public manager;\n    // Treasury manager which receives fees.\n    address public treasury_manager;\n\n    // Mapping that stores all fee requirements for a given activated campaign.\n    // If no fee is required at all, should set to all zero values except for `isActive`.\n    mapping(uint256 =\u003e CampaignFeeConfig) public campaignFeeConfigs;\n    // hasMinted(dummyID(signature) =\u003e bool) that records if the user account has already used the dummyID(signature).\n    mapping(uint256 =\u003e bool) public hasMinted;\n    // for capped campaign usage only\n    mapping(uint256 =\u003e uint256) public numMinted;\n\n    /* ============ Constructor ============ */\n    constructor(\n        address _galaxy_signer,\n        address _campaign_setter,\n        address _contract_manager,\n        address _treasury_manager\n    ) EIP712(\"Galaxy\", \"1.0.0\") {\n        // require(galaxy_signer != address(0), \"Galaxy signer address must not be null address\");\n        // require(campaign_setter != address(0), \"Campaign setter address must not be null address\");\n        // require(contract_manager != address(0), \"Contract manager address must not be null address\");\n        // require(treasury_manager != address(0), \"Treasury manager address must not be null address\");\n        galaxy_signer = _galaxy_signer;\n        campaign_setter = _campaign_setter;\n        manager = _contract_manager;\n        treasury_manager = _treasury_manager;\n    }\n\n    /* ============ External Functions ============ */\n    function activateCampaign(\n        uint256 _cid,\n        uint256 _platformFee,\n        uint256 _erc20Fee,\n        address _erc20\n    ) external onlyCampaignSetter {\n        _setFees(_cid, _platformFee, _erc20Fee, _erc20);\n        emit EventActivateCampaign(_cid);\n    }\n\n    function claim(\n        uint256 _cid,\n        IStarNFT _starNFT,\n        uint256 _dummyId,\n        uint256 _powah,\n        address _mintTo,\n        bytes calldata _signature\n    ) public payable onlyNoPaused {\n        require(!hasMinted[_dummyId], \"Already minted\");\n        require(\n            _verify(\n                _hash(_cid, _starNFT, _dummyId, _powah, _mintTo),\n                _signature\n            ),\n            \"Invalid signature\"\n        );\n        hasMinted[_dummyId] = true;\n        _payFees(_cid, 1);\n        uint256 nftID = _starNFT.mint(_mintTo, _powah);\n        emit EventClaim(_cid, _dummyId, nftID, _starNFT, _mintTo);\n    }\n\n    function claim(\n        uint256 _cid,\n        IStarNFT _starNFT,\n        uint256 _dummyId,\n        uint256 _powah,\n        bytes calldata _signature\n    ) external payable onlyNoPaused {\n        claim(_cid, _starNFT, _dummyId, _powah, msg.sender, _signature);\n    }\n\n    function claimBatch(\n        uint256 _cid,\n        IStarNFT _starNFT,\n        uint256[] calldata _dummyIdArr,\n        uint256[] calldata _powahArr,\n        address _mintTo,\n        bytes calldata _signature\n    ) public payable onlyNoPaused {\n        require(\n            _dummyIdArr.length \u003e 0,\n            \"Array(_dummyIdArr) should not be empty\"\n        );\n        require(\n            _powahArr.length == _dummyIdArr.length,\n            \"Array(_powahArr) length mismatch\"\n        );\n\n        for (uint256 i = 0; i \u003c _dummyIdArr.length; i++) {\n            require(!hasMinted[_dummyIdArr[i]], \"Already minted\");\n            hasMinted[_dummyIdArr[i]] = true;\n        }\n\n        require(\n            _verify(\n                _hashBatch(_cid, _starNFT, _dummyIdArr, _powahArr, _mintTo),\n                _signature\n            ),\n            \"Invalid signature\"\n        );\n        _payFees(_cid, _dummyIdArr.length);\n\n        uint256[] memory nftIdArr = _starNFT.mintBatch(\n            _mintTo,\n            _powahArr.length,\n            _powahArr\n        );\n        emit EventClaimBatch(_cid, _dummyIdArr, nftIdArr, _starNFT, _mintTo);\n    }\n\n    function claimBatch(\n        uint256 _cid,\n        IStarNFT _starNFT,\n        uint256[] calldata _dummyIdArr,\n        uint256[] calldata _powahArr,\n        bytes calldata _signature\n    ) external payable onlyNoPaused {\n        claimBatch(_cid, _starNFT, _dummyIdArr, _powahArr, msg.sender, _signature);\n    }\n\n    function claimCapped(\n        uint256 _cid,\n        IStarNFT _starNFT,\n        uint256 _dummyId,\n        uint256 _powah,\n        uint256 _cap,\n        address _mintTo,\n        bytes calldata _signature\n    ) public payable onlyNoPaused {\n        require(!hasMinted[_dummyId], \"Already minted\");\n        require(numMinted[_cid] \u003c _cap, \"Reached cap limit\");\n        require(\n            _verify(\n                _hashCapped(_cid, _starNFT, _dummyId, _powah, _cap, _mintTo),\n                _signature\n            ),\n            \"Invalid signature\"\n        );\n        hasMinted[_dummyId] = true;\n        numMinted[_cid] = numMinted[_cid] + 1;\n        _payFees(_cid, 1);\n        uint256 nftID = _starNFT.mint(_mintTo, _powah);\n        uint256 minted = numMinted[_cid];\n        emit EventClaimCapped(_cid, _dummyId, nftID, _starNFT, _mintTo, minted, _cap);\n    }\n\n    function claimCapped(\n        uint256 _cid,\n        IStarNFT _starNFT,\n        uint256 _dummyId,\n        uint256 _powah,\n        uint256 _cap,\n        bytes calldata _signature\n    ) external payable onlyNoPaused {\n        claimCapped(_cid, _starNFT, _dummyId, _powah, _cap, msg.sender, _signature);\n    }\n\n    function claimBatchCapped(\n        uint256 _cid,\n        IStarNFT _starNFT,\n        uint256[] calldata _dummyIdArr,\n        uint256[] calldata _powahArr,\n        uint256 _cap,\n        address _mintTo,\n        bytes calldata _signature\n    ) public payable onlyNoPaused {\n        require(\n            _dummyIdArr.length \u003e 0,\n            \"Array(_dummyIdArr) should not be empty\"\n        );\n        require(\n            _powahArr.length == _dummyIdArr.length,\n            \"Array(_powahArr) length mismatch\"\n        );\n        require(\n            numMinted[_cid] + _dummyIdArr.length \u003c= _cap,\n            \"Reached cap limit\"\n        );\n\n        for (uint256 i = 0; i \u003c _dummyIdArr.length; i++) {\n            require(!hasMinted[_dummyIdArr[i]], \"Already minted\");\n            hasMinted[_dummyIdArr[i]] = true;\n        }\n\n        require(\n            _verify(\n                _hashBatchCapped(\n                    _cid,\n                    _starNFT,\n                    _dummyIdArr,\n                    _powahArr,\n                    _cap,\n                    _mintTo\n                ),\n                _signature\n            ),\n            \"Invalid signature\"\n        );\n        numMinted[_cid] = numMinted[_cid] + _dummyIdArr.length;\n        _payFees(_cid, _dummyIdArr.length);\n        uint256[] memory nftIdArr = _starNFT.mintBatch(\n            _mintTo,\n            _powahArr.length,\n            _powahArr\n        );\n        uint256 minted = numMinted[_cid];\n        emit EventClaimBatchCapped(_cid, _dummyIdArr, nftIdArr, _starNFT, _mintTo, minted, _cap);\n    }\n\n    function claimBatchCapped(\n        uint256 _cid,\n        IStarNFT _starNFT,\n        uint256[] calldata _dummyIdArr,\n        uint256[] calldata _powahArr,\n        uint256 _cap,\n        bytes calldata _signature\n    ) external payable onlyNoPaused {\n        claimBatchCapped(_cid, _starNFT, _dummyIdArr, _powahArr, _cap, msg.sender, _signature);\n    }\n\n    function forge(\n        uint256 _cid,\n        IStarNFT _starNFT,\n        uint256[] calldata _nftIDs,\n        uint256 _dummyId,\n        uint256 _powah,\n        address _mintTo,\n        bytes calldata _signature\n    ) public payable onlyNoPaused {\n        require(!hasMinted[_dummyId], \"Already minted\");\n        require(\n            _verify(\n                _hashForge(\n                    _cid,\n                    _starNFT,\n                    _nftIDs,\n                    _dummyId,\n                    _powah,\n                    _mintTo\n                ),\n                _signature\n            ),\n            \"Invalid signature\"\n        );\n        hasMinted[_dummyId] = true;\n        for (uint256 i = 0; i \u003c _nftIDs.length; i++) {\n            require(\n                _starNFT.isOwnerOf(_mintTo, _nftIDs[i]),\n                \"Not the owner\"\n            );\n        }\n        _starNFT.burnBatch(_mintTo, _nftIDs);\n        _payFees(_cid, 1);\n        uint256 nftID = _starNFT.mint(_mintTo, _powah);\n        emit EventForge(_cid, _dummyId, nftID, _starNFT, _mintTo);\n    }\n\n    function forge(\n        uint256 _cid,\n        IStarNFT _starNFT,\n        uint256[] calldata _nftIDs,\n        uint256 _dummyId,\n        uint256 _powah,\n        bytes calldata _signature\n    ) external payable onlyNoPaused {\n        forge(_cid, _starNFT, _nftIDs, _dummyId, _powah, msg.sender, _signature);\n    }\n\n    receive() external payable {\n        // anonymous transfer: to treasury_manager\n        (bool success, ) = treasury_manager.call{value: msg.value}(\n            new bytes(0)\n        );\n        require(success, \"Transfer failed\");\n    }\n\n    fallback() external payable {\n        if (msg.value \u003e 0) {\n            // call non exist function: send to treasury_manager\n            (bool success, ) = treasury_manager.call{value: msg.value}(new bytes(0));\n            require(success, \"Transfer failed\");\n        }\n    }\n\n    /**\n     * PRIVILEGED MODULE FUNCTION. Function that update galaxy signer address.\n     */\n    function updateGalaxySigner(address newAddress) external onlyManager {\n        require(\n            newAddress != address(0),\n            \"Galaxy signer address must not be null address\"\n        );\n        galaxy_signer = newAddress;\n    }\n\n    /**\n     * PRIVILEGED MODULE FUNCTION. Function that update galaxy signer address.\n     */\n    function updateCampaignSetter(address newAddress) external onlyManager {\n        require(\n            newAddress != address(0),\n            \"Campaign setter address must not be null address\"\n        );\n        campaign_setter = newAddress;\n    }\n\n    /**\n     * PRIVILEGED MODULE FUNCTION. Function that update manager address.\n     */\n    function updateManager(address newAddress) external onlyManager {\n        require(\n            newAddress != address(0),\n            \"Manager address must not be null address\"\n        );\n        manager = newAddress;\n    }\n\n    /**\n     * PRIVILEGED MODULE FUNCTION. Function that update treasure manager address.\n     */\n    function updateTreasureManager(address payable newAddress)\n    external\n    onlyTreasuryManager\n    {\n        require(\n            newAddress != address(0),\n            \"Treasure manager must not be null address\"\n        );\n        treasury_manager = newAddress;\n    }\n\n    /**\n     * PRIVILEGED MODULE FUNCTION. Function that pause the contract.\n     */\n    function setPause(bool _paused) external onlyManager {\n        paused = _paused;\n    }\n\n    /* ============ Internal Functions ============ */\n    function _hash(\n        uint256 _cid,\n        IStarNFT _starNFT,\n        uint256 _dummyId,\n        uint256 _powah,\n        address _account\n    ) public view returns (bytes32) {\n        return\n        _hashTypedDataV4(\n            keccak256(\n                abi.encode(\n                    keccak256(\n                        \"NFT(uint256 cid,address starNFT,uint256 dummyId,uint256 powah,address account)\"\n                    ),\n                    _cid,\n                    _starNFT,\n                    _dummyId,\n                    _powah,\n                    _account\n                )\n            )\n        );\n    }\n\n    function _hashCapped(\n        uint256 _cid,\n        IStarNFT _starNFT,\n        uint256 _dummyId,\n        uint256 _powah,\n        uint256 _cap,\n        address _account\n    ) public view returns (bytes32) {\n        return\n        _hashTypedDataV4(\n            keccak256(\n                abi.encode(\n                    keccak256(\n                        \"NFT(uint256 cid,address starNFT,uint256 dummyId,uint256 powah,uint256 cap,address account)\"\n                    ),\n                    _cid,\n                    _starNFT,\n                    _dummyId,\n                    _powah,\n                    _cap,\n                    _account\n                )\n            )\n        );\n    }\n\n    function _hashBatch(\n        uint256 _cid,\n        IStarNFT _starNFT,\n        uint256[] calldata _dummyIdArr,\n        uint256[] calldata _powahArr,\n        address _account\n    ) public view returns (bytes32) {\n        return\n        _hashTypedDataV4(\n            keccak256(\n                abi.encode(\n                    keccak256(\n                        \"NFT(uint256 cid,address starNFT,uint256[] dummyIdArr,uint256[] powahArr,address account)\"\n                    ),\n                    _cid,\n                    _starNFT,\n                    keccak256(abi.encodePacked(_dummyIdArr)),\n                    keccak256(abi.encodePacked(_powahArr)),\n                    _account\n                )\n            )\n        );\n    }\n\n    function _hashBatchCapped(\n        uint256 _cid,\n        IStarNFT _starNFT,\n        uint256[] calldata _dummyIdArr,\n        uint256[] calldata _powahArr,\n        uint256 _cap,\n        address _account\n    ) public view returns (bytes32) {\n        return\n        _hashTypedDataV4(\n            keccak256(\n                abi.encode(\n                    keccak256(\n                        \"NFT(uint256 cid,address starNFT,uint256[] dummyIdArr,uint256[] powahArr,uint256 cap,address account)\"\n                    ),\n                    _cid,\n                    _starNFT,\n                    keccak256(abi.encodePacked(_dummyIdArr)),\n                    keccak256(abi.encodePacked(_powahArr)),\n                    _cap,\n                    _account\n                )\n            )\n        );\n    }\n\n    // todo: change to internal on PRD\n    function _hashForge(\n        uint256 _cid,\n        IStarNFT _starNFT,\n        uint256[] calldata _nftIDs,\n        uint256 _dummyId,\n        uint256 _powah,\n        address _account\n    ) public view returns (bytes32) {\n        return\n        _hashTypedDataV4(\n            keccak256(\n                abi.encode(\n                    keccak256(\n                        \"NFT(uint256 cid,address starNFT,uint256[] nftIDs,uint256 dummyId,uint256 powah,address account)\"\n                    ),\n                    _cid,\n                    _starNFT,\n                    keccak256(abi.encodePacked(_nftIDs)),\n                    _dummyId,\n                    _powah,\n                    _account\n                )\n            )\n        );\n    }\n\n    // todo: change to internal on PRD\n    function _verify(bytes32 hash, bytes calldata signature)\n    public\n    view\n    returns (bool)\n    {\n        return ECDSA.recover(hash, signature) == galaxy_signer;\n    }\n\n    function _setFees(\n        uint256 _cid,\n        uint256 _platformFee,\n        uint256 _erc20Fee,\n        address _erc20\n    ) private {\n        require(\n            (_erc20 == address(0) \u0026\u0026 _erc20Fee == 0) ||\n            (_erc20 != address(0) \u0026\u0026 _erc20Fee != 0),\n            \"Invalid erc20 fee requirement arguments\"\n        );\n        campaignFeeConfigs[_cid] = CampaignFeeConfig(\n            _erc20,\n            _erc20Fee,\n            _platformFee\n        );\n    }\n\n    function _payFees(uint256 _cid, uint256 amount) private {\n        require(amount \u003e 0, \"Must mint more than 0\");\n        CampaignFeeConfig memory feeConf = campaignFeeConfigs[_cid];\n        // 1. pay platformFee if needed\n        if (feeConf.platformFee \u003e 0) {\n            require(\n                msg.value \u003e= feeConf.platformFee.mul(amount),\n                \"Insufficient Payment\"\n            );\n            (bool success, ) = treasury_manager.call{value: msg.value}(\n                new bytes(0)\n            );\n            require(success, \"Transfer platformFee failed\");\n        }\n        // 2. pay erc20_fee if needed\n        if (feeConf.erc20Fee \u003e 0) {\n            // user wallet transfer \u003cerc20\u003e of \u003cfeeConf.erc20Fee\u003e to \u003cthis contract\u003e.\n            require(\n                IERC20(feeConf.erc20).transferFrom(\n                    msg.sender,\n                    treasury_manager,\n                    feeConf.erc20Fee.mul(amount)\n                ),\n                \"Transfer erc20Fee failed\"\n            );\n        }\n    }\n\n    /**\n     * Due to reason error bloat, internal functions are used to reduce bytecode size\n     */\n    function _validateOnlyCampaignSetter() internal view {\n        require(msg.sender == campaign_setter, \"Only campaignSetter can call\");\n    }\n\n    function _validateOnlyManager() internal view {\n        require(msg.sender == manager, \"Only manager can call\");\n    }\n\n    function _validateOnlyTreasuryManager() internal view {\n        require(\n            msg.sender == treasury_manager,\n            \"Only treasury manager can call\"\n        );\n    }\n\n    function _validateOnlyNotPaused() internal view {\n        require(!paused, \"Contract paused\");\n    }\n}"}}

    File 2 of 2: StarNFTV4
    /*
        Copyright 2022 Project Galaxy.
        Licensed under the Apache License, Version 2.0 (the "License");
        you may not use this file except in compliance with the License.
        You may obtain a copy of the License at
        http://www.apache.org/licenses/LICENSE-2.0
        Unless required by applicable law or agreed to in writing, software
        distributed under the License is distributed on an "AS IS" BASIS,
        WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
        See the License for the specific language governing permissions and
        limitations under the License.
        SPDX-License-Identifier: Apache License, Version 2.0
    */
    pragma solidity 0.7.6;
    import "IERC721.sol";
    import "IERC721Receiver.sol";
    import "IERC721Metadata.sol";
    import "Address.sol";
    import "Strings.sol";
    import "Ownable.sol";
    import "ERC165.sol";
    import "IStarNFT.sol";
    /**
     * @dev Fork https://github.com/generalgalactic/ERC721S and implement IStarNFT interface
     */
    contract StarNFTV4 is Ownable, ERC165, IERC721, IERC721Metadata, IStarNFT {
        using Address for address;
        using Strings for uint256;
        /* ============ State Variables ============ */
        struct Star {
            uint160 owner;
            uint96 cid; // Max value is 7.9E28, enough to store campaign id
        }
        // Token name
        string private _name;
        // Token symbol
        string private _symbol;
        // Total number of tokens burned
        uint256 private _burnCount;
        // Array of all tokens storing the owner's address and the campaign id
        Star[] private _tokens;
        // Mapping owner address to token count
        mapping(address => uint256) private _balances;
        // Mapping from token ID to approved address
        mapping(uint256 => address) private _tokenApprovals;
        // Mapping from owner to operator approvals
        mapping(address => mapping(address => bool)) private _operatorApprovals;
        // Mint and burn star.
        mapping(address => bool) private _minters;
        // Default allow transfer
        bool private _transferable = true;
        // Base token URI
        string private _baseURI;
        /* ============ Events ============ */
        // Add new minter
        event EventMinterAdded(address indexed newMinter);
        // Remove old minter
        event EventMinterRemoved(address indexed oldMinter);
        /* ============ Modifiers ============ */
        /**
         * Only minter.
         */
        modifier onlyMinter() {
            require(_minters[msg.sender], "StarNFT: must be minter");
            _;
        }
        /**
         * Only allow transfer.
         */
        modifier onlyTransferable() {
            require(_transferable, "StarNFT: must transferable");
            _;
        }
        /**
         * @dev Initializes the contract
         */
        constructor() {
            // Initialize zero index value
            Star memory _star = Star(0, 0);
            _tokens.push(_star);
        }
        /**
         * @dev See {IERC165-supportsInterface}.
         */
        function supportsInterface(bytes4 interfaceId)
        public
        view
        override(ERC165, IERC165)
        returns (bool)
        {
            return
            interfaceId == type(IERC721).interfaceId ||
            interfaceId == type(IERC721Metadata).interfaceId ||
            interfaceId == type(IStarNFT).interfaceId ||
            super.supportsInterface(interfaceId);
        }
        /**
         * @dev Is this address a minters.
         */
        function minters(address account) public view returns (bool) {
            return _minters[account];
        }
        /**
         * @dev Is this contract allow nft transfer.
         */
        function transferable() public view returns (bool) {
            return _transferable;
        }
        /**
         * @dev Returns the base URI for nft.
         */
        function baseURI() public view returns (string memory) {
            return _baseURI;
        }
        /**
         * @dev Get Star NFT CID.
         */
        function cid(uint256 tokenId) public view returns (uint256) {
            require(_exists(tokenId), "StarNFT: StarNFT does not exist");
            return _tokens[tokenId].cid;
        }
        /**
         * @dev Get Star NFT owner
         */
        function getNumMinted() public view override returns (uint256) {
            return _tokens.length-1;
        }
        /**
         * @dev See {IERC721Enumerable-totalSupply}.
         */
        function totalSupply() public view returns (uint256) {
            return getNumMinted() - _burnCount;
        }
        /**
         * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
         * This is implementation is O(n) and should not be
         * called by other contracts.
         */
        function tokenOfOwnerByIndex(address owner, uint256 index)
        public
        view
        returns (uint256)
        {
            uint256 currentIndex = 0;
            for (uint256 i = 1; i < _tokens.length; i++) {
                if (isOwnerOf(owner, i)) {
                    if (currentIndex == index) {
                        return i;
                    }
                    currentIndex += 1;
                }
            }
            revert("ERC721Enumerable: owner index out of bounds");
        }
        /**
         * @dev See {IERC721-balanceOf}.
         */
        function balanceOf(address owner)
        public
        view
        override
        returns (uint256)
        {
            require(
                owner != address(0),
                "ERC721: balance query for the zero address"
            );
            return _balances[owner];
        }
        /**
         * @dev See {IERC721-ownerOf}.
         */
        function ownerOf(uint256 tokenId)
        public
        view
        override
        returns (address)
        {
            require(
                _exists(tokenId),
                "ERC721: owner query for nonexistent token"
            );
            return address(_tokens[tokenId].owner);
        }
        /**
         * @dev See {IStarNFT-isOwnerOf}.
         */
        function isOwnerOf(address account, uint256 id)
        public
        view
        override
        returns (bool)
        {
            address owner = ownerOf(id);
            return owner == account;
        }
        /**
         * @dev See {IERC721Metadata-name}.
         */
        function name() public view virtual override returns (string memory) {
            return _name;
        }
        /**
         * @dev See {IERC721Metadata-symbol}.
         */
        function symbol() public view virtual override returns (string memory) {
            return _symbol;
        }
        /**
         * @dev See {IERC721Metadata-tokenURI}.
         */
        function tokenURI(uint256 tokenId)
        public
        view
        override
        returns (string memory)
        {
            require(
                _exists(tokenId),
                "ERC721Metadata: URI query for nonexistent token"
            );
            return
            bytes(_baseURI).length > 0
            ? string(abi.encodePacked(_baseURI, tokenId.toString(), ".json"))
            : "";
        }
        /**
         * @dev See {IERC721-approve}.
         */
        function approve(address to, uint256 tokenId) public override {
            address owner = ownerOf(tokenId);
            require(to != owner, "ERC721: approval to current owner");
            require(
                _msgSender() == owner || isApprovedForAll(owner, _msgSender()),
                "ERC721: approve caller is not owner nor approved for all"
            );
            _approve(to, tokenId);
        }
        /**
         * @dev See {IERC721-getApproved}.
         */
        function getApproved(uint256 tokenId)
        public
        view
        override
        returns (address)
        {
            require(
                _exists(tokenId),
                "ERC721: approved query for nonexistent token"
            );
            return _tokenApprovals[tokenId];
        }
        /**
         * @dev See {IERC721-setApprovalForAll}.
         */
        function setApprovalForAll(address operator, bool approved)
        public
        override
        {
            require(operator != _msgSender(), "ERC721: approve to caller");
            _operatorApprovals[_msgSender()][operator] = approved;
            emit ApprovalForAll(_msgSender(), operator, approved);
        }
        /**
         * @dev See {IERC721-isApprovedForAll}.
         */
        function isApprovedForAll(address owner, address operator)
        public
        view
        override
        returns (bool)
        {
            return _operatorApprovals[owner][operator];
        }
        /**
         * @dev See {IERC721-transferFrom}.
         */
        function transferFrom(
            address from,
            address to,
            uint256 tokenId
        ) public onlyTransferable override {
            //solhint-disable-next-line max-line-length
            require(
                _isApprovedOrOwner(_msgSender(), tokenId),
                "ERC721: transfer caller is not owner nor approved"
            );
            _transfer(from, to, tokenId);
        }
        /**
         * @dev See {IERC721-safeTransferFrom}.
         */
        function safeTransferFrom(
            address from,
            address to,
            uint256 tokenId
        ) public onlyTransferable override {
            safeTransferFrom(from, to, tokenId, "");
        }
        /**
         * @dev See {IERC721-safeTransferFrom}.
         */
        function safeTransferFrom(
            address from,
            address to,
            uint256 tokenId,
            bytes memory _data
        ) public onlyTransferable override {
            require(
                _isApprovedOrOwner(_msgSender(), tokenId),
                "ERC721: transfer caller is not owner nor approved"
            );
            _safeTransfer(from, to, tokenId, _data);
        }
        /**
         * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
         * are aware of the ERC721 protocol to prevent tokens from being forever locked.
         *
         * `_data` is additional data, it has no specified format and it is sent in call to `to`.
         *
         * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.
         * implement alternative mechanisms to perform token transfer, such as signature-based.
         *
         * Requirements:
         *
         * - `from` cannot be the zero address.
         * - `to` cannot be the zero address.
         * - `tokenId` token must exist and be owned by `from`.
         * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
         *
         * Emits a {Transfer} event.
         */
        function _safeTransfer(
            address from,
            address to,
            uint256 tokenId,
            bytes memory _data
        ) internal {
            _transfer(from, to, tokenId);
            require(
                _checkOnERC721Received(from, to, tokenId, _data),
                "ERC721: transfer to non ERC721Receiver implementer"
            );
        }
        /**
         * @dev Returns whether `tokenId` exists.
         *
         * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
         *
         * Tokens start existing when they are minted (`_mint`),
         * and stop existing when they are burned (`_burn`).
         */
        function _exists(uint256 tokenId) internal view returns (bool) {
            return tokenId > 0 && tokenId <= getNumMinted() && _tokens[tokenId].owner != 0x0;
        }
        /**
         * @dev Returns whether `spender` is allowed to manage `tokenId`.
         *
         * Requirements:
         *
         * - `tokenId` must exist.
         */
        function _isApprovedOrOwner(address spender, uint256 tokenId)
        internal
        view
        returns (bool)
        {
            address owner = ownerOf(tokenId);
            return (spender == owner ||
            getApproved(tokenId) == spender ||
            isApprovedForAll(owner, spender));
        }
        /* ============ External Functions ============ */
        function mint(address account, uint256 cid)
        external
        override
        onlyMinter
        returns (uint256)
        {
            require(account != address(0), "StarNFT: mint to the zero address");
            uint256 tokenId = _tokens.length;
            Star memory star = Star(uint160(account), uint96(cid));
            _balances[account] += 1;
            _tokens.push(star);
            require(
                _checkOnERC721Received(address(0), account, tokenId, ""),
                "StarNFT: transfer to non ERC721Receiver implementer"
            );
            emit Transfer(address(0), account, tokenId);
            return tokenId;
        }
        function mintBatch(
            address account,
            uint256 amount,
            uint256[] calldata cidArr
        ) external override onlyMinter returns (uint256[] memory) {
            require(account != address(0), "StarNFT: mint to the zero address");
            uint256[] memory ids = new uint256[](amount);
            _balances[account] += amount;
            for (uint256 i = 0; i < ids.length; i++) {
                uint256 tokenId = _tokens.length;
                Star memory star = Star(uint160(account), uint96(cidArr[i]));
                ids[i] = tokenId;
                _tokens.push(star);
                require(
                    _checkOnERC721Received(address(0), account, tokenId, ""),
                    "StarNFT: transfer to non ERC721Receiver implementer"
                );
                emit Transfer(address(0), account, tokenId);
            }
            return ids;
        }
        function burn(address account, uint256 id) external override onlyMinter {
            require(
                _isApprovedOrOwner(_msgSender(), id),
                "StarNFT: caller is not approved or owner"
            );
            require(isOwnerOf(account, id), "StarNFT: not owner");
            // Clear approvals
            _approve(address(0), id);
            _burnCount++;
            _balances[account] -= 1;
            _tokens[id].owner = 0;
            _tokens[id].cid = 0;
            emit Transfer(account, address(0), id);
        }
        function burnBatch(address account, uint256[] calldata ids)
        external
        override
        onlyMinter
        {
            _burnCount += ids.length;
            _balances[account] -= ids.length;
            for (uint256 i = 0; i < ids.length; i++) {
                uint256 tokenId = ids[i];
                require(
                    _isApprovedOrOwner(_msgSender(), tokenId),
                    "StarNFT: caller is not approved or owner"
                );
                require(isOwnerOf(account, tokenId), "StarNFT: not owner");
                // Clear approvals
                _approve(address(0), tokenId);
                _tokens[tokenId].owner = 0;
                _tokens[tokenId].cid = 0;
                emit Transfer(account, address(0), tokenId);
            }
        }
        /**
         * @dev Transfers `tokenId` from `from` to `to`.
         *  As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
         *
         * Requirements:
         *
         * - `to` cannot be the zero address.
         * - `tokenId` token must be owned by `from`.
         *
         * Emits a {Transfer} event.
         */
        function _transfer(
            address from,
            address to,
            uint256 tokenId
        ) internal virtual {
            require(
                isOwnerOf(from, tokenId),
                "ERC721: transfer of token that is not own"
            );
            require(to != address(0), "ERC721: transfer to the zero address");
            // Clear approvals from the previous owner
            _approve(address(0), tokenId);
            _balances[from] -= 1;
            _balances[to] += 1;
            _tokens[tokenId].owner = uint160(to);
            emit Transfer(from, to, tokenId);
        }
        /**
         * @dev Approve `to` to operate on `tokenId`
         *
         * Emits a {Approval} event.
         */
        function _approve(address to, uint256 tokenId) internal virtual {
            _tokenApprovals[tokenId] = to;
            emit Approval(ownerOf(tokenId), to, tokenId);
        }
        /**
         * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
         * The call is not executed if the target address is not a contract.
         *
         * @param from address representing the previous owner of the given token ID
         * @param to target address that will receive the tokens
         * @param tokenId uint256 ID of the token to be transferred
         * @param _data bytes optional data to send along with the call
         * @return bool whether the call correctly returned the expected magic value
         */
        function _checkOnERC721Received(
            address from,
            address to,
            uint256 tokenId,
            bytes memory _data
        ) private returns (bool) {
            if (to.isContract()) {
                try
                IERC721Receiver(to).onERC721Received(
                    _msgSender(),
                    from,
                    tokenId,
                    _data
                )
                returns (bytes4 retval) {
                    return retval == IERC721Receiver.onERC721Received.selector;
                } catch (bytes memory reason) {
                    if (reason.length == 0) {
                        revert(
                        "ERC721: transfer to non ERC721Receiver implementer"
                        );
                    } else {
                        assembly {
                            revert(add(32, reason), mload(reason))
                        }
                    }
                }
            }
            return true;
        }
        /* ============ Util Functions ============ */
        /**
         * @dev Sets a new baseURI for all token types.
         */
        function setURI(string calldata newURI) external onlyOwner {
            _baseURI = newURI;
        }
        /**
         * @dev Sets a new transferable for all token types.
         */
        function setTransferable(bool transferable) external onlyOwner {
            _transferable = transferable;
        }
        /**
         * @dev Sets a new name for all token types.
         */
        function setName(string calldata newName) external onlyOwner {
            _name = newName;
        }
        /**
         * @dev Sets a new symbol for all token types.
         */
        function setSymbol(string calldata newSymbol) external onlyOwner {
            _symbol = newSymbol;
        }
        /**
         * @dev Add a new minter.
         */
        function addMinter(address minter) external onlyOwner {
            require(minter != address(0), "minter must not be null address");
            require(!_minters[minter], "minter already added");
            _minters[minter] = true;
            emit EventMinterAdded(minter);
        }
        /**
         * @dev Remove a old minter.
         */
        function removeMinter(address minter) external onlyOwner {
            require(_minters[minter], "minter does not exist");
            delete _minters[minter];
            emit EventMinterRemoved(minter);
        }
    }// SPDX-License-Identifier: MIT
    pragma solidity >=0.6.2 <0.8.0;
    import "IERC165.sol";
    /**
     * @dev Required interface of an ERC721 compliant contract.
     */
    interface IERC721 is IERC165 {
        /**
         * @dev Emitted when `tokenId` token is transferred from `from` to `to`.
         */
        event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
        /**
         * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
         */
        event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
        /**
         * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
         */
        event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
        /**
         * @dev Returns the number of tokens in ``owner``'s account.
         */
        function balanceOf(address owner) external view returns (uint256 balance);
        /**
         * @dev Returns the owner of the `tokenId` token.
         *
         * Requirements:
         *
         * - `tokenId` must exist.
         */
        function ownerOf(uint256 tokenId) external view returns (address owner);
        /**
         * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
         * are aware of the ERC721 protocol to prevent tokens from being forever locked.
         *
         * Requirements:
         *
         * - `from` cannot be the zero address.
         * - `to` cannot be the zero address.
         * - `tokenId` token must exist and be owned by `from`.
         * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.
         * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
         *
         * Emits a {Transfer} event.
         */
        function safeTransferFrom(address from, address to, uint256 tokenId) external;
        /**
         * @dev Transfers `tokenId` token from `from` to `to`.
         *
         * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
         *
         * Requirements:
         *
         * - `from` cannot be the zero address.
         * - `to` cannot be the zero address.
         * - `tokenId` token must be owned by `from`.
         * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
         *
         * Emits a {Transfer} event.
         */
        function transferFrom(address from, address to, uint256 tokenId) external;
        /**
         * @dev Gives permission to `to` to transfer `tokenId` token to another account.
         * The approval is cleared when the token is transferred.
         *
         * Only a single account can be approved at a time, so approving the zero address clears previous approvals.
         *
         * Requirements:
         *
         * - The caller must own the token or be an approved operator.
         * - `tokenId` must exist.
         *
         * Emits an {Approval} event.
         */
        function approve(address to, uint256 tokenId) external;
        /**
         * @dev Returns the account approved for `tokenId` token.
         *
         * Requirements:
         *
         * - `tokenId` must exist.
         */
        function getApproved(uint256 tokenId) external view returns (address operator);
        /**
         * @dev Approve or remove `operator` as an operator for the caller.
         * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
         *
         * Requirements:
         *
         * - The `operator` cannot be the caller.
         *
         * Emits an {ApprovalForAll} event.
         */
        function setApprovalForAll(address operator, bool _approved) external;
        /**
         * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
         *
         * See {setApprovalForAll}
         */
        function isApprovedForAll(address owner, address operator) external view returns (bool);
        /**
          * @dev Safely transfers `tokenId` token from `from` to `to`.
          *
          * Requirements:
          *
          * - `from` cannot be the zero address.
          * - `to` cannot be the zero address.
          * - `tokenId` token must exist and be owned by `from`.
          * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
          * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
          *
          * Emits a {Transfer} event.
          */
        function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;
    }
    // SPDX-License-Identifier: MIT
    pragma solidity >=0.6.0 <0.8.0;
    /**
     * @dev Interface of the ERC165 standard, as defined in the
     * https://eips.ethereum.org/EIPS/eip-165[EIP].
     *
     * Implementers can declare support of contract interfaces, which can then be
     * queried by others ({ERC165Checker}).
     *
     * For an implementation, see {ERC165}.
     */
    interface IERC165 {
        /**
         * @dev Returns true if this contract implements the interface defined by
         * `interfaceId`. See the corresponding
         * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
         * to learn more about how these ids are created.
         *
         * This function call must use less than 30 000 gas.
         */
        function supportsInterface(bytes4 interfaceId) external view returns (bool);
    }
    // SPDX-License-Identifier: MIT
    pragma solidity >=0.6.0 <0.8.0;
    /**
     * @title ERC721 token receiver interface
     * @dev Interface for any contract that wants to support safeTransfers
     * from ERC721 asset contracts.
     */
    interface IERC721Receiver {
        /**
         * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
         * by `operator` from `from`, this function is called.
         *
         * It must return its Solidity selector to confirm the token transfer.
         * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
         *
         * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`.
         */
        function onERC721Received(address operator, address from, uint256 tokenId, bytes calldata data) external returns (bytes4);
    }
    // SPDX-License-Identifier: MIT
    pragma solidity >=0.6.2 <0.8.0;
    import "IERC721.sol";
    /**
     * @title ERC-721 Non-Fungible Token Standard, optional metadata extension
     * @dev See https://eips.ethereum.org/EIPS/eip-721
     */
    interface IERC721Metadata is IERC721 {
        /**
         * @dev Returns the token collection name.
         */
        function name() external view returns (string memory);
        /**
         * @dev Returns the token collection symbol.
         */
        function symbol() external view returns (string memory);
        /**
         * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
         */
        function tokenURI(uint256 tokenId) external view returns (string memory);
    }
    // SPDX-License-Identifier: MIT
    pragma solidity >=0.6.2 <0.8.0;
    /**
     * @dev Collection of functions related to the address type
     */
    library Address {
        /**
         * @dev Returns true if `account` is a contract.
         *
         * [IMPORTANT]
         * ====
         * It is unsafe to assume that an address for which this function returns
         * false is an externally-owned account (EOA) and not a contract.
         *
         * Among others, `isContract` will return false for the following
         * types of addresses:
         *
         *  - an externally-owned account
         *  - a contract in construction
         *  - an address where a contract will be created
         *  - an address where a contract lived, but was destroyed
         * ====
         */
        function isContract(address account) internal view returns (bool) {
            // This method relies on extcodesize, which returns 0 for contracts in
            // construction, since the code is only stored at the end of the
            // constructor execution.
            uint256 size;
            // solhint-disable-next-line no-inline-assembly
            assembly { size := extcodesize(account) }
            return size > 0;
        }
        /**
         * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
         * `recipient`, forwarding all available gas and reverting on errors.
         *
         * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
         * of certain opcodes, possibly making contracts go over the 2300 gas limit
         * imposed by `transfer`, making them unable to receive funds via
         * `transfer`. {sendValue} removes this limitation.
         *
         * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
         *
         * IMPORTANT: because control is transferred to `recipient`, care must be
         * taken to not create reentrancy vulnerabilities. Consider using
         * {ReentrancyGuard} or the
         * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
         */
        function sendValue(address payable recipient, uint256 amount) internal {
            require(address(this).balance >= amount, "Address: insufficient balance");
            // solhint-disable-next-line avoid-low-level-calls, avoid-call-value
            (bool success, ) = recipient.call{ value: amount }("");
            require(success, "Address: unable to send value, recipient may have reverted");
        }
        /**
         * @dev Performs a Solidity function call using a low level `call`. A
         * plain`call` is an unsafe replacement for a function call: use this
         * function instead.
         *
         * If `target` reverts with a revert reason, it is bubbled up by this
         * function (like regular Solidity function calls).
         *
         * Returns the raw returned data. To convert to the expected return value,
         * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
         *
         * Requirements:
         *
         * - `target` must be a contract.
         * - calling `target` with `data` must not revert.
         *
         * _Available since v3.1._
         */
        function functionCall(address target, bytes memory data) internal returns (bytes memory) {
          return functionCall(target, data, "Address: low-level call failed");
        }
        /**
         * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
         * `errorMessage` as a fallback revert reason when `target` reverts.
         *
         * _Available since v3.1._
         */
        function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
            return functionCallWithValue(target, data, 0, errorMessage);
        }
        /**
         * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
         * but also transferring `value` wei to `target`.
         *
         * Requirements:
         *
         * - the calling contract must have an ETH balance of at least `value`.
         * - the called Solidity function must be `payable`.
         *
         * _Available since v3.1._
         */
        function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
            return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
        }
        /**
         * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
         * with `errorMessage` as a fallback revert reason when `target` reverts.
         *
         * _Available since v3.1._
         */
        function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
            require(address(this).balance >= value, "Address: insufficient balance for call");
            require(isContract(target), "Address: call to non-contract");
            // solhint-disable-next-line avoid-low-level-calls
            (bool success, bytes memory returndata) = target.call{ value: value }(data);
            return _verifyCallResult(success, returndata, errorMessage);
        }
        /**
         * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
         * but performing a static call.
         *
         * _Available since v3.3._
         */
        function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
            return functionStaticCall(target, data, "Address: low-level static call failed");
        }
        /**
         * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
         * but performing a static call.
         *
         * _Available since v3.3._
         */
        function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {
            require(isContract(target), "Address: static call to non-contract");
            // solhint-disable-next-line avoid-low-level-calls
            (bool success, bytes memory returndata) = target.staticcall(data);
            return _verifyCallResult(success, returndata, errorMessage);
        }
        /**
         * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
         * but performing a delegate call.
         *
         * _Available since v3.4._
         */
        function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
            return functionDelegateCall(target, data, "Address: low-level delegate call failed");
        }
        /**
         * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
         * but performing a delegate call.
         *
         * _Available since v3.4._
         */
        function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
            require(isContract(target), "Address: delegate call to non-contract");
            // solhint-disable-next-line avoid-low-level-calls
            (bool success, bytes memory returndata) = target.delegatecall(data);
            return _verifyCallResult(success, returndata, errorMessage);
        }
        function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {
            if (success) {
                return returndata;
            } else {
                // Look for revert reason and bubble it up if present
                if (returndata.length > 0) {
                    // The easiest way to bubble the revert reason is using memory via assembly
                    // solhint-disable-next-line no-inline-assembly
                    assembly {
                        let returndata_size := mload(returndata)
                        revert(add(32, returndata), returndata_size)
                    }
                } else {
                    revert(errorMessage);
                }
            }
        }
    }
    // SPDX-License-Identifier: MIT
    pragma solidity >=0.6.0 <0.8.0;
    /**
     * @dev String operations.
     */
    library Strings {
        /**
         * @dev Converts a `uint256` to its ASCII `string` representation.
         */
        function toString(uint256 value) internal pure returns (string memory) {
            // Inspired by OraclizeAPI's implementation - MIT licence
            // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
            if (value == 0) {
                return "0";
            }
            uint256 temp = value;
            uint256 digits;
            while (temp != 0) {
                digits++;
                temp /= 10;
            }
            bytes memory buffer = new bytes(digits);
            uint256 index = digits - 1;
            temp = value;
            while (temp != 0) {
                buffer[index--] = bytes1(uint8(48 + temp % 10));
                temp /= 10;
            }
            return string(buffer);
        }
    }
    // SPDX-License-Identifier: MIT
    pragma solidity >=0.6.0 <0.8.0;
    import "Context.sol";
    /**
     * @dev Contract module which provides a basic access control mechanism, where
     * there is an account (an owner) that can be granted exclusive access to
     * specific functions.
     *
     * By default, the owner account will be the one that deploys the contract. This
     * can later be changed with {transferOwnership}.
     *
     * This module is used through inheritance. It will make available the modifier
     * `onlyOwner`, which can be applied to your functions to restrict their use to
     * the owner.
     */
    abstract contract Ownable is Context {
        address private _owner;
        event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
        /**
         * @dev Initializes the contract setting the deployer as the initial owner.
         */
        constructor () internal {
            address msgSender = _msgSender();
            _owner = msgSender;
            emit OwnershipTransferred(address(0), msgSender);
        }
        /**
         * @dev Returns the address of the current owner.
         */
        function owner() public view virtual returns (address) {
            return _owner;
        }
        /**
         * @dev Throws if called by any account other than the owner.
         */
        modifier onlyOwner() {
            require(owner() == _msgSender(), "Ownable: caller is not the owner");
            _;
        }
        /**
         * @dev Leaves the contract without owner. It will not be possible to call
         * `onlyOwner` functions anymore. Can only be called by the current owner.
         *
         * NOTE: Renouncing ownership will leave the contract without an owner,
         * thereby removing any functionality that is only available to the owner.
         */
        function renounceOwnership() public virtual onlyOwner {
            emit OwnershipTransferred(_owner, address(0));
            _owner = address(0);
        }
        /**
         * @dev Transfers ownership of the contract to a new account (`newOwner`).
         * Can only be called by the current owner.
         */
        function transferOwnership(address newOwner) public virtual onlyOwner {
            require(newOwner != address(0), "Ownable: new owner is the zero address");
            emit OwnershipTransferred(_owner, newOwner);
            _owner = newOwner;
        }
    }
    // SPDX-License-Identifier: MIT
    pragma solidity >=0.6.0 <0.8.0;
    /*
     * @dev Provides information about the current execution context, including the
     * sender of the transaction and its data. While these are generally available
     * via msg.sender and msg.data, they should not be accessed in such a direct
     * manner, since when dealing with GSN meta-transactions the account sending and
     * paying for execution may not be the actual sender (as far as an application
     * is concerned).
     *
     * This contract is only required for intermediate, library-like contracts.
     */
    abstract contract Context {
        function _msgSender() internal view virtual returns (address payable) {
            return msg.sender;
        }
        function _msgData() internal view virtual returns (bytes memory) {
            this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
            return msg.data;
        }
    }
    // SPDX-License-Identifier: MIT
    pragma solidity >=0.6.0 <0.8.0;
    import "IERC165.sol";
    /**
     * @dev Implementation of the {IERC165} interface.
     *
     * Contracts may inherit from this and call {_registerInterface} to declare
     * their support of an interface.
     */
    abstract contract ERC165 is IERC165 {
        /*
         * bytes4(keccak256('supportsInterface(bytes4)')) == 0x01ffc9a7
         */
        bytes4 private constant _INTERFACE_ID_ERC165 = 0x01ffc9a7;
        /**
         * @dev Mapping of interface ids to whether or not it's supported.
         */
        mapping(bytes4 => bool) private _supportedInterfaces;
        constructor () internal {
            // Derived contracts need only register support for their own interfaces,
            // we register support for ERC165 itself here
            _registerInterface(_INTERFACE_ID_ERC165);
        }
        /**
         * @dev See {IERC165-supportsInterface}.
         *
         * Time complexity O(1), guaranteed to always use less than 30 000 gas.
         */
        function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
            return _supportedInterfaces[interfaceId];
        }
        /**
         * @dev Registers the contract as an implementer of the interface defined by
         * `interfaceId`. Support of the actual ERC165 interface is automatic and
         * registering its interface id is not required.
         *
         * See {IERC165-supportsInterface}.
         *
         * Requirements:
         *
         * - `interfaceId` cannot be the ERC165 invalid interface (`0xffffffff`).
         */
        function _registerInterface(bytes4 interfaceId) internal virtual {
            require(interfaceId != 0xffffffff, "ERC165: invalid interface id");
            _supportedInterfaces[interfaceId] = true;
        }
    }
    /*
        Copyright 2021 Project Galaxy.
        Licensed under the Apache License, Version 2.0 (the "License");
        you may not use this file except in compliance with the License.
        You may obtain a copy of the License at
        http://www.apache.org/licenses/LICENSE-2.0
        Unless required by applicable law or agreed to in writing, software
        distributed under the License is distributed on an "AS IS" BASIS,
        WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
        See the License for the specific language governing permissions and
        limitations under the License.
        SPDX-License-Identifier: Apache License, Version 2.0
    */
    pragma solidity 0.7.6;
    /**
     * @title IStarNFT
     * @author Galaxy Protocol
     *
     * Interface for operating with StarNFTs.
     */
    interface IStarNFT {
        /* ============ Events =============== */
        /* ============ Functions ============ */
        function isOwnerOf(address, uint256) external view returns (bool);
        function getNumMinted() external view returns (uint256);
        // mint
        function mint(address account, uint256 powah) external returns (uint256);
        function mintBatch(address account, uint256 amount, uint256[] calldata powahArr) external returns (uint256[] memory);
        function burn(address account, uint256 id) external;
        function burnBatch(address account, uint256[] calldata ids) external;
    }