ETH Price: $1,903.68 (-0.40%)
Gas: 0.5 Gwei

Transaction Decoder

Block:
12172742 at Apr-04-2021 11:10:45 AM +UTC
Transaction Fee:
0.00509827 ETH $9.71
Gas Used:
53,666 Gas / 95 Gwei

Emitted Events:

100 AdminUpgradeabilityProxy.0x39b0a0620bb668047ab7248973ddfd93d53dff1d4952bd2d56bbf5934edc1fd0( 0x39b0a0620bb668047ab7248973ddfd93d53dff1d4952bd2d56bbf5934edc1fd0, 0x000000000000000000000000ffbdda5105e20bcda6a1c2d3736e715579ad8683, 0000000000000000000000000000000000000000000000000000000000000001, 0000000000000000000000000000000000000000000000000000000000000000, 0000000000000000000000000000000000000000000000000000000000000001, 0000000000000000000000000000000000000000000000000000000000ba028c )

Account State Difference:

  Address   Before After State Difference Code
0x4B5057B2...fF2FDaCad 43.897623409339969628 Eth43.905117143675809228 Eth0.0074937343358396
(Spark Pool)
33.535572456799181874 Eth33.540670726799181874 Eth0.00509827
0xFbdDaDD8...2238Ae655
(StrongBlock: Service)
0xffbddA51...579AD8683
0.053033286514437379 Eth
Nonce: 16
0.040441282178597779 Eth
Nonce: 17
0.0125920043358396

Execution Trace

ETH 0.0074937343358396 AdminUpgradeabilityProxy.0f694584( )
  • ServiceV11.payFee( nodeId=1 )
    • ETH 0.0074937343358396 0x4b5057b2c87ec9e7c047fb00c0e406dff2fdacad.CALL( )
      File 1 of 2: AdminUpgradeabilityProxy
      // SPDX-License-Identifier: MIT
      pragma solidity ^0.6.0;
      import './UpgradeabilityProxy.sol';
      /**
       * @title AdminUpgradeabilityProxy
       * @dev This contract combines an upgradeability proxy with an authorization
       * mechanism for administrative tasks.
       * All external functions in this contract must be guarded by the
       * `ifAdmin` modifier. See ethereum/solidity#3864 for a Solidity
       * feature proposal that would enable this to be done automatically.
       */
      contract AdminUpgradeabilityProxy is UpgradeabilityProxy {
        /**
         * Contract constructor.
         * @param _logic address of the initial implementation.
         * @param _admin Address of the proxy administrator.
         * @param _data Data to send as msg.data to the implementation to initialize the proxied contract.
         * It should include the signature and the parameters of the function to be called, as described in
         * https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding.
         * This parameter is optional, if no data is given the initialization call to proxied contract will be skipped.
         */
        constructor(address _logic, address _admin, bytes memory _data) UpgradeabilityProxy(_logic, _data) public payable {
          assert(ADMIN_SLOT == bytes32(uint256(keccak256('eip1967.proxy.admin')) - 1));
          _setAdmin(_admin);
        }
        /**
         * @dev Emitted when the administration has been transferred.
         * @param previousAdmin Address of the previous admin.
         * @param newAdmin Address of the new admin.
         */
        event AdminChanged(address previousAdmin, address newAdmin);
        /**
         * @dev Storage slot with the admin of the contract.
         * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is
         * validated in the constructor.
         */
        bytes32 internal constant ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
        /**
         * @dev Modifier to check whether the `msg.sender` is the admin.
         * If it is, it will run the function. Otherwise, it will delegate the call
         * to the implementation.
         */
        modifier ifAdmin() {
          if (msg.sender == _admin()) {
            _;
          } else {
            _fallback();
          }
        }
        /**
         * @return The address of the proxy admin.
         */
        function admin() external ifAdmin returns (address) {
          return _admin();
        }
        /**
         * @return The address of the implementation.
         */
        function implementation() external ifAdmin returns (address) {
          return _implementation();
        }
        /**
         * @dev Changes the admin of the proxy.
         * Only the current admin can call this function.
         * @param newAdmin Address to transfer proxy administration to.
         */
        function changeAdmin(address newAdmin) external ifAdmin {
          require(newAdmin != address(0), "Cannot change the admin of a proxy to the zero address");
          emit AdminChanged(_admin(), newAdmin);
          _setAdmin(newAdmin);
        }
        /**
         * @dev Upgrade the backing implementation of the proxy.
         * Only the admin can call this function.
         * @param newImplementation Address of the new implementation.
         */
        function upgradeTo(address newImplementation) external ifAdmin {
          _upgradeTo(newImplementation);
        }
        /**
         * @dev Upgrade the backing implementation of the proxy and call a function
         * on the new implementation.
         * This is useful to initialize the proxied contract.
         * @param newImplementation Address of the new implementation.
         * @param data Data to send as msg.data in the low level call.
         * It should include the signature and the parameters of the function to be called, as described in
         * https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding.
         */
        function upgradeToAndCall(address newImplementation, bytes calldata data) payable external ifAdmin {
          _upgradeTo(newImplementation);
          (bool success,) = newImplementation.delegatecall(data);
          require(success);
        }
        /**
         * @return adm The admin slot.
         */
        function _admin() internal view returns (address adm) {
          bytes32 slot = ADMIN_SLOT;
          assembly {
            adm := sload(slot)
          }
        }
        /**
         * @dev Sets the address of the proxy admin.
         * @param newAdmin Address of the new proxy admin.
         */
        function _setAdmin(address newAdmin) internal {
          bytes32 slot = ADMIN_SLOT;
          assembly {
            sstore(slot, newAdmin)
          }
        }
        /**
         * @dev Only fall back when the sender is not the admin.
         */
        function _willFallback() internal override virtual {
          require(msg.sender != _admin(), "Cannot call fallback function from the proxy admin");
          super._willFallback();
        }
      }
      // SPDX-License-Identifier: MIT
      pragma solidity ^0.6.0;
      import './Proxy.sol';
      import '@openzeppelin/contracts/utils/Address.sol';
      /**
       * @title UpgradeabilityProxy
       * @dev This contract implements a proxy that allows to change the
       * implementation address to which it will delegate.
       * Such a change is called an implementation upgrade.
       */
      contract UpgradeabilityProxy is Proxy {
        /**
         * @dev Contract constructor.
         * @param _logic Address of the initial implementation.
         * @param _data Data to send as msg.data to the implementation to initialize the proxied contract.
         * It should include the signature and the parameters of the function to be called, as described in
         * https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding.
         * This parameter is optional, if no data is given the initialization call to proxied contract will be skipped.
         */
        constructor(address _logic, bytes memory _data) public payable {
          assert(IMPLEMENTATION_SLOT == bytes32(uint256(keccak256('eip1967.proxy.implementation')) - 1));
          _setImplementation(_logic);
          if(_data.length > 0) {
            (bool success,) = _logic.delegatecall(_data);
            require(success);
          }
        }  
        /**
         * @dev Emitted when the implementation is upgraded.
         * @param implementation Address of the new implementation.
         */
        event Upgraded(address indexed implementation);
        /**
         * @dev Storage slot with the address of the current implementation.
         * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is
         * validated in the constructor.
         */
        bytes32 internal constant IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
        /**
         * @dev Returns the current implementation.
         * @return impl Address of the current implementation
         */
        function _implementation() internal override view returns (address impl) {
          bytes32 slot = IMPLEMENTATION_SLOT;
          assembly {
            impl := sload(slot)
          }
        }
        /**
         * @dev Upgrades the proxy to a new implementation.
         * @param newImplementation Address of the new implementation.
         */
        function _upgradeTo(address newImplementation) internal {
          _setImplementation(newImplementation);
          emit Upgraded(newImplementation);
        }
        /**
         * @dev Sets the implementation address of the proxy.
         * @param newImplementation Address of the new implementation.
         */
        function _setImplementation(address newImplementation) internal {
          require(Address.isContract(newImplementation), "Cannot set a proxy implementation to a non-contract address");
          bytes32 slot = IMPLEMENTATION_SLOT;
          assembly {
            sstore(slot, newImplementation)
          }
        }
      }
      // SPDX-License-Identifier: MIT
      pragma solidity ^0.6.0;
      /**
       * @title Proxy
       * @dev Implements delegation of calls to other contracts, with proper
       * forwarding of return values and bubbling of failures.
       * It defines a fallback function that delegates all calls to the address
       * returned by the abstract _implementation() internal function.
       */
      abstract contract Proxy {
        /**
         * @dev Fallback function.
         * Implemented entirely in `_fallback`.
         */
        fallback () payable external {
          _fallback();
        }
        /**
         * @dev Receive function.
         * Implemented entirely in `_fallback`.
         */
        receive () payable external {
          _fallback();
        }
        /**
         * @return The Address of the implementation.
         */
        function _implementation() internal virtual view returns (address);
        /**
         * @dev Delegates execution to an implementation contract.
         * This is a low level function that doesn't return to its internal call site.
         * It will return to the external caller whatever the implementation returns.
         * @param implementation Address to delegate.
         */
        function _delegate(address implementation) internal {
          assembly {
            // Copy msg.data. We take full control of memory in this inline assembly
            // block because it will not return to Solidity code. We overwrite the
            // Solidity scratch pad at memory position 0.
            calldatacopy(0, 0, calldatasize())
            // Call the implementation.
            // out and outsize are 0 because we don't know the size yet.
            let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)
            // Copy the returned data.
            returndatacopy(0, 0, returndatasize())
            switch result
            // delegatecall returns 0 on error.
            case 0 { revert(0, returndatasize()) }
            default { return(0, returndatasize()) }
          }
        }
        /**
         * @dev Function that is run as the first thing in the fallback function.
         * Can be redefined in derived contracts to add functionality.
         * Redefinitions must call super._willFallback().
         */
        function _willFallback() internal virtual {
        }
        /**
         * @dev fallback implementation.
         * Extracted to enable manual triggering.
         */
        function _fallback() internal {
          _willFallback();
          _delegate(_implementation());
        }
      }
      // 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);
          }
          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);
                  }
              }
          }
      }
      

      File 2 of 2: ServiceV11
      {"Context.sol":{"content":"// SPDX-License-Identifier: MIT\n\npragma solidity ^0.6.0;\n\n/*\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with GSN meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n    function _msgSender() internal view virtual returns (address payable) {\n        return msg.sender;\n    }\n\n    function _msgData() internal view virtual returns (bytes memory) {\n        this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691\n        return msg.data;\n    }\n}\n"},"Counters.sol":{"content":"// SPDX-License-Identifier: MIT\n\npragma solidity ^0.6.0;\n\nimport \"./SafeMath.sol\";\n\n/**\n * @title Counters\n * @author Matt Condon (@shrugs)\n * @dev Provides counters that can only be incremented or decremented by one. This can be used e.g. to track the number\n * of elements in a mapping, issuing ERC721 ids, or counting request ids.\n *\n * Include with `using Counters for Counters.Counter;`\n * Since it is not possible to overflow a 256 bit integer with increments of one, `increment` can skip the {SafeMath}\n * overflow check, thereby saving gas. This does assume however correct usage, in that the underlying `_value` is never\n * directly accessed.\n */\nlibrary Counters {\n    using SafeMath for uint256;\n\n    struct Counter {\n        // This variable should never be directly accessed by users of the library: interactions must be restricted to\n        // the library\u0027s function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add\n        // this feature: see https://github.com/ethereum/solidity/issues/4637\n        uint256 _value; // default: 0\n    }\n\n    function current(Counter storage counter) internal view returns (uint256) {\n        return counter._value;\n    }\n\n    function increment(Counter storage counter) internal {\n        // The {SafeMath} overflow check can be skipped here, see the comment at the top\n        counter._value += 1;\n    }\n\n    function decrement(Counter storage counter) internal {\n        counter._value = counter._value.sub(1);\n    }\n}\n"},"IERC1155Preset.sol":{"content":"// SPDX-License-Identifier: MIT\n\npragma solidity ^0.6.2;\n\n/**\n * @dev Required interface of an ERC1155 compliant contract, as defined in the\n * https://eips.ethereum.org/EIPS/eip-1155[EIP].\n *\n * _Available since v3.1._\n */\ninterface IERC1155Preset {\n    /**\n     * @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`.\n     */\n    event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);\n\n    /**\n     * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all\n     * transfers.\n     */\n    event TransferBatch(address indexed operator, address indexed from, address indexed to, uint256[] ids, uint256[] values);\n\n    /**\n     * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to\n     * `approved`.\n     */\n    event ApprovalForAll(address indexed account, address indexed operator, bool approved);\n\n    /**\n     * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI.\n     *\n     * If an {URI} event was emitted for `id`, the standard\n     * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value\n     * returned by {IERC1155MetadataURI-uri}.\n     */\n    event URI(string value, uint256 indexed id);\n\n    /**\n     * @dev Returns the amount of tokens of token type `id` owned by `account`.\n     *\n     * Requirements:\n     *\n     * - `account` cannot be the zero address.\n     */\n    function balanceOf(address account, uint256 id) external view returns (uint256);\n\n    /**\n     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}.\n     *\n     * Requirements:\n     *\n     * - `accounts` and `ids` must have the same length.\n     */\n    function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids) external view returns (uint256[] memory);\n\n    /**\n     * @dev Grants or revokes permission to `operator` to transfer the caller\u0027s tokens, according to `approved`,\n     *\n     * Emits an {ApprovalForAll} event.\n     *\n     * Requirements:\n     *\n     * - `operator` cannot be the caller.\n     */\n    function setApprovalForAll(address operator, bool approved) external;\n\n    /**\n     * @dev Returns true if `operator` is approved to transfer ``account``\u0027s tokens.\n     *\n     * See {setApprovalForAll}.\n     */\n    function isApprovedForAll(address account, address operator) external view returns (bool);\n\n    /**\n     * @dev Transfers `amount` tokens of token type `id` from `from` to `to`.\n     *\n     * Emits a {TransferSingle} event.\n     *\n     * Requirements:\n     *\n     * - `to` cannot be the zero address.\n     * - If the caller is not `from`, it must be have been approved to spend ``from``\u0027s tokens via {setApprovalForAll}.\n     * - `from` must have a balance of tokens of type `id` of at least `amount`.\n     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the\n     * acceptance magic value.\n     */\n    function safeTransferFrom(address from, address to, uint256 id, uint256 amount, bytes calldata data) external;\n\n    /**\n     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.\n     *\n     * Emits a {TransferBatch} event.\n     *\n     * Requirements:\n     *\n     * - `ids` and `amounts` must have the same length.\n     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the\n     * acceptance magic value.\n     */\n    function safeBatchTransferFrom(address from, address to, uint256[] calldata ids, uint256[] calldata amounts, bytes calldata data) external;\n\n    /**\n     * @dev Returns true if this contract implements the interface defined by\n     * `interfaceId`. See the corresponding\n     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n     * to learn more about how these ids are created.\n     *\n     * This function call must use less than 30 000 gas.\n     */\n    function supportsInterface(bytes4 interfaceId) external view returns (bool);\n\n    /**\n     * @dev Creates `amount` new tokens for `to`, of token type `id`.\n     *\n     * See {ERC1155-_mint}.\n     *\n     * Requirements:\n     *\n     * - the caller must have the `MINTER_ROLE`.\n     */\n    function mint(address to, uint256 id, uint256 amount, bytes memory data) external;\n\n    /**\n     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] variant of {mint}.\n     */\n    function mintBatch(address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data) external;\n\n    function getOwnerIdByIndex(address owner, uint256 index) external view returns (uint256);\n\n    function getOwnerIdIndex(address owner, uint256 id) external view returns (uint256);\n}\n"},"IERC20.sol":{"content":"// SPDX-License-Identifier: MIT\n\npragma solidity \u003e=0.6.0 \u003c0.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     */\n    function 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     */\n    function 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     */\n    function 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     */\n    function 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     */\n    function 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}\n"},"rewards.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity 0.6.12;\n\nimport \"./SafeMath.sol\";\n\nlibrary rewards {\n\n    using SafeMath for uint256;\n\n    function blocks(uint256 lastClaimedOnBlock, uint256 newRewardBlock, uint256 blockNumber) internal pure returns (uint256[2] memory) {\n        if (lastClaimedOnBlock \u003e= blockNumber) return [uint256(0), uint256(0)];\n\n        if (blockNumber \u003c= newRewardBlock || newRewardBlock == 0) {\n            return [blockNumber.sub(lastClaimedOnBlock), uint256(0)];\n        }\n        else if (lastClaimedOnBlock \u003e= newRewardBlock) {\n            return [uint256(0), blockNumber.sub(lastClaimedOnBlock)];\n        }\n        else {\n            return [newRewardBlock.sub(lastClaimedOnBlock), blockNumber.sub(newRewardBlock)];\n        }\n    }\n\n}\n"},"SafeMath.sol":{"content":"// SPDX-License-Identifier: MIT\n\npragma solidity \u003e=0.6.0 \u003c0.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, 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\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        return sub(a, b, \"SafeMath: subtraction overflow\");\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     * 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        uint256 c = a - b;\n\n        return c;\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        // 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) {\n            return 0;\n        }\n\n        uint256 c = a * b;\n        require(c / a == b, \"SafeMath: multiplication overflow\");\n\n        return c;\n    }\n\n    /**\n     * @dev Returns the integer division of two unsigned integers. Reverts 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        return div(a, b, \"SafeMath: division by zero\");\n    }\n\n    /**\n     * @dev Returns the integer division of two unsigned integers. Reverts with custom message on\n     * division by zero. The result is rounded towards zero.\n     *\n     * Counterpart to Solidity\u0027s `/` operator. Note: this function uses a\n     * `revert` opcode (which leaves remaining gas untouched) while Solidity\n     * uses an invalid opcode to revert (consuming all remaining gas).\n     *\n     * Requirements:\n     *\n     * - The divisor cannot be zero.\n     */\n    function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\n        require(b \u003e 0, errorMessage);\n        uint256 c = a / b;\n        // assert(a == b * c + a % b); // There is no case in which this doesn\u0027t hold\n\n        return c;\n    }\n\n    /**\n     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\n     * Reverts when dividing by zero.\n     *\n     * Counterpart to Solidity\u0027s `%` operator. This function uses a `revert`\n     * opcode (which leaves remaining gas untouched) while Solidity uses an\n     * invalid opcode to revert (consuming all remaining gas).\n     *\n     * Requirements:\n     *\n     * - The divisor cannot be zero.\n     */\n    function mod(uint256 a, uint256 b) internal pure returns (uint256) {\n        return mod(a, b, \"SafeMath: modulo by zero\");\n    }\n\n    /**\n     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\n     * Reverts with custom message 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, string memory errorMessage) internal pure returns (uint256) {\n        require(b != 0, errorMessage);\n        return a % b;\n    }\n}\n"},"ServiceInterface.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity ^0.6.12;\n\ninterface ServiceInterface {\n  function claimingFeeNumerator() external view returns(uint256);\n\n  function claimingFeeDenominator() external view returns(uint256);\n\n  function doesNodeExist(address entity, uint128 nodeId) external view returns (bool);\n\n  function getNodeId(address entity, uint128 nodeId) external view returns (bytes memory);\n\n  function getReward(address entity, uint128 nodeId) external view returns (uint256);\n\n  function getRewardByBlock(address entity, uint128 nodeId, uint256 blockNumber) external view returns (uint256);\n\n  function getTraunch(address entity) external view returns (uint256);\n\n  function isEntityActive(address entity) external view returns (bool);\n\n  function claim(uint128 nodeId, uint256 blockNumber, bool toStrongPool) external payable;\n}\n"},"ServiceInterfaceV10.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity ^0.6.12;\n\ninterface ServiceInterfaceV10 {\n  function traunch(address) external view returns(uint256);\n\n  function claimingFeeNumerator() external view returns(uint256);\n\n  function claimingFeeDenominator() external view returns(uint256);\n\n  function doesNodeExist(address entity, uint128 nodeId) external view returns (bool);\n\n  function getNodeId(address entity, uint128 nodeId) external view returns (bytes memory);\n\n  function getReward(address entity, uint128 nodeId) external view returns (uint256);\n\n  function getRewardByBlock(address entity, uint128 nodeId, uint256 blockNumber) external view returns (uint256);\n\n  function isEntityActive(address entity) external view returns (bool);\n\n  function claim(uint128 nodeId, uint256 blockNumber, bool toStrongPool) external payable;\n}\n"},"ServiceV10.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity 0.6.12;\n\nimport \"./IERC20.sol\";\nimport \"./SafeMath.sol\";\nimport \"./StrongPoolInterface.sol\";\nimport \"./IERC1155Preset.sol\";\nimport \"./StrongNFTBonusInterface.sol\";\nimport \"./rewards.sol\";\n\ncontract ServiceV10 {\n  event Requested(address indexed miner);\n  event Claimed(address indexed miner, uint256 reward);\n\n  using SafeMath for uint256;\n  bool public initDone;\n  address public admin;\n  address public pendingAdmin;\n  address public superAdmin;\n  address public pendingSuperAdmin;\n  address public serviceAdmin;\n  address public parameterAdmin;\n  address payable public feeCollector;\n\n  IERC20 public strongToken;\n  StrongPoolInterface public strongPool;\n\n  uint256 public rewardPerBlockNumerator;\n  uint256 public rewardPerBlockDenominator;\n\n  uint256 public naasRewardPerBlockNumerator;\n  uint256 public naasRewardPerBlockDenominator;\n\n  uint256 public claimingFeeNumerator;\n  uint256 public claimingFeeDenominator;\n\n  uint256 public requestingFeeInWei;\n\n  uint256 public strongFeeInWei;\n\n  uint256 public recurringFeeInWei;\n  uint256 public recurringNaaSFeeInWei;\n  uint256 public recurringPaymentCycleInBlocks;\n\n  uint256 public rewardBalance;\n\n  mapping(address =\u003e uint256) public entityBlockLastClaimedOn;\n\n  address[] public entities;\n  mapping(address =\u003e uint256) public entityIndex;\n  mapping(address =\u003e bool) public entityActive;\n  mapping(address =\u003e bool) public requestPending;\n  mapping(address =\u003e bool) public entityIsNaaS;\n  mapping(address =\u003e uint256) public paidOnBlock;\n  uint256 public activeEntities;\n\n  string public desciption;\n\n  uint256 public claimingFeeInWei;\n\n  uint256 public naasRequestingFeeInWei;\n\n  uint256 public naasStrongFeeInWei;\n\n  bool public removedTokens;\n\n  mapping(address =\u003e uint256) public traunch;\n\n  uint256 public currentTraunch;\n\n  mapping(bytes =\u003e bool) public entityNodeIsActive;\n  mapping(bytes =\u003e bool) public entityNodeIsBYON;\n  mapping(bytes =\u003e uint256) public entityNodeTraunch;\n  mapping(bytes =\u003e uint256) public entityNodePaidOnBlock;\n  mapping(bytes =\u003e uint256) public entityNodeClaimedOnBlock;\n  mapping(address =\u003e uint128) public entityNodeCount;\n\n  event Paid(address indexed entity, uint128 nodeId, bool isBYON, bool isRenewal, uint256 upToBlockNumber);\n  event Migrated(address indexed from, address indexed to, uint128 fromNodeId, uint128 toNodeId, bool isBYON);\n\n  uint256 public rewardPerBlockNumeratorNew;\n  uint256 public rewardPerBlockDenominatorNew;\n  uint256 public naasRewardPerBlockNumeratorNew;\n  uint256 public naasRewardPerBlockDenominatorNew;\n  uint256 public rewardPerBlockNewEffectiveBlock;\n\n  StrongNFTBonusInterface public strongNFTBonus;\n\n  function init(\n    address strongTokenAddress,\n    address strongPoolAddress,\n    address adminAddress,\n    address superAdminAddress,\n    uint256 rewardPerBlockNumeratorValue,\n    uint256 rewardPerBlockDenominatorValue,\n    uint256 naasRewardPerBlockNumeratorValue,\n    uint256 naasRewardPerBlockDenominatorValue,\n    uint256 requestingFeeInWeiValue,\n    uint256 strongFeeInWeiValue,\n    uint256 recurringFeeInWeiValue,\n    uint256 recurringNaaSFeeInWeiValue,\n    uint256 recurringPaymentCycleInBlocksValue,\n    uint256 claimingFeeNumeratorValue,\n    uint256 claimingFeeDenominatorValue,\n    string memory desc\n  ) public {\n    require(!initDone, \"init done\");\n    strongToken = IERC20(strongTokenAddress);\n    strongPool = StrongPoolInterface(strongPoolAddress);\n    admin = adminAddress;\n    superAdmin = superAdminAddress;\n    rewardPerBlockNumerator = rewardPerBlockNumeratorValue;\n    rewardPerBlockDenominator = rewardPerBlockDenominatorValue;\n    naasRewardPerBlockNumerator = naasRewardPerBlockNumeratorValue;\n    naasRewardPerBlockDenominator = naasRewardPerBlockDenominatorValue;\n    requestingFeeInWei = requestingFeeInWeiValue;\n    strongFeeInWei = strongFeeInWeiValue;\n    recurringFeeInWei = recurringFeeInWeiValue;\n    recurringNaaSFeeInWei = recurringNaaSFeeInWeiValue;\n    claimingFeeNumerator = claimingFeeNumeratorValue;\n    claimingFeeDenominator = claimingFeeDenominatorValue;\n    recurringPaymentCycleInBlocks = recurringPaymentCycleInBlocksValue;\n    desciption = desc;\n    initDone = true;\n  }\n\n  // ADMIN\n  // *************************************************************************************\n\n  function updateServiceAdmin(address newServiceAdmin) public {\n    require(msg.sender == superAdmin);\n    serviceAdmin = newServiceAdmin;\n  }\n\n  function updateParameterAdmin(address newParameterAdmin) public {\n    require(newParameterAdmin != address(0), \"zero\");\n    require(msg.sender == superAdmin);\n    parameterAdmin = newParameterAdmin;\n  }\n\n  function updateFeeCollector(address payable newFeeCollector) public {\n    require(newFeeCollector != address(0), \"zero\");\n    require(msg.sender == superAdmin);\n    feeCollector = newFeeCollector;\n  }\n\n  function setPendingAdmin(address newPendingAdmin) public {\n    require(msg.sender == admin, \"not admin\");\n    pendingAdmin = newPendingAdmin;\n  }\n\n  function acceptAdmin() public {\n    require(msg.sender == pendingAdmin \u0026\u0026 msg.sender != address(0), \"not pendingAdmin\");\n    admin = pendingAdmin;\n    pendingAdmin = address(0);\n  }\n\n  function setPendingSuperAdmin(address newPendingSuperAdmin) public {\n    require(msg.sender == superAdmin, \"not superAdmin\");\n    pendingSuperAdmin = newPendingSuperAdmin;\n  }\n\n  function acceptSuperAdmin() public {\n    require(msg.sender == pendingSuperAdmin \u0026\u0026 msg.sender != address(0), \"not pendingSuperAdmin\");\n    superAdmin = pendingSuperAdmin;\n    pendingSuperAdmin = address(0);\n  }\n\n  // ENTITIES\n  // *************************************************************************************\n\n  function getEntities() public view returns (address[] memory) {\n    return entities;\n  }\n\n  function isEntityActive(address entity) public view returns (bool) {\n    return entityActive[entity];\n  }\n\n  // TRAUNCH\n  // *************************************************************************************\n\n  function updateCurrentTraunch(uint256 value) public {\n    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, \"not admin\");\n    currentTraunch = value;\n  }\n\n  // REWARD\n  // *************************************************************************************\n\n  function updateRewardPerBlock(uint256 numerator, uint256 denominator) public {\n    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, \"not admin\");\n    require(denominator != 0, \"invalid value\");\n    rewardPerBlockNumerator = numerator;\n    rewardPerBlockDenominator = denominator;\n  }\n\n  function updateNaaSRewardPerBlock(uint256 numerator, uint256 denominator) public {\n    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, \"not admin\");\n    require(denominator != 0, \"invalid value\");\n    naasRewardPerBlockNumerator = numerator;\n    naasRewardPerBlockDenominator = denominator;\n  }\n\n  function updateRewardPerBlockNew(\n    uint256 numerator,\n    uint256 denominator,\n    uint256 numeratorNass,\n    uint256 denominatorNass,\n    uint256 effectiveBlock\n  ) public {\n    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, \"not admin\");\n\n    rewardPerBlockNumeratorNew = numerator;\n    rewardPerBlockDenominatorNew = denominator;\n    naasRewardPerBlockNumeratorNew = numeratorNass;\n    naasRewardPerBlockDenominatorNew = denominatorNass;\n    rewardPerBlockNewEffectiveBlock = effectiveBlock != 0 ? effectiveBlock : block.number;\n  }\n\n  function deposit(uint256 amount) public {\n    require(msg.sender == superAdmin, \"not admin\");\n    require(amount \u003e 0, \"zero\");\n    strongToken.transferFrom(msg.sender, address(this), amount);\n    rewardBalance = rewardBalance.add(amount);\n  }\n\n  function withdraw(address destination, uint256 amount) public {\n    require(msg.sender == superAdmin, \"not admin\");\n    require(amount \u003e 0, \"zero\");\n    require(rewardBalance \u003e= amount, \"not enough\");\n    strongToken.transfer(destination, amount);\n    rewardBalance = rewardBalance.sub(amount);\n  }\n\n  // FEES\n  // *************************************************************************************\n\n  function updateRequestingFee(uint256 feeInWei) public {\n    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, \"not admin\");\n    requestingFeeInWei = feeInWei;\n  }\n\n  function updateStrongFee(uint256 feeInWei) public {\n    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, \"not admin\");\n    strongFeeInWei = feeInWei;\n  }\n\n  function updateNaasRequestingFee(uint256 feeInWei) public {\n    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, \"not admin\");\n    naasRequestingFeeInWei = feeInWei;\n  }\n\n  function updateNaasStrongFee(uint256 feeInWei) public {\n    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, \"not admin\");\n    naasStrongFeeInWei = feeInWei;\n  }\n\n  function updateClaimingFee(uint256 numerator, uint256 denominator) public {\n    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, \"not admin\");\n    require(denominator != 0, \"invalid value\");\n    claimingFeeNumerator = numerator;\n    claimingFeeDenominator = denominator;\n  }\n\n  function updateRecurringFee(uint256 feeInWei) public {\n    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, \"not admin\");\n    recurringFeeInWei = feeInWei;\n  }\n\n  function updateRecurringNaaSFee(uint256 feeInWei) public {\n    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, \"not admin\");\n    recurringNaaSFeeInWei = feeInWei;\n  }\n\n  function updateRecurringPaymentCycleInBlocks(uint256 blocks) public {\n    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, \"not admin\");\n    require(blocks \u003e 0, \"zero\");\n    recurringPaymentCycleInBlocks = blocks;\n  }\n\n  // CORE\n  // *************************************************************************************\n\n  function requestAccess(bool isNaaS) public payable {\n    uint256 rFee;\n    uint256 sFee;\n\n    if (hasLegacyNode(msg.sender)) {\n      migrateLegacyNode(msg.sender);\n    }\n\n    uint128 nodeId = entityNodeCount[msg.sender] + 1;\n    bytes memory id = getNodeId(msg.sender, nodeId);\n\n    if (isNaaS) {\n      rFee = naasRequestingFeeInWei;\n      sFee = naasStrongFeeInWei;\n      activeEntities = activeEntities.add(1);\n    } else {\n      rFee = requestingFeeInWei;\n      sFee = strongFeeInWei;\n      entityNodeIsBYON[id] = true;\n    }\n\n    require(msg.value == rFee, \"invalid fee\");\n\n    entityNodePaidOnBlock[id] = block.number;\n    entityNodeTraunch[id] = currentTraunch;\n    entityNodeClaimedOnBlock[id] = block.number;\n    entityNodeCount[msg.sender] = entityNodeCount[msg.sender] + 1;\n\n    feeCollector.transfer(msg.value);\n    strongToken.transferFrom(msg.sender, address(this), sFee);\n    strongToken.transfer(feeCollector, sFee);\n\n    emit Paid(msg.sender, nodeId, entityNodeIsBYON[id], false, entityNodePaidOnBlock[id].add(recurringPaymentCycleInBlocks));\n  }\n\n  function setEntityActiveStatus(address entity, bool status) public {\n    require(msg.sender == admin || msg.sender == serviceAdmin || msg.sender == superAdmin, \"not admin\");\n    uint256 index = entityIndex[entity];\n    require(entities[index] == entity, \"invalid entity\");\n    require(entityActive[entity] != status, \"already set\");\n    entityActive[entity] = status;\n    if (status) {\n      activeEntities = activeEntities.add(1);\n      entityBlockLastClaimedOn[entity] = block.number;\n    } else {\n      activeEntities = activeEntities.sub(1);\n      entityBlockLastClaimedOn[entity] = 0;\n    }\n  }\n\n  function payFee(uint128 nodeId) public payable {\n    address sender = msg.sender == address(this) ? tx.origin : msg.sender;\n    bytes memory id = getNodeId(sender, nodeId);\n    uint256 blockLastPaidOn = entityNodePaidOnBlock[id];\n\n    if (hasLegacyNode(sender)) {\n      migrateLegacyNode(sender);\n    }\n\n    bool isExpired = block.number \u003e blockLastPaidOn.add(recurringPaymentCycleInBlocks).add(recurringPaymentCycleInBlocks);\n\n    require(doesNodeExist(sender, nodeId), \"doesnt exist\");\n    require(isExpired == false || msg.sender == address(this), \"too late\");\n\n    if (isExpired) {\n      return;\n    }\n\n    if (entityNodeIsBYON[id]) {\n      require(msg.value == recurringFeeInWei, \"invalid fee\");\n    } else {\n      require(msg.value == recurringNaaSFeeInWei, \"invalid fee\");\n    }\n\n    feeCollector.transfer(msg.value);\n    entityNodePaidOnBlock[id] = entityNodePaidOnBlock[id].add(recurringPaymentCycleInBlocks);\n\n    emit Paid(sender, nodeId, entityNodeIsBYON[id], true, entityNodePaidOnBlock[id]);\n  }\n\n  function getReward(address entity, uint128 nodeId) public view returns (uint256) {\n    return getRewardByBlock(entity, nodeId, block.number);\n  }\n\n  function getRewardByBlock(address entity, uint128 nodeId, uint256 blockNumber) public view returns (uint256) {\n    bytes memory id = getNodeId(entity, nodeId);\n\n    if (hasLegacyNode(entity)) {\n      return getRewardByBlockLegacy(entity, blockNumber);\n    }\n\n    uint256 blockLastClaimedOn = entityNodeClaimedOnBlock[id] != 0 ? entityNodeClaimedOnBlock[id] : entityNodePaidOnBlock[id];\n\n    if (blockNumber \u003e block.number) return 0;\n    if (blockLastClaimedOn == 0) return 0;\n    if (blockNumber \u003c blockLastClaimedOn) return 0;\n    if (activeEntities == 0) return 0;\n    if (entityNodeIsBYON[id] \u0026\u0026 !entityNodeIsActive[id]) return 0;\n\n    uint256 rewardNumerator = entityNodeIsBYON[id] ? rewardPerBlockNumerator : naasRewardPerBlockNumerator;\n    uint256 rewardDenominator = entityNodeIsBYON[id] ? rewardPerBlockDenominator : naasRewardPerBlockDenominator;\n    uint256 newRewardNumerator = entityNodeIsBYON[id] ? rewardPerBlockNumeratorNew : naasRewardPerBlockNumeratorNew;\n    uint256 newRewardDenominator = entityNodeIsBYON[id] ? rewardPerBlockDenominatorNew : naasRewardPerBlockDenominatorNew;\n\n    uint256 bonus = address(strongNFTBonus) != address(0)\n    ? strongNFTBonus.getBonus(entity, nodeId, blockLastClaimedOn, blockNumber)\n    : 0;\n\n    uint256[2] memory rewardBlocks = rewards.blocks(blockLastClaimedOn, rewardPerBlockNewEffectiveBlock, blockNumber);\n    uint256 rewardOld = rewardDenominator \u003e 0 ? rewardBlocks[0].mul(rewardNumerator).div(rewardDenominator) : 0;\n    uint256 rewardNew = newRewardDenominator \u003e 0 ? rewardBlocks[1].mul(newRewardNumerator).div(newRewardDenominator) : 0;\n\n    return rewardOld.add(rewardNew).add(bonus);\n  }\n\n  function getRewardByBlockLegacy(address entity, uint256 blockNumber) public view returns (uint256) {\n    if (blockNumber \u003e block.number) return 0;\n    if (entityBlockLastClaimedOn[entity] == 0) return 0;\n    if (blockNumber \u003c entityBlockLastClaimedOn[entity]) return 0;\n    if (activeEntities == 0) return 0;\n    uint256 blockResult = blockNumber.sub(entityBlockLastClaimedOn[entity]);\n    uint256 rewardNumerator;\n    uint256 rewardDenominator;\n    if (entityIsNaaS[entity]) {\n      rewardNumerator = naasRewardPerBlockNumerator;\n      rewardDenominator = naasRewardPerBlockDenominator;\n    } else {\n      rewardNumerator = rewardPerBlockNumerator;\n      rewardDenominator = rewardPerBlockDenominator;\n    }\n    uint256 rewardPerBlockResult = blockResult.mul(rewardNumerator).div(rewardDenominator);\n\n    return rewardPerBlockResult;\n  }\n\n  function claim(uint128 nodeId, uint256 blockNumber, bool toStrongPool) public payable {\n    address sender = msg.sender == address(this) || msg.sender == address(strongNFTBonus) ? tx.origin : msg.sender;\n    bytes memory id = getNodeId(sender, nodeId);\n\n    if (hasLegacyNode(sender)) {\n      migrateLegacyNode(sender);\n    }\n\n    uint256 blockLastClaimedOn = entityNodeClaimedOnBlock[id] != 0 ? entityNodeClaimedOnBlock[id] : entityNodePaidOnBlock[id];\n    uint256 blockLastPaidOn = entityNodePaidOnBlock[id];\n\n    require(blockLastClaimedOn != 0, \"never claimed\");\n    require(blockNumber \u003c= block.number, \"invalid block\");\n    require(blockNumber \u003e blockLastClaimedOn, \"too soon\");\n    require(!entityNodeIsBYON[id] || entityNodeIsActive[id], \"not active\");\n\n    if (\n      (!entityNodeIsBYON[id] \u0026\u0026 recurringNaaSFeeInWei != 0) || (entityNodeIsBYON[id] \u0026\u0026 recurringFeeInWei != 0)\n    ) {\n      require(blockNumber \u003c blockLastPaidOn.add(recurringPaymentCycleInBlocks), \"pay fee\");\n    }\n\n    uint256 reward = getRewardByBlock(sender, nodeId, blockNumber);\n    require(reward \u003e 0, \"no reward\");\n\n    uint256 fee = reward.mul(claimingFeeNumerator).div(claimingFeeDenominator);\n    require(msg.value \u003e= fee, \"invalid fee\");\n\n    feeCollector.transfer(msg.value);\n\n    if (toStrongPool) {\n      strongToken.approve(address(strongPool), reward);\n      strongPool.mineFor(sender, reward);\n    } else {\n      strongToken.transfer(sender, reward);\n    }\n\n    rewardBalance = rewardBalance.sub(reward);\n    entityNodeClaimedOnBlock[id] = blockNumber;\n    emit Claimed(sender, reward);\n  }\n\n  function getRewardAll(address entity, uint256 blockNumber) public view returns (uint256) {\n    uint256 rewardsAll = 0;\n\n    for (uint128 i = 1; i \u003c= entityNodeCount[entity]; i++) {\n      rewardsAll = rewardsAll.add(getRewardByBlock(entity, i, blockNumber \u003e 0 ? blockNumber : block.number));\n    }\n\n    return rewardsAll;\n  }\n\n  function doesNodeExist(address entity, uint128 nodeId) public view returns (bool) {\n    bytes memory id = getNodeId(entity, nodeId);\n    return entityNodePaidOnBlock[id] \u003e 0;\n  }\n\n  function getNodeId(address entity, uint128 nodeId) public view returns (bytes memory) {\n    uint128 id = nodeId != 0 ? nodeId : entityNodeCount[entity] + 1;\n    return abi.encodePacked(entity, id);\n  }\n\n  function getNodePaidOn(address entity, uint128 nodeId) public view returns (uint256) {\n    bytes memory id = getNodeId(entity, nodeId);\n    return entityNodePaidOnBlock[id];\n  }\n\n  function getNodeFee(address entity, uint128 nodeId) public view returns (uint256) {\n    bytes memory id = getNodeId(entity, nodeId);\n    return entityNodeIsBYON[id] ? recurringFeeInWei : recurringNaaSFeeInWei;\n  }\n\n  function isNodeActive(address entity, uint128 nodeId) public view returns (bool) {\n    bytes memory id = getNodeId(entity, nodeId);\n    return entityNodeIsActive[id] || !entityNodeIsBYON[id];\n  }\n\n  function isNodeBYON(address entity, uint128 nodeId) public view returns (bool) {\n    bytes memory id = getNodeId(entity, nodeId);\n    return entityNodeIsBYON[id];\n  }\n\n  function hasLegacyNode(address entity) public view returns (bool) {\n    return entityActive[entity] \u0026\u0026 entityNodeCount[entity] == 0;\n  }\n\n  function approveBYONNode(address entity, uint128 nodeId) public {\n    require(msg.sender == admin || msg.sender == serviceAdmin || msg.sender == superAdmin, \"not admin\");\n\n    bytes memory id = getNodeId(entity, nodeId);\n    entityNodeIsActive[id] = true;\n    entityNodeClaimedOnBlock[id] = block.number;\n    activeEntities = activeEntities.add(1);\n  }\n\n  function suspendBYONNode(address entity, uint128 nodeId) public {\n    require(msg.sender == admin || msg.sender == serviceAdmin || msg.sender == superAdmin, \"not admin\");\n\n    bytes memory id = getNodeId(entity, nodeId);\n    entityNodeIsActive[id] = false;\n    activeEntities = activeEntities.sub(1);\n  }\n\n  function setNodeIsActive(address entity, uint128 nodeId, bool isActive) public {\n    require(msg.sender == admin || msg.sender == serviceAdmin || msg.sender == superAdmin, \"not admin\");\n    bytes memory id = getNodeId(entity, nodeId);\n\n    if (isActive \u0026\u0026 !entityNodeIsActive[id]) {\n      activeEntities = activeEntities.add(1);\n      entityNodeClaimedOnBlock[id] = block.number;\n    }\n\n    if (!isActive \u0026\u0026 entityNodeIsActive[id]) {\n      activeEntities = activeEntities.sub(1);\n    }\n\n    entityNodeIsActive[id] = isActive;\n  }\n\n  function setNodeIsNaaS(address entity, uint128 nodeId, bool isNaaS) public {\n    require(msg.sender == admin || msg.sender == serviceAdmin || msg.sender == superAdmin, \"not admin\");\n    bytes memory id = getNodeId(entity, nodeId);\n\n    entityNodeIsBYON[id] = !isNaaS;\n  }\n\n  function migrateLegacyNode(address entity) private {\n    bytes memory id = getNodeId(entity, 1);\n    entityNodeClaimedOnBlock[id] = entityBlockLastClaimedOn[entity];\n    entityNodePaidOnBlock[id] = paidOnBlock[entity];\n    entityNodeTraunch[id] = traunch[entity];\n    entityNodeIsBYON[id] = !entityIsNaaS[entity];\n    if (entityNodeIsBYON[id]) {\n      entityNodeIsActive[id] = true;\n    }\n    entityNodeCount[msg.sender] = 1;\n  }\n\n  function migrateNode(uint128 nodeId, address to) public {\n    if (hasLegacyNode(msg.sender)) {\n      migrateLegacyNode(msg.sender);\n    }\n\n    if (hasLegacyNode(to)) {\n      migrateLegacyNode(to);\n    }\n\n    require(doesNodeExist(msg.sender, nodeId), \"doesnt exist\");\n\n    uint128 toNodeId = entityNodeCount[to] + 1;\n    bytes memory fromId = getNodeId(msg.sender, nodeId);\n    bytes memory toId = getNodeId(to, toNodeId);\n\n    // move node to another address\n    entityNodeIsActive[toId] = entityNodeIsActive[fromId];\n    entityNodeIsBYON[toId] = entityNodeIsBYON[fromId];\n    entityNodePaidOnBlock[toId] = entityNodePaidOnBlock[fromId];\n    entityNodeClaimedOnBlock[toId] = entityNodeClaimedOnBlock[fromId];\n    entityNodeTraunch[toId] = entityNodeTraunch[fromId];\n    entityNodeCount[to] = entityNodeCount[to] + 1;\n\n    // deactivate node\n    entityNodeIsActive[fromId] = false;\n    entityNodePaidOnBlock[fromId] = 0;\n    entityNodeClaimedOnBlock[fromId] = 0;\n    entityNodeCount[msg.sender] = entityNodeCount[msg.sender] - 1;\n\n    emit Migrated(msg.sender, to, nodeId, toNodeId, entityNodeIsBYON[fromId]);\n  }\n\n  function claimAll(uint256 blockNumber, bool toStrongPool) public payable {\n    for (uint16 i = 1; i \u003c= entityNodeCount[msg.sender]; i++) {\n      uint256 reward = getRewardByBlock(msg.sender, i, blockNumber);\n      uint256 fee = reward.mul(claimingFeeNumerator).div(claimingFeeDenominator);\n      this.claim{value : fee}(i, blockNumber, toStrongPool);\n    }\n  }\n\n  function payAll() public payable {\n    for (uint16 i = 1; i \u003c= entityNodeCount[msg.sender]; i++) {\n      bytes memory id = getNodeId(msg.sender, i);\n      uint256 fee = entityNodeIsBYON[id] ? recurringFeeInWei : recurringNaaSFeeInWei;\n      this.payFee{value : fee}(i);\n    }\n  }\n\n  function addNFTBonusContract(address _contract) public {\n    require(msg.sender == admin || msg.sender == serviceAdmin || msg.sender == superAdmin, \"not admin\");\n\n    strongNFTBonus = StrongNFTBonusInterface(_contract);\n  }\n}\n"},"ServiceV11.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity 0.6.12;\n\nimport \"./IERC20.sol\";\nimport \"./SafeMath.sol\";\nimport \"./StrongPoolInterface.sol\";\nimport \"./IERC1155Preset.sol\";\nimport \"./StrongNFTBonusInterface.sol\";\nimport \"./rewards.sol\";\n\ncontract ServiceV11 {\n  event Requested(address indexed miner);\n  event Claimed(address indexed miner, uint256 reward);\n\n  using SafeMath for uint256;\n  bool public initDone;\n  address public admin;\n  address public pendingAdmin;\n  address public superAdmin;\n  address public pendingSuperAdmin;\n  address public serviceAdmin;\n  address public parameterAdmin;\n  address payable public feeCollector;\n\n  IERC20 public strongToken;\n  StrongPoolInterface public strongPool;\n\n  uint256 public rewardPerBlockNumerator;\n  uint256 public rewardPerBlockDenominator;\n\n  uint256 public naasRewardPerBlockNumerator;\n  uint256 public naasRewardPerBlockDenominator;\n\n  uint256 public claimingFeeNumerator;\n  uint256 public claimingFeeDenominator;\n\n  uint256 public requestingFeeInWei;\n\n  uint256 public strongFeeInWei;\n\n  uint256 public recurringFeeInWei;\n  uint256 public recurringNaaSFeeInWei;\n  uint256 public recurringPaymentCycleInBlocks;\n\n  uint256 public rewardBalance;\n\n  mapping(address =\u003e uint256) public entityBlockLastClaimedOn;\n\n  address[] public entities;\n  mapping(address =\u003e uint256) public entityIndex;\n  mapping(address =\u003e bool) public entityActive;\n  mapping(address =\u003e bool) public requestPending;\n  mapping(address =\u003e bool) public entityIsNaaS;\n  mapping(address =\u003e uint256) public paidOnBlock;\n  uint256 public activeEntities;\n\n  string public desciption;\n\n  uint256 public claimingFeeInWei;\n\n  uint256 public naasRequestingFeeInWei;\n\n  uint256 public naasStrongFeeInWei;\n\n  bool public removedTokens;\n\n  mapping(address =\u003e uint256) public traunch;\n\n  uint256 public currentTraunch;\n\n  mapping(bytes =\u003e bool) public entityNodeIsActive;\n  mapping(bytes =\u003e bool) public entityNodeIsBYON;\n  mapping(bytes =\u003e uint256) public entityNodeTraunch;\n  mapping(bytes =\u003e uint256) public entityNodePaidOnBlock;\n  mapping(bytes =\u003e uint256) public entityNodeClaimedOnBlock;\n  mapping(address =\u003e uint128) public entityNodeCount;\n\n  event Paid(address indexed entity, uint128 nodeId, bool isBYON, bool isRenewal, uint256 upToBlockNumber);\n  event Migrated(address indexed from, address indexed to, uint128 fromNodeId, uint128 toNodeId, bool isBYON);\n\n  uint256 public rewardPerBlockNumeratorNew;\n  uint256 public rewardPerBlockDenominatorNew;\n  uint256 public naasRewardPerBlockNumeratorNew;\n  uint256 public naasRewardPerBlockDenominatorNew;\n  uint256 public rewardPerBlockNewEffectiveBlock;\n\n  StrongNFTBonusInterface public strongNFTBonus;\n\n  uint256 public gracePeriodInBlocks;\n\n  function init(\n    address strongTokenAddress,\n    address strongPoolAddress,\n    address adminAddress,\n    address superAdminAddress,\n    uint256 rewardPerBlockNumeratorValue,\n    uint256 rewardPerBlockDenominatorValue,\n    uint256 naasRewardPerBlockNumeratorValue,\n    uint256 naasRewardPerBlockDenominatorValue,\n    uint256 requestingFeeInWeiValue,\n    uint256 strongFeeInWeiValue,\n    uint256 recurringFeeInWeiValue,\n    uint256 recurringNaaSFeeInWeiValue,\n    uint256 recurringPaymentCycleInBlocksValue,\n    uint256 claimingFeeNumeratorValue,\n    uint256 claimingFeeDenominatorValue,\n    string memory desc\n  ) public {\n    require(!initDone, \"init done\");\n    strongToken = IERC20(strongTokenAddress);\n    strongPool = StrongPoolInterface(strongPoolAddress);\n    admin = adminAddress;\n    superAdmin = superAdminAddress;\n    rewardPerBlockNumerator = rewardPerBlockNumeratorValue;\n    rewardPerBlockDenominator = rewardPerBlockDenominatorValue;\n    naasRewardPerBlockNumerator = naasRewardPerBlockNumeratorValue;\n    naasRewardPerBlockDenominator = naasRewardPerBlockDenominatorValue;\n    requestingFeeInWei = requestingFeeInWeiValue;\n    strongFeeInWei = strongFeeInWeiValue;\n    recurringFeeInWei = recurringFeeInWeiValue;\n    recurringNaaSFeeInWei = recurringNaaSFeeInWeiValue;\n    claimingFeeNumerator = claimingFeeNumeratorValue;\n    claimingFeeDenominator = claimingFeeDenominatorValue;\n    recurringPaymentCycleInBlocks = recurringPaymentCycleInBlocksValue;\n    desciption = desc;\n    initDone = true;\n  }\n\n  // ADMIN\n  // *************************************************************************************\n\n  function updateServiceAdmin(address newServiceAdmin) public {\n    require(msg.sender == superAdmin);\n    serviceAdmin = newServiceAdmin;\n  }\n\n  function updateParameterAdmin(address newParameterAdmin) public {\n    require(newParameterAdmin != address(0), \"zero\");\n    require(msg.sender == superAdmin);\n    parameterAdmin = newParameterAdmin;\n  }\n\n  function updateFeeCollector(address payable newFeeCollector) public {\n    require(newFeeCollector != address(0), \"zero\");\n    require(msg.sender == superAdmin);\n    feeCollector = newFeeCollector;\n  }\n\n  function setPendingAdmin(address newPendingAdmin) public {\n    require(msg.sender == admin, \"not admin\");\n    pendingAdmin = newPendingAdmin;\n  }\n\n  function acceptAdmin() public {\n    require(msg.sender == pendingAdmin \u0026\u0026 msg.sender != address(0), \"not pendingAdmin\");\n    admin = pendingAdmin;\n    pendingAdmin = address(0);\n  }\n\n  function setPendingSuperAdmin(address newPendingSuperAdmin) public {\n    require(msg.sender == superAdmin, \"not superAdmin\");\n    pendingSuperAdmin = newPendingSuperAdmin;\n  }\n\n  function acceptSuperAdmin() public {\n    require(msg.sender == pendingSuperAdmin \u0026\u0026 msg.sender != address(0), \"not pendingSuperAdmin\");\n    superAdmin = pendingSuperAdmin;\n    pendingSuperAdmin = address(0);\n  }\n\n  // ENTITIES\n  // *************************************************************************************\n\n  function isEntityActive(address entity) public view returns (bool) {\n    return entityActive[entity] || (doesNodeExist(entity, 1) \u0026\u0026 !hasNodeExpired(entity, 1));\n  }\n\n  // REWARD\n  // *************************************************************************************\n\n  function updateRewardPerBlock(uint256 numerator, uint256 denominator) public {\n    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, \"not admin\");\n    require(denominator != 0, \"invalid value\");\n    rewardPerBlockNumerator = numerator;\n    rewardPerBlockDenominator = denominator;\n  }\n\n  function updateNaaSRewardPerBlock(uint256 numerator, uint256 denominator) public {\n    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, \"not admin\");\n    require(denominator != 0, \"invalid value\");\n    naasRewardPerBlockNumerator = numerator;\n    naasRewardPerBlockDenominator = denominator;\n  }\n\n  function updateRewardPerBlockNew(\n    uint256 numerator,\n    uint256 denominator,\n    uint256 numeratorNass,\n    uint256 denominatorNass,\n    uint256 effectiveBlock\n  ) public {\n    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, \"not admin\");\n\n    rewardPerBlockNumeratorNew = numerator;\n    rewardPerBlockDenominatorNew = denominator;\n    naasRewardPerBlockNumeratorNew = numeratorNass;\n    naasRewardPerBlockDenominatorNew = denominatorNass;\n    rewardPerBlockNewEffectiveBlock = effectiveBlock != 0 ? effectiveBlock : block.number;\n  }\n\n  function deposit(uint256 amount) public {\n    require(msg.sender == superAdmin, \"not admin\");\n    require(amount \u003e 0, \"zero\");\n    strongToken.transferFrom(msg.sender, address(this), amount);\n    rewardBalance = rewardBalance.add(amount);\n  }\n\n  function withdraw(address destination, uint256 amount) public {\n    require(msg.sender == superAdmin, \"not admin\");\n    require(amount \u003e 0, \"zero\");\n    require(rewardBalance \u003e= amount, \"not enough\");\n    strongToken.transfer(destination, amount);\n    rewardBalance = rewardBalance.sub(amount);\n  }\n\n  // FEES\n  // *************************************************************************************\n\n  function updateRequestingFee(uint256 feeInWei) public {\n    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, \"not admin\");\n    requestingFeeInWei = feeInWei;\n  }\n\n  function updateStrongFee(uint256 feeInWei) public {\n    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, \"not admin\");\n    strongFeeInWei = feeInWei;\n  }\n\n  function updateNaasRequestingFee(uint256 feeInWei) public {\n    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, \"not admin\");\n    naasRequestingFeeInWei = feeInWei;\n  }\n\n  function updateNaasStrongFee(uint256 feeInWei) public {\n    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, \"not admin\");\n    naasStrongFeeInWei = feeInWei;\n  }\n\n  function updateClaimingFee(uint256 numerator, uint256 denominator) public {\n    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, \"not admin\");\n    require(denominator != 0, \"invalid value\");\n    claimingFeeNumerator = numerator;\n    claimingFeeDenominator = denominator;\n  }\n\n  function updateRecurringFee(uint256 feeInWei) public {\n    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, \"not admin\");\n    recurringFeeInWei = feeInWei;\n  }\n\n  function updateRecurringNaaSFee(uint256 feeInWei) public {\n    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, \"not admin\");\n    recurringNaaSFeeInWei = feeInWei;\n  }\n\n  function updateRecurringPaymentCycleInBlocks(uint256 blocks) public {\n    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, \"not admin\");\n    require(blocks \u003e 0, \"zero\");\n    recurringPaymentCycleInBlocks = blocks;\n  }\n\n  function updateGracePeriodInBlocks(uint256 blocks) public {\n    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, \"not admin\");\n    require(blocks \u003e 0, \"zero\");\n    gracePeriodInBlocks = blocks;\n  }\n\n  // CORE\n  // *************************************************************************************\n\n  function requestAccess(bool isNaaS) public payable {\n    uint256 rFee;\n    uint256 sFee;\n\n    if (hasLegacyNode(msg.sender)) {\n      migrateLegacyNode(msg.sender);\n    }\n\n    uint128 nodeId = entityNodeCount[msg.sender] + 1;\n    bytes memory id = getNodeId(msg.sender, nodeId);\n\n    if (isNaaS) {\n      rFee = naasRequestingFeeInWei;\n      sFee = naasStrongFeeInWei;\n      activeEntities = activeEntities.add(1);\n    } else {\n      rFee = requestingFeeInWei;\n      sFee = strongFeeInWei;\n      entityNodeIsBYON[id] = true;\n    }\n\n    require(msg.value == rFee, \"invalid fee\");\n\n    entityNodePaidOnBlock[id] = block.number;\n    entityNodeClaimedOnBlock[id] = block.number;\n    entityNodeCount[msg.sender] = entityNodeCount[msg.sender] + 1;\n\n    feeCollector.transfer(msg.value);\n    strongToken.transferFrom(msg.sender, address(this), sFee);\n    strongToken.transfer(feeCollector, sFee);\n\n    emit Paid(msg.sender, nodeId, entityNodeIsBYON[id], false, entityNodePaidOnBlock[id].add(recurringPaymentCycleInBlocks));\n  }\n\n  function setEntityActiveStatus(address entity, bool status) public {\n    require(msg.sender == admin || msg.sender == serviceAdmin || msg.sender == superAdmin, \"not admin\");\n    uint256 index = entityIndex[entity];\n    require(entities[index] == entity, \"invalid entity\");\n    require(entityActive[entity] != status, \"already set\");\n    entityActive[entity] = status;\n    if (status) {\n      activeEntities = activeEntities.add(1);\n      entityBlockLastClaimedOn[entity] = block.number;\n    } else {\n      activeEntities = activeEntities.sub(1);\n      entityBlockLastClaimedOn[entity] = 0;\n    }\n  }\n\n  function payFee(uint128 nodeId) public payable {\n    address sender = msg.sender == address(this) ? tx.origin : msg.sender;\n    bytes memory id = getNodeId(sender, nodeId);\n\n    if (hasLegacyNode(sender)) {\n      migrateLegacyNode(sender);\n    }\n\n    bool isExpired = hasNodeExpired(msg.sender, nodeId);\n\n    require(doesNodeExist(sender, nodeId), \"doesnt exist\");\n    require(isExpired == false || msg.sender == address(this), \"too late\");\n\n    if (isExpired) {\n      return;\n    }\n\n    if (entityNodeIsBYON[id]) {\n      require(msg.value == recurringFeeInWei, \"invalid fee\");\n    } else {\n      require(msg.value == recurringNaaSFeeInWei, \"invalid fee\");\n    }\n\n    feeCollector.transfer(msg.value);\n    entityNodePaidOnBlock[id] = entityNodePaidOnBlock[id].add(recurringPaymentCycleInBlocks);\n\n    emit Paid(sender, nodeId, entityNodeIsBYON[id], true, entityNodePaidOnBlock[id]);\n  }\n\n  function getReward(address entity, uint128 nodeId) public view returns (uint256) {\n    return getRewardByBlock(entity, nodeId, block.number);\n  }\n\n  function getRewardByBlock(address entity, uint128 nodeId, uint256 blockNumber) public view returns (uint256) {\n    bytes memory id = getNodeId(entity, nodeId);\n\n    if (hasLegacyNode(entity)) {\n      return getRewardByBlockLegacy(entity, blockNumber);\n    }\n\n    uint256 blockLastClaimedOn = entityNodeClaimedOnBlock[id] != 0 ? entityNodeClaimedOnBlock[id] : entityNodePaidOnBlock[id];\n\n    if (blockNumber \u003e block.number) return 0;\n    if (blockLastClaimedOn == 0) return 0;\n    if (blockNumber \u003c blockLastClaimedOn) return 0;\n    if (activeEntities == 0) return 0;\n    if (entityNodeIsBYON[id] \u0026\u0026 !entityNodeIsActive[id]) return 0;\n\n    uint256 rewardNumerator = entityNodeIsBYON[id] ? rewardPerBlockNumerator : naasRewardPerBlockNumerator;\n    uint256 rewardDenominator = entityNodeIsBYON[id] ? rewardPerBlockDenominator : naasRewardPerBlockDenominator;\n    uint256 newRewardNumerator = entityNodeIsBYON[id] ? rewardPerBlockNumeratorNew : naasRewardPerBlockNumeratorNew;\n    uint256 newRewardDenominator = entityNodeIsBYON[id] ? rewardPerBlockDenominatorNew : naasRewardPerBlockDenominatorNew;\n\n    uint256 bonus = address(strongNFTBonus) != address(0)\n    ? strongNFTBonus.getBonus(entity, nodeId, blockLastClaimedOn, blockNumber)\n    : 0;\n\n    uint256[2] memory rewardBlocks = rewards.blocks(blockLastClaimedOn, rewardPerBlockNewEffectiveBlock, blockNumber);\n    uint256 rewardOld = rewardDenominator \u003e 0 ? rewardBlocks[0].mul(rewardNumerator).div(rewardDenominator) : 0;\n    uint256 rewardNew = newRewardDenominator \u003e 0 ? rewardBlocks[1].mul(newRewardNumerator).div(newRewardDenominator) : 0;\n\n    return rewardOld.add(rewardNew).add(bonus);\n  }\n\n  function getRewardByBlockLegacy(address entity, uint256 blockNumber) public view returns (uint256) {\n    if (blockNumber \u003e block.number) return 0;\n    if (entityBlockLastClaimedOn[entity] == 0) return 0;\n    if (blockNumber \u003c entityBlockLastClaimedOn[entity]) return 0;\n    if (activeEntities == 0) return 0;\n    uint256 blockResult = blockNumber.sub(entityBlockLastClaimedOn[entity]);\n    uint256 rewardNumerator;\n    uint256 rewardDenominator;\n    if (entityIsNaaS[entity]) {\n      rewardNumerator = naasRewardPerBlockNumerator;\n      rewardDenominator = naasRewardPerBlockDenominator;\n    } else {\n      rewardNumerator = rewardPerBlockNumerator;\n      rewardDenominator = rewardPerBlockDenominator;\n    }\n    uint256 rewardPerBlockResult = blockResult.mul(rewardNumerator).div(rewardDenominator);\n\n    return rewardPerBlockResult;\n  }\n\n  function claim(uint128 nodeId, uint256 blockNumber, bool toStrongPool) public payable {\n    address sender = msg.sender == address(this) || msg.sender == address(strongNFTBonus) ? tx.origin : msg.sender;\n    bytes memory id = getNodeId(sender, nodeId);\n\n    if (hasLegacyNode(sender)) {\n      migrateLegacyNode(sender);\n    }\n\n    uint256 blockLastClaimedOn = entityNodeClaimedOnBlock[id] != 0 ? entityNodeClaimedOnBlock[id] : entityNodePaidOnBlock[id];\n    uint256 blockLastPaidOn = entityNodePaidOnBlock[id];\n\n    require(blockLastClaimedOn != 0, \"never claimed\");\n    require(blockNumber \u003c= block.number, \"invalid block\");\n    require(blockNumber \u003e blockLastClaimedOn, \"too soon\");\n    require(!entityNodeIsBYON[id] || entityNodeIsActive[id], \"not active\");\n\n    if (\n      (!entityNodeIsBYON[id] \u0026\u0026 recurringNaaSFeeInWei != 0) || (entityNodeIsBYON[id] \u0026\u0026 recurringFeeInWei != 0)\n    ) {\n      require(blockNumber \u003c blockLastPaidOn.add(recurringPaymentCycleInBlocks), \"pay fee\");\n    }\n\n    uint256 reward = getRewardByBlock(sender, nodeId, blockNumber);\n    require(reward \u003e 0, \"no reward\");\n\n    uint256 fee = reward.mul(claimingFeeNumerator).div(claimingFeeDenominator);\n    require(msg.value \u003e= fee, \"invalid fee\");\n\n    feeCollector.transfer(msg.value);\n\n    if (toStrongPool) {\n      strongToken.approve(address(strongPool), reward);\n      strongPool.mineFor(sender, reward);\n    } else {\n      strongToken.transfer(sender, reward);\n    }\n\n    rewardBalance = rewardBalance.sub(reward);\n    entityNodeClaimedOnBlock[id] = blockNumber;\n    emit Claimed(sender, reward);\n  }\n\n  function getRewardAll(address entity, uint256 blockNumber) public view returns (uint256) {\n    uint256 rewardsAll = 0;\n\n    for (uint128 i = 1; i \u003c= entityNodeCount[entity]; i++) {\n      rewardsAll = rewardsAll.add(getRewardByBlock(entity, i, blockNumber \u003e 0 ? blockNumber : block.number));\n    }\n\n    return rewardsAll;\n  }\n\n  function doesNodeExist(address entity, uint128 nodeId) public view returns (bool) {\n    bytes memory id = getNodeId(entity, nodeId);\n    return entityNodePaidOnBlock[id] \u003e 0;\n  }\n\n  function hasNodeExpired(address entity, uint128 nodeId) public view returns (bool) {\n    bytes memory id = getNodeId(entity, nodeId);\n    uint256 blockLastPaidOn = entityNodePaidOnBlock[id];\n    return block.number \u003e blockLastPaidOn.add(recurringPaymentCycleInBlocks).add(gracePeriodInBlocks);\n  }\n\n  function getNodeId(address entity, uint128 nodeId) public view returns (bytes memory) {\n    uint128 id = nodeId != 0 ? nodeId : entityNodeCount[entity] + 1;\n    return abi.encodePacked(entity, id);\n  }\n\n  function getNodePaidOn(address entity, uint128 nodeId) public view returns (uint256) {\n    bytes memory id = getNodeId(entity, nodeId);\n    return entityNodePaidOnBlock[id];\n  }\n\n  function getNodeFee(address entity, uint128 nodeId) public view returns (uint256) {\n    bytes memory id = getNodeId(entity, nodeId);\n    return entityNodeIsBYON[id] ? recurringFeeInWei : recurringNaaSFeeInWei;\n  }\n\n  function isNodeActive(address entity, uint128 nodeId) public view returns (bool) {\n    bytes memory id = getNodeId(entity, nodeId);\n    return entityNodeIsActive[id] || !entityNodeIsBYON[id];\n  }\n\n  function isNodeBYON(address entity, uint128 nodeId) public view returns (bool) {\n    bytes memory id = getNodeId(entity, nodeId);\n    return entityNodeIsBYON[id];\n  }\n\n  function hasLegacyNode(address entity) public view returns (bool) {\n    return entityActive[entity] \u0026\u0026 entityNodeCount[entity] == 0;\n  }\n\n  function approveBYONNode(address entity, uint128 nodeId) public {\n    require(msg.sender == admin || msg.sender == serviceAdmin || msg.sender == superAdmin, \"not admin\");\n\n    bytes memory id = getNodeId(entity, nodeId);\n    entityNodeIsActive[id] = true;\n    entityNodeClaimedOnBlock[id] = block.number;\n    activeEntities = activeEntities.add(1);\n  }\n\n  function suspendBYONNode(address entity, uint128 nodeId) public {\n    require(msg.sender == admin || msg.sender == serviceAdmin || msg.sender == superAdmin, \"not admin\");\n\n    bytes memory id = getNodeId(entity, nodeId);\n    entityNodeIsActive[id] = false;\n    activeEntities = activeEntities.sub(1);\n  }\n\n  function setNodeIsActive(address entity, uint128 nodeId, bool isActive) public {\n    require(msg.sender == admin || msg.sender == serviceAdmin || msg.sender == superAdmin, \"not admin\");\n    bytes memory id = getNodeId(entity, nodeId);\n\n    if (isActive \u0026\u0026 !entityNodeIsActive[id]) {\n      activeEntities = activeEntities.add(1);\n      entityNodeClaimedOnBlock[id] = block.number;\n    }\n\n    if (!isActive \u0026\u0026 entityNodeIsActive[id]) {\n      activeEntities = activeEntities.sub(1);\n    }\n\n    entityNodeIsActive[id] = isActive;\n  }\n\n  function setNodeIsNaaS(address entity, uint128 nodeId, bool isNaaS) public {\n    require(msg.sender == admin || msg.sender == serviceAdmin || msg.sender == superAdmin, \"not admin\");\n    bytes memory id = getNodeId(entity, nodeId);\n\n    entityNodeIsBYON[id] = !isNaaS;\n  }\n\n  function migrateLegacyNode(address entity) private {\n    bytes memory id = getNodeId(entity, 1);\n    entityNodeClaimedOnBlock[id] = entityBlockLastClaimedOn[entity];\n    entityNodePaidOnBlock[id] = paidOnBlock[entity];\n    entityNodeIsBYON[id] = !entityIsNaaS[entity];\n    if (entityNodeIsBYON[id]) {\n      entityNodeIsActive[id] = true;\n    }\n    entityNodeCount[msg.sender] = 1;\n  }\n\n  function migrateNode(uint128 nodeId, address to) public {\n    if (hasLegacyNode(msg.sender)) {\n      migrateLegacyNode(msg.sender);\n    }\n\n    if (hasLegacyNode(to)) {\n      migrateLegacyNode(to);\n    }\n\n    require(doesNodeExist(msg.sender, nodeId), \"doesnt exist\");\n\n    uint128 toNodeId = entityNodeCount[to] + 1;\n    bytes memory fromId = getNodeId(msg.sender, nodeId);\n    bytes memory toId = getNodeId(to, toNodeId);\n\n    // move node to another address\n    entityNodeIsActive[toId] = entityNodeIsActive[fromId];\n    entityNodeIsBYON[toId] = entityNodeIsBYON[fromId];\n    entityNodePaidOnBlock[toId] = entityNodePaidOnBlock[fromId];\n    entityNodeClaimedOnBlock[toId] = entityNodeClaimedOnBlock[fromId];\n    entityNodeCount[to] = entityNodeCount[to] + 1;\n\n    // deactivate node\n    entityNodeIsActive[fromId] = false;\n    entityNodePaidOnBlock[fromId] = 0;\n    entityNodeClaimedOnBlock[fromId] = 0;\n    entityNodeCount[msg.sender] = entityNodeCount[msg.sender] - 1;\n\n    emit Migrated(msg.sender, to, nodeId, toNodeId, entityNodeIsBYON[fromId]);\n  }\n\n  function claimAll(uint256 blockNumber, bool toStrongPool) public payable {\n    for (uint16 i = 1; i \u003c= entityNodeCount[msg.sender]; i++) {\n      uint256 reward = getRewardByBlock(msg.sender, i, blockNumber);\n      uint256 fee = reward.mul(claimingFeeNumerator).div(claimingFeeDenominator);\n      this.claim{value : fee}(i, blockNumber, toStrongPool);\n    }\n  }\n\n  function payAll() public payable {\n    for (uint16 i = 1; i \u003c= entityNodeCount[msg.sender]; i++) {\n      bytes memory id = getNodeId(msg.sender, i);\n      uint256 fee = entityNodeIsBYON[id] ? recurringFeeInWei : recurringNaaSFeeInWei;\n      this.payFee{value : fee}(i);\n    }\n  }\n\n  function addNFTBonusContract(address _contract) public {\n    require(msg.sender == admin || msg.sender == serviceAdmin || msg.sender == superAdmin, \"not admin\");\n\n    strongNFTBonus = StrongNFTBonusInterface(_contract);\n  }\n}\n"},"ServiceV9.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity 0.6.12;\n\nimport \"./IERC20.sol\";\nimport \"./SafeMath.sol\";\nimport \"./StrongPoolInterface.sol\";\n\ncontract ServiceV9 {\n  event Requested(address indexed miner);\n  event Claimed(address indexed miner, uint256 reward);\n\n  using SafeMath for uint256;\n  bool public initDone;\n  address public admin;\n  address public pendingAdmin;\n  address public superAdmin;\n  address public pendingSuperAdmin;\n  address public serviceAdmin;\n  address public parameterAdmin;\n  address payable public feeCollector;\n\n  IERC20 public strongToken;\n  StrongPoolInterface public strongPool;\n\n  uint256 public rewardPerBlockNumerator;\n  uint256 public rewardPerBlockDenominator;\n\n  uint256 public naasRewardPerBlockNumerator;\n  uint256 public naasRewardPerBlockDenominator;\n\n  uint256 public claimingFeeNumerator;\n  uint256 public claimingFeeDenominator;\n\n  uint256 public requestingFeeInWei;\n\n  uint256 public strongFeeInWei;\n\n  uint256 public recurringFeeInWei;\n  uint256 public recurringNaaSFeeInWei;\n  uint256 public recurringPaymentCycleInBlocks;\n\n  uint256 public rewardBalance;\n\n  mapping(address =\u003e uint256) public entityBlockLastClaimedOn;\n\n  address[] public entities;\n  mapping(address =\u003e uint256) public entityIndex;\n  mapping(address =\u003e bool) public entityActive;\n  mapping(address =\u003e bool) public requestPending;\n  mapping(address =\u003e bool) public entityIsNaaS;\n  mapping(address =\u003e uint256) public paidOnBlock;\n  uint256 public activeEntities;\n\n  string public desciption;\n\n  uint256 public claimingFeeInWei;\n\n  uint256 public naasRequestingFeeInWei;\n\n  uint256 public naasStrongFeeInWei;\n\n  bool public removedTokens;\n\n  mapping(address =\u003e uint256) public traunch;\n\n  uint256 public currentTraunch;\n\n  mapping(bytes =\u003e bool) public entityNodeIsActive;\n  mapping(bytes =\u003e bool) public entityNodeIsBYON;\n  mapping(bytes =\u003e uint256) public entityNodeTraunch;\n  mapping(bytes =\u003e uint256) public entityNodePaidOnBlock;\n  mapping(bytes =\u003e uint256) public entityNodeClaimedOnBlock;\n  mapping(address =\u003e uint128) public entityNodeCount;\n\n  event Paid(address indexed entity, uint128 nodeId, bool isBYON, bool isRenewal, uint256 upToBlockNumber);\n  event Migrated(address indexed from, address indexed to, uint128 fromNodeId, uint128 toNodeId, bool isBYON);\n\n  function init(\n    address strongTokenAddress,\n    address strongPoolAddress,\n    address adminAddress,\n    address superAdminAddress,\n    uint256 rewardPerBlockNumeratorValue,\n    uint256 rewardPerBlockDenominatorValue,\n    uint256 naasRewardPerBlockNumeratorValue,\n    uint256 naasRewardPerBlockDenominatorValue,\n    uint256 requestingFeeInWeiValue,\n    uint256 strongFeeInWeiValue,\n    uint256 recurringFeeInWeiValue,\n    uint256 recurringNaaSFeeInWeiValue,\n    uint256 recurringPaymentCycleInBlocksValue,\n    uint256 claimingFeeNumeratorValue,\n    uint256 claimingFeeDenominatorValue,\n    string memory desc\n  ) public {\n    require(!initDone, \u0027init done\u0027);\n    strongToken = IERC20(strongTokenAddress);\n    strongPool = StrongPoolInterface(strongPoolAddress);\n    admin = adminAddress;\n    superAdmin = superAdminAddress;\n    rewardPerBlockNumerator = rewardPerBlockNumeratorValue;\n    rewardPerBlockDenominator = rewardPerBlockDenominatorValue;\n    naasRewardPerBlockNumerator = naasRewardPerBlockNumeratorValue;\n    naasRewardPerBlockDenominator = naasRewardPerBlockDenominatorValue;\n    requestingFeeInWei = requestingFeeInWeiValue;\n    strongFeeInWei = strongFeeInWeiValue;\n    recurringFeeInWei = recurringFeeInWeiValue;\n    recurringNaaSFeeInWei = recurringNaaSFeeInWeiValue;\n    claimingFeeNumerator = claimingFeeNumeratorValue;\n    claimingFeeDenominator = claimingFeeDenominatorValue;\n    recurringPaymentCycleInBlocks = recurringPaymentCycleInBlocksValue;\n    desciption = desc;\n    initDone = true;\n  }\n\n  // ADMIN\n  // *************************************************************************************\n\n  function updateServiceAdmin(address newServiceAdmin) public {\n    require(msg.sender == superAdmin);\n    serviceAdmin = newServiceAdmin;\n  }\n\n  function updateParameterAdmin(address newParameterAdmin) public {\n    require(newParameterAdmin != address(0), \u0027zero\u0027);\n    require(msg.sender == superAdmin);\n    parameterAdmin = newParameterAdmin;\n  }\n\n  function updateFeeCollector(address payable newFeeCollector) public {\n    require(newFeeCollector != address(0), \u0027zero\u0027);\n    require(msg.sender == superAdmin);\n    feeCollector = newFeeCollector;\n  }\n\n  function setPendingAdmin(address newPendingAdmin) public {\n    require(msg.sender == admin, \u0027not admin\u0027);\n    pendingAdmin = newPendingAdmin;\n  }\n\n  function acceptAdmin() public {\n    require(msg.sender == pendingAdmin \u0026\u0026 msg.sender != address(0), \u0027not pendingAdmin\u0027);\n    admin = pendingAdmin;\n    pendingAdmin = address(0);\n  }\n\n  function setPendingSuperAdmin(address newPendingSuperAdmin) public {\n    require(msg.sender == superAdmin, \u0027not superAdmin\u0027);\n    pendingSuperAdmin = newPendingSuperAdmin;\n  }\n\n  function acceptSuperAdmin() public {\n    require(msg.sender == pendingSuperAdmin \u0026\u0026 msg.sender != address(0), \u0027not pendingSuperAdmin\u0027);\n    superAdmin = pendingSuperAdmin;\n    pendingSuperAdmin = address(0);\n  }\n\n  // ENTITIES\n  // *************************************************************************************\n\n  function getEntities() public view returns (address[] memory) {\n    return entities;\n  }\n\n  function isEntityActive(address entity) public view returns (bool) {\n    return entityActive[entity];\n  }\n\n  // TRAUNCH\n  // *************************************************************************************\n\n  function updateCurrentTraunch(uint256 value) public {\n    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, \u0027not an admin\u0027);\n    currentTraunch = value;\n  }\n\n  function getTraunch(address entity) public view returns (uint256) {\n    return traunch[entity];\n  }\n\n  // REWARD\n  // *************************************************************************************\n\n  function updateRewardPerBlock(uint256 numerator, uint256 denominator) public {\n    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, \u0027not an admin\u0027);\n    require(denominator != 0, \u0027invalid value\u0027);\n    rewardPerBlockNumerator = numerator;\n    rewardPerBlockDenominator = denominator;\n  }\n\n  function updateNaaSRewardPerBlock(uint256 numerator, uint256 denominator) public {\n    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, \u0027not an admin\u0027);\n    require(denominator != 0, \u0027invalid value\u0027);\n    naasRewardPerBlockNumerator = numerator;\n    naasRewardPerBlockDenominator = denominator;\n  }\n\n  function deposit(uint256 amount) public {\n    require(msg.sender == superAdmin, \u0027not an admin\u0027);\n    require(amount \u003e 0, \u0027zero\u0027);\n    strongToken.transferFrom(msg.sender, address(this), amount);\n    rewardBalance = rewardBalance.add(amount);\n  }\n\n  function withdraw(address destination, uint256 amount) public {\n    require(msg.sender == superAdmin, \u0027not an admin\u0027);\n    require(amount \u003e 0, \u0027zero\u0027);\n    require(rewardBalance \u003e= amount, \u0027not enough\u0027);\n    strongToken.transfer(destination, amount);\n    rewardBalance = rewardBalance.sub(amount);\n  }\n\n  function removeTokens() public {\n    require(!removedTokens, \u0027already removed\u0027);\n    require(msg.sender == superAdmin, \u0027not an admin\u0027);\n    // removing 2500 STRONG tokens sent in this tx: 0xe27640beda32a5e49aad3b6692790b9d380ed25da0cf8dca7fd5f3258efa600a\n    strongToken.transfer(superAdmin, 2500000000000000000000);\n    removedTokens = true;\n  }\n\n  // FEES\n  // *************************************************************************************\n\n  function updateRequestingFee(uint256 feeInWei) public {\n    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, \u0027not an admin\u0027);\n    requestingFeeInWei = feeInWei;\n  }\n\n  function updateStrongFee(uint256 feeInWei) public {\n    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, \u0027not an admin\u0027);\n    strongFeeInWei = feeInWei;\n  }\n\n  function updateNaasRequestingFee(uint256 feeInWei) public {\n    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, \u0027not an admin\u0027);\n    naasRequestingFeeInWei = feeInWei;\n  }\n\n  function updateNaasStrongFee(uint256 feeInWei) public {\n    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, \u0027not an admin\u0027);\n    naasStrongFeeInWei = feeInWei;\n  }\n\n  function updateClaimingFee(uint256 numerator, uint256 denominator) public {\n    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, \u0027not an admin\u0027);\n    require(denominator != 0, \u0027invalid value\u0027);\n    claimingFeeNumerator = numerator;\n    claimingFeeDenominator = denominator;\n  }\n\n  function updateRecurringFee(uint256 feeInWei) public {\n    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, \u0027not an admin\u0027);\n    recurringFeeInWei = feeInWei;\n  }\n\n  function updateRecurringNaaSFee(uint256 feeInWei) public {\n    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, \u0027not an admin\u0027);\n    recurringNaaSFeeInWei = feeInWei;\n  }\n\n  function updateRecurringPaymentCycleInBlocks(uint256 blocks) public {\n    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, \u0027not an admin\u0027);\n    require(blocks \u003e 0, \u0027zero\u0027);\n    recurringPaymentCycleInBlocks = blocks;\n  }\n\n  // CORE\n  // *************************************************************************************\n\n  function requestAccess(bool isNaaS) public payable {\n    uint256 rFee;\n    uint256 sFee;\n\n    if (hasLegacyNode(msg.sender)) {\n      migrateLegacyNode(msg.sender);\n    }\n\n    uint128 nodeId = entityNodeCount[msg.sender] + 1;\n    bytes memory id = getNodeId(msg.sender, nodeId);\n\n    if (isNaaS) {\n      rFee = naasRequestingFeeInWei;\n      sFee = naasStrongFeeInWei;\n      activeEntities = activeEntities.add(1);\n    } else {\n      rFee = requestingFeeInWei;\n      sFee = strongFeeInWei;\n      entityNodeIsBYON[id] = true;\n    }\n\n    require(msg.value == rFee, \u0027invalid fee\u0027);\n\n    entityNodePaidOnBlock[id] = block.number;\n    entityNodeTraunch[id] = currentTraunch;\n    entityNodeClaimedOnBlock[id] = block.number;\n    entityNodeCount[msg.sender] = entityNodeCount[msg.sender] + 1;\n\n    feeCollector.transfer(msg.value);\n    strongToken.transferFrom(msg.sender, address(this), sFee);\n    strongToken.transfer(feeCollector, sFee);\n\n    emit Paid(msg.sender, nodeId, entityNodeIsBYON[id], false, entityNodePaidOnBlock[id].add(recurringPaymentCycleInBlocks));\n  }\n\n  function setEntityActiveStatus(address entity, bool status) public {\n    require(msg.sender == admin || msg.sender == serviceAdmin || msg.sender == superAdmin, \u0027not admin\u0027);\n    uint256 index = entityIndex[entity];\n    require(entities[index] == entity, \u0027invalid entity\u0027);\n    require(entityActive[entity] != status, \u0027already set\u0027);\n    entityActive[entity] = status;\n    if (status) {\n      activeEntities = activeEntities.add(1);\n      entityBlockLastClaimedOn[entity] = block.number;\n    } else {\n      activeEntities = activeEntities.sub(1);\n      entityBlockLastClaimedOn[entity] = 0;\n    }\n  }\n\n  function setTraunch(address entity, uint256 value) public {\n    require(msg.sender == admin || msg.sender == serviceAdmin || msg.sender == superAdmin, \u0027not admin\u0027);\n\n    traunch[entity] = value;\n  }\n\n  function payFee(uint128 nodeId) public payable {\n    address sender = msg.sender == address(this) ? tx.origin : msg.sender;\n    bytes memory id = getNodeId(sender, nodeId);\n\n    if (hasLegacyNode(sender)) {\n      migrateLegacyNode(sender);\n    }\n\n    require(doesNodeExist(sender, nodeId), \u0027doesnt exist\u0027);\n\n    if (entityNodeIsBYON[id]) {\n      require(msg.value == recurringFeeInWei, \u0027invalid fee\u0027);\n    } else {\n      require(msg.value == recurringNaaSFeeInWei, \u0027invalid fee\u0027);\n    }\n\n    feeCollector.transfer(msg.value);\n    entityNodePaidOnBlock[id] = entityNodePaidOnBlock[id].add(recurringPaymentCycleInBlocks);\n\n    emit Paid(sender, nodeId, entityNodeIsBYON[id], true, entityNodePaidOnBlock[id]);\n  }\n\n  function getReward(address entity, uint128 nodeId) public view returns (uint256) {\n    return getRewardByBlock(entity, nodeId, block.number);\n  }\n\n  function getRewardByBlock(address entity, uint128 nodeId, uint256 blockNumber) public view returns (uint256) {\n    bytes memory id = getNodeId(entity, nodeId);\n\n    if (hasLegacyNode(entity)) {\n      return getRewardByBlockLegacy(entity, blockNumber);\n    }\n\n    uint256 blockLastClaimedOn = entityNodeClaimedOnBlock[id] != 0 ? entityNodeClaimedOnBlock[id] : entityNodePaidOnBlock[id];\n\n    if (blockNumber \u003e block.number) return 0;\n    if (blockLastClaimedOn == 0) return 0;\n    if (blockNumber \u003c blockLastClaimedOn) return 0;\n    if (activeEntities == 0) return 0;\n    if (entityNodeIsBYON[id] \u0026\u0026 !entityNodeIsActive[id]) return 0;\n\n    uint256 blockResult = blockNumber.sub(blockLastClaimedOn);\n    uint256 rewardNumerator;\n    uint256 rewardDenominator;\n\n    if (entityNodeIsBYON[id]) {\n      rewardNumerator = rewardPerBlockNumerator;\n      rewardDenominator = rewardPerBlockDenominator;\n    } else {\n      rewardNumerator = naasRewardPerBlockNumerator;\n      rewardDenominator = naasRewardPerBlockDenominator;\n    }\n\n    uint256 rewardPerBlockResult = blockResult.mul(rewardNumerator).div(rewardDenominator);\n\n    return rewardPerBlockResult;\n  }\n\n  function getRewardByBlockLegacy(address entity, uint256 blockNumber) public view returns (uint256) {\n    if (blockNumber \u003e block.number) return 0;\n    if (entityBlockLastClaimedOn[entity] == 0) return 0;\n    if (blockNumber \u003c entityBlockLastClaimedOn[entity]) return 0;\n    if (activeEntities == 0) return 0;\n    uint256 blockResult = blockNumber.sub(entityBlockLastClaimedOn[entity]);\n    uint256 rewardNumerator;\n    uint256 rewardDenominator;\n    if (entityIsNaaS[entity]) {\n      rewardNumerator = naasRewardPerBlockNumerator;\n      rewardDenominator = naasRewardPerBlockDenominator;\n    } else {\n      rewardNumerator = rewardPerBlockNumerator;\n      rewardDenominator = rewardPerBlockDenominator;\n    }\n    uint256 rewardPerBlockResult = blockResult.mul(rewardNumerator).div(rewardDenominator);\n\n    return rewardPerBlockResult;\n  }\n\n  function claim(uint128 nodeId, uint256 blockNumber, bool toStrongPool) public payable {\n    address sender = msg.sender == address(this) ? tx.origin : msg.sender;\n    bytes memory id = getNodeId(sender, nodeId);\n\n    if (hasLegacyNode(sender)) {\n      migrateLegacyNode(sender);\n    }\n\n    uint256 blockLastClaimedOn = entityNodeClaimedOnBlock[id] != 0 ? entityNodeClaimedOnBlock[id] : entityNodePaidOnBlock[id];\n    uint256 blockLastPaidOn = entityNodePaidOnBlock[id];\n\n    require(blockLastClaimedOn != 0, \u0027never claimed\u0027);\n    require(blockNumber \u003c= block.number, \u0027invalid block\u0027);\n    require(blockNumber \u003e blockLastClaimedOn, \u0027too soon\u0027);\n    require(!entityNodeIsBYON[id] || entityNodeIsActive[id], \u0027not active\u0027);\n\n    if (\n      (!entityNodeIsBYON[id] \u0026\u0026 recurringNaaSFeeInWei != 0) || (entityNodeIsBYON[id] \u0026\u0026 recurringFeeInWei != 0)\n    ) {\n      require(blockNumber \u003c blockLastPaidOn.add(recurringPaymentCycleInBlocks), \u0027pay fee\u0027);\n    }\n\n    uint256 reward = getRewardByBlock(sender, nodeId, blockNumber);\n    require(reward \u003e 0, \u0027no reward\u0027);\n\n    uint256 fee = reward.mul(claimingFeeNumerator).div(claimingFeeDenominator);\n    require(msg.value \u003e= fee, \u0027invalid fee\u0027);\n\n    feeCollector.transfer(msg.value);\n\n    if (toStrongPool) {\n      strongToken.approve(address(strongPool), reward);\n      strongPool.mineFor(sender, reward);\n    } else {\n      strongToken.transfer(sender, reward);\n    }\n\n    rewardBalance = rewardBalance.sub(reward);\n    entityNodeClaimedOnBlock[id] = blockNumber;\n    emit Claimed(sender, reward);\n  }\n\n  function getRewardAll(address entity, uint256 blockNumber) public view returns (uint256) {\n    uint256 rewardsAll = 0;\n\n    for (uint128 i = 1; i \u003c= entityNodeCount[entity]; i++) {\n      rewardsAll = rewardsAll.add(getRewardByBlock(entity, i, blockNumber \u003e 0 ? blockNumber : block.number));\n    }\n\n    return rewardsAll;\n  }\n\n  function doesNodeExist(address entity, uint128 nodeId) public view returns (bool) {\n    bytes memory id = getNodeId(entity, nodeId);\n    return entityNodePaidOnBlock[id] \u003e 0;\n  }\n\n  function getNodeId(address entity, uint128 nodeId) public view returns (bytes memory) {\n    uint128 id = nodeId != 0 ? nodeId : entityNodeCount[entity] + 1;\n    return abi.encodePacked(entity, id);\n  }\n\n  function getNodePaidOn(address entity, uint128 nodeId) public view returns (uint256) {\n    bytes memory id = getNodeId(entity, nodeId);\n    return entityNodePaidOnBlock[id];\n  }\n\n  function getNodeFee(address entity, uint128 nodeId) public view returns (uint256) {\n    bytes memory id = getNodeId(entity, nodeId);\n    return entityNodeIsBYON[id] ? recurringFeeInWei : recurringNaaSFeeInWei;\n  }\n\n  function isNodeActive(address entity, uint128 nodeId) public view returns (bool) {\n    bytes memory id = getNodeId(entity, nodeId);\n    return entityNodeIsActive[id] || !entityNodeIsBYON[id];\n  }\n\n  function isNodeBYON(address entity, uint128 nodeId) public view returns (bool) {\n    bytes memory id = getNodeId(entity, nodeId);\n    return entityNodeIsBYON[id];\n  }\n\n  function hasLegacyNode(address entity) public view returns (bool) {\n    return entityActive[entity] \u0026\u0026 entityNodeCount[entity] == 0;\n  }\n\n  function approveBYONNode(address entity, uint128 nodeId) public {\n    require(msg.sender == admin || msg.sender == serviceAdmin || msg.sender == superAdmin, \u0027not admin\u0027);\n\n    bytes memory id = getNodeId(entity, nodeId);\n    entityNodeIsActive[id] = true;\n    entityNodeClaimedOnBlock[id] = block.number;\n    activeEntities = activeEntities.add(1);\n  }\n\n  function suspendBYONNode(address entity, uint128 nodeId) public {\n    require(msg.sender == admin || msg.sender == serviceAdmin || msg.sender == superAdmin, \u0027not admin\u0027);\n\n    bytes memory id = getNodeId(entity, nodeId);\n    entityNodeIsActive[id] = false;\n    activeEntities = activeEntities.sub(1);\n  }\n\n  function setNodeIsActive(address entity, uint128 nodeId, bool isActive) public {\n    require(msg.sender == admin || msg.sender == serviceAdmin || msg.sender == superAdmin, \u0027not admin\u0027);\n    bytes memory id = getNodeId(entity, nodeId);\n\n    if (isActive \u0026\u0026 !entityNodeIsActive[id]) {\n      activeEntities = activeEntities.add(1);\n      entityNodeClaimedOnBlock[id] = block.number;\n    }\n\n    if (!isActive \u0026\u0026 entityNodeIsActive[id]) {\n      activeEntities = activeEntities.sub(1);\n    }\n\n    entityNodeIsActive[id] = isActive;\n  }\n\n  function setNodeIsNaaS(address entity, uint128 nodeId, bool isNaaS) public {\n    require(msg.sender == admin || msg.sender == serviceAdmin || msg.sender == superAdmin, \u0027not admin\u0027);\n    bytes memory id = getNodeId(entity, nodeId);\n\n    entityNodeIsBYON[id] = !isNaaS;\n  }\n\n  function migrateLegacyNode(address entity) private {\n    bytes memory id = getNodeId(entity, 1);\n    entityNodeClaimedOnBlock[id] = entityBlockLastClaimedOn[entity];\n    entityNodePaidOnBlock[id] = paidOnBlock[entity];\n    entityNodeTraunch[id] = traunch[entity];\n    entityNodeIsBYON[id] = !entityIsNaaS[entity];\n    if (entityNodeIsBYON[id]) {\n      entityNodeIsActive[id] = true;\n    }\n    entityNodeCount[msg.sender] = 1;\n  }\n\n  function migrateNode(uint128 nodeId, address to) public {\n    if (hasLegacyNode(msg.sender)) {\n      migrateLegacyNode(msg.sender);\n    }\n\n    if (hasLegacyNode(to)) {\n      migrateLegacyNode(to);\n    }\n\n    require(doesNodeExist(msg.sender, nodeId), \u0027doesnt exist\u0027);\n\n    uint128 toNodeId = entityNodeCount[to] + 1;\n    bytes memory fromId = getNodeId(msg.sender, nodeId);\n    bytes memory toId = getNodeId(to, toNodeId);\n\n    // move node to another address\n    entityNodeIsActive[toId] = entityNodeIsActive[fromId];\n    entityNodeIsBYON[toId] = entityNodeIsBYON[fromId];\n    entityNodePaidOnBlock[toId] = entityNodePaidOnBlock[fromId];\n    entityNodeClaimedOnBlock[toId] = entityNodeClaimedOnBlock[fromId];\n    entityNodeTraunch[toId] = entityNodeTraunch[fromId];\n    entityNodeCount[to] = entityNodeCount[to] + 1;\n\n    // deactivate node\n    entityNodeIsActive[fromId] = false;\n    entityNodePaidOnBlock[fromId] = 0;\n    entityNodeClaimedOnBlock[fromId] = 0;\n    entityNodeCount[msg.sender] = entityNodeCount[msg.sender] - 1;\n\n    emit Migrated(msg.sender, to, nodeId, toNodeId, entityNodeIsBYON[fromId]);\n  }\n\n  function claimAll(uint256 blockNumber, bool toStrongPool) public payable {\n    for (uint16 i = 1; i \u003c= entityNodeCount[msg.sender]; i++) {\n      uint256 reward = getRewardByBlock(msg.sender, i, blockNumber);\n      uint256 fee = reward.mul(claimingFeeNumerator).div(claimingFeeDenominator);\n      this.claim{ value: fee }(i, blockNumber, toStrongPool);\n    }\n  }\n\n  function payAll() public payable {\n    for (uint16 i = 1; i \u003c= entityNodeCount[msg.sender]; i++) {\n      bytes memory id = getNodeId(msg.sender, i);\n      uint256 fee = entityNodeIsBYON[id] ? recurringFeeInWei : recurringNaaSFeeInWei;\n      this.payFee{ value: fee }(i);\n    }\n  }\n}\n"},"StrongNFTBonus.sol":{"content":"//SPDX-License-Identifier: Unlicense\npragma solidity ^0.6.8;\n\nimport \"./ServiceInterface.sol\";\nimport \"./IERC1155Preset.sol\";\nimport \"./SafeMath.sol\";\nimport \"./Context.sol\";\n\ncontract StrongNFTBonus is Context {\n\n  using SafeMath for uint256;\n\n  event Staked(address indexed sender, uint256 tokenId, uint128 nodeId, uint256 block);\n  event Unstaked(address indexed sender, uint256 tokenId, uint128 nodeId, uint256 block);\n\n  ServiceInterface public service;\n  IERC1155Preset public nft;\n\n  bool public initDone;\n\n  address public serviceAdmin;\n  address public superAdmin;\n\n  string[] public nftBonusNames;\n  mapping(string =\u003e uint256) public nftBonusLowerBound;\n  mapping(string =\u003e uint256) public nftBonusUpperBound;\n  mapping(string =\u003e uint256) public nftBonusValue;\n\n  mapping(uint256 =\u003e uint256) public nftIdStakedForNodeId;\n  mapping(address =\u003e mapping(uint128 =\u003e uint256)) public entityNodeStakedNftId;\n  mapping(address =\u003e mapping(uint128 =\u003e uint256)) public entityNodeStakedNftBlock;\n\n  function init(address serviceContract, address nftContract, address serviceAdminAddress, address superAdminAddress) public {\n    require(initDone == false, \"init done\");\n\n    serviceAdmin = serviceAdminAddress;\n    superAdmin = superAdminAddress;\n    service = ServiceInterface(serviceContract);\n    nft = IERC1155Preset(nftContract);\n    initDone = true;\n  }\n\n  function isNftStaked(uint256 _tokenId) public view returns (bool) {\n    return nftIdStakedForNodeId[_tokenId] != 0;\n  }\n\n  function getNftStakedForNodeId(uint256 _tokenId) public view returns (uint256) {\n    return nftIdStakedForNodeId[_tokenId];\n  }\n\n  function getStakedNftId(address _entity, uint128 _nodeId) public view returns (uint256) {\n    return entityNodeStakedNftId[_entity][_nodeId];\n  }\n\n  function getStakedNftBlock(address _entity, uint128 _nodeId) public view returns (uint256) {\n    return entityNodeStakedNftBlock[_entity][_nodeId];\n  }\n\n  function getBonus(address _entity, uint128 _nodeId, uint256 _fromBlock, uint256 _toBlock) public view returns (uint256) {\n    uint256 nftId = entityNodeStakedNftId[_entity][_nodeId];\n\n    if (nftId == 0) return 0;\n    if (nftId \u003c nftBonusLowerBound[\"BRONZE\"]) return 0;\n    if (nftId \u003e nftBonusUpperBound[\"BRONZE\"]) return 0;\n    if (nft.balanceOf(_entity, nftId) == 0) return 0;\n    if (_fromBlock \u003e= _toBlock) return 0;\n\n    uint256 stakedAtBlock = entityNodeStakedNftBlock[_entity][_nodeId];\n\n    if (stakedAtBlock == 0) return 0;\n\n    uint256 startFromBlock = stakedAtBlock \u003e _fromBlock ? stakedAtBlock : _fromBlock;\n\n    if (startFromBlock \u003e= _toBlock) return 0;\n\n    return _toBlock.sub(startFromBlock).mul(nftBonusValue[\"BRONZE\"]);\n  }\n\n  function stakeNFT(uint256 _tokenId, uint128 _nodeId) public payable {\n    require(nft.balanceOf(_msgSender(), _tokenId) != 0, \"not enough\");\n    require(_tokenId \u003e= nftBonusLowerBound[\"BRONZE\"] \u0026\u0026 _tokenId \u003c= nftBonusUpperBound[\"BRONZE\"], \"not eligible\");\n    require(nftIdStakedForNodeId[_tokenId] == 0, \"already staked\");\n    require(service.doesNodeExist(_msgSender(), _nodeId), \"node doesnt exist\");\n\n    nftIdStakedForNodeId[_tokenId] = _nodeId;\n    entityNodeStakedNftId[_msgSender()][_nodeId] = _tokenId;\n    entityNodeStakedNftBlock[_msgSender()][_nodeId] = block.number;\n\n    emit Staked(msg.sender, _tokenId, _nodeId, block.number);\n  }\n\n  function unStakeNFT(uint256 _tokenId, uint128 _nodeId, uint256 _blockNumber) public payable {\n    require(nft.balanceOf(_msgSender(), _tokenId) != 0, \"not enough\");\n    require(nftIdStakedForNodeId[_tokenId] == _nodeId, \"not this node\");\n\n    service.claim{value : msg.value}(_nodeId, _blockNumber, false);\n\n    nftIdStakedForNodeId[_tokenId] = 0;\n    entityNodeStakedNftId[_msgSender()][_nodeId] = 0;\n    entityNodeStakedNftBlock[_msgSender()][_nodeId] = 0;\n\n    emit Unstaked(msg.sender, _tokenId, _nodeId, _blockNumber);\n  }\n\n  function updateBonus(string memory _name, uint256 _lowerBound, uint256 _upperBound, uint256 _value) public {\n    require(msg.sender == serviceAdmin || msg.sender == superAdmin, \"not admin\");\n\n    bool alreadyExit = false;\n    for (uint i = 0; i \u003c nftBonusNames.length; i++) {\n      if (keccak256(abi.encode(nftBonusNames[i])) == keccak256(abi.encode(_name))) {\n        alreadyExit = true;\n      }\n    }\n\n    if (!alreadyExit) {\n      nftBonusNames.push(_name);\n    }\n\n    nftBonusLowerBound[_name] = _lowerBound;\n    nftBonusUpperBound[_name] = _upperBound;\n    nftBonusValue[_name] = _value;\n  }\n\n  function updateContracts(address serviceContract, address nftContract) public {\n    require(msg.sender == superAdmin, \"not admin\");\n    service = ServiceInterface(serviceContract);\n    nft = IERC1155Preset(nftContract);\n  }\n\n  function updateServiceAdmin(address newServiceAdmin) public {\n    require(msg.sender == superAdmin, \"not admin\");\n    serviceAdmin = newServiceAdmin;\n  }\n}\n"},"StrongNFTBonusInterface.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity ^0.6.12;\n\ninterface StrongNFTBonusInterface {\n  function getBonus(address _entity, uint128 _nodeId, uint256 _fromBlock, uint256 _toBlock) external view returns (uint256);\n}\n"},"StrongNFTClaimerInterface.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity ^0.6.12;\n\ninterface StrongNFTClaimerInterface {\n  function tokenNameAddressClaimed(string memory, address) external view returns(bool);\n}\n"},"StrongPoolInterface.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity ^0.6.12;\n\ninterface StrongPoolInterface {\n  function mineFor(address miner, uint256 amount) external;\n}\n"}}