ETH Price: $1,877.53 (+0.43%)

Transaction Decoder

Block:
14362164 at Mar-10-2022 11:48:41 PM +UTC
Transaction Fee:
0.001777613855380335 ETH $3.34
Gas Used:
67,305 Gas / 26.411319447 Gwei

Emitted Events:

650 AdminUpgradeabilityProxy.0x39b0a0620bb668047ab7248973ddfd93d53dff1d4952bd2d56bbf5934edc1fd0( 0x39b0a0620bb668047ab7248973ddfd93d53dff1d4952bd2d56bbf5934edc1fd0, 0x000000000000000000000000cb2d169accd43f20047359501decfa3b4153269b, 0000000000000000000000000000000000000000000000000000000000000001, 0000000000000000000000000000000000000000000000000000000000000000, 0000000000000000000000000000000000000000000000000000000000000001, 0000000000000000000000000000000000000000000000000000000000e1315c )

Account State Difference:

  Address   Before After State Difference Code
0x4B5057B2...fF2FDaCad 231.660184575257152386 Eth231.666047320355191606 Eth0.00586274509803922
(Flexpool.io)
5,131.721430535563504582 Eth5,131.721498168209898202 Eth0.00006763264639362
0xcb2d169a...B4153269B
0.180293073424986866 Eth
Nonce: 11
0.172652714471567311 Eth
Nonce: 12
0.007640358953419555
0xFbdDaDD8...2238Ae655
(StrongBlock: Service)

Execution Trace

ETH 0.00586274509803922 AdminUpgradeabilityProxy.0f694584( )
  • ETH 0.00586274509803922 ServiceV18.payFee( nodeId=1 )
    • ETH 0.00586274509803922 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: ServiceV18
      // SPDX-License-Identifier: MIT
      pragma solidity 0.6.12;
      import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
      import "@openzeppelin/contracts/math/SafeMath.sol";
      import "./interfaces/StrongPoolInterface.sol";
      import "./interfaces/IERC1155Preset.sol";
      import "./interfaces/StrongNFTBonusInterface.sol";
      import "./lib/rewards.sol";
      contract ServiceV18 {
        event Requested(address indexed miner);
        event Claimed(address indexed miner, uint256 reward);
        using SafeMath for uint256;
        bool public initDone;
        address public admin;
        address public pendingAdmin;
        address public superAdmin;
        address public pendingSuperAdmin;
        address public serviceAdmin;
        address public parameterAdmin;
        address payable public feeCollector;
        IERC20 public strongToken;
        StrongPoolInterface public strongPool;
        uint256 public rewardPerBlockNumerator;
        uint256 public rewardPerBlockDenominator;
        uint256 public naasRewardPerBlockNumerator;
        uint256 public naasRewardPerBlockDenominator;
        uint256 public claimingFeeNumerator;
        uint256 public claimingFeeDenominator;
        uint256 public requestingFeeInWei;
        uint256 public strongFeeInWei;
        uint256 public recurringFeeInWei;
        uint256 public recurringNaaSFeeInWei;
        uint256 public recurringPaymentCycleInBlocks;
        uint256 public rewardBalance;
        mapping(address => uint256) public entityBlockLastClaimedOn;
        address[] public entities;
        mapping(address => uint256) public entityIndex;
        mapping(address => bool) public entityActive;
        mapping(address => bool) public requestPending;
        mapping(address => bool) public entityIsNaaS;
        mapping(address => uint256) public paidOnBlock;
        uint256 public activeEntities;
        string public desciption;
        uint256 public claimingFeeInWei;
        uint256 public naasRequestingFeeInWei;
        uint256 public naasStrongFeeInWei;
        bool public removedTokens;
        mapping(address => uint256) public traunch;
        uint256 public currentTraunch;
        mapping(bytes => bool) public entityNodeIsActive;
        mapping(bytes => bool) public entityNodeIsBYON;
        mapping(bytes => uint256) public entityNodeTraunch;
        mapping(bytes => uint256) public entityNodePaidOnBlock;
        mapping(bytes => uint256) public entityNodeClaimedOnBlock;
        mapping(address => uint128) public entityNodeCount;
        event Paid(address indexed entity, uint128 nodeId, bool isBYON, bool isRenewal, uint256 upToBlockNumber);
        event Migrated(address indexed from, address indexed to, uint128 fromNodeId, uint128 toNodeId, bool isBYON);
        uint256 public rewardPerBlockNumeratorNew;
        uint256 public rewardPerBlockDenominatorNew;
        uint256 public naasRewardPerBlockNumeratorNew;
        uint256 public naasRewardPerBlockDenominatorNew;
        uint256 public rewardPerBlockNewEffectiveBlock;
        StrongNFTBonusInterface public strongNFTBonus;
        uint256 public gracePeriodInBlocks;
        uint128 public maxNodes;
        uint256 public maxPaymentPeriods;
        event Deactivated(address indexed entity, uint128 nodeId, bool isBYON, uint256 atBlockNumber);
        function init(
          address strongTokenAddress,
          address strongPoolAddress,
          address adminAddress,
          address superAdminAddress,
          uint256 rewardPerBlockNumeratorValue,
          uint256 rewardPerBlockDenominatorValue,
          uint256 naasRewardPerBlockNumeratorValue,
          uint256 naasRewardPerBlockDenominatorValue,
          uint256 requestingFeeInWeiValue,
          uint256 strongFeeInWeiValue,
          uint256 recurringFeeInWeiValue,
          uint256 recurringNaaSFeeInWeiValue,
          uint256 recurringPaymentCycleInBlocksValue,
          uint256 claimingFeeNumeratorValue,
          uint256 claimingFeeDenominatorValue,
          string memory desc
        ) public {
          require(!initDone, "init done");
          strongToken = IERC20(strongTokenAddress);
          strongPool = StrongPoolInterface(strongPoolAddress);
          admin = adminAddress;
          superAdmin = superAdminAddress;
          rewardPerBlockNumerator = rewardPerBlockNumeratorValue;
          rewardPerBlockDenominator = rewardPerBlockDenominatorValue;
          naasRewardPerBlockNumerator = naasRewardPerBlockNumeratorValue;
          naasRewardPerBlockDenominator = naasRewardPerBlockDenominatorValue;
          requestingFeeInWei = requestingFeeInWeiValue;
          strongFeeInWei = strongFeeInWeiValue;
          recurringFeeInWei = recurringFeeInWeiValue;
          recurringNaaSFeeInWei = recurringNaaSFeeInWeiValue;
          claimingFeeNumerator = claimingFeeNumeratorValue;
          claimingFeeDenominator = claimingFeeDenominatorValue;
          recurringPaymentCycleInBlocks = recurringPaymentCycleInBlocksValue;
          desciption = desc;
          initDone = true;
        }
        function updateServiceAdmin(address newServiceAdmin) public {
          require(msg.sender == superAdmin);
          serviceAdmin = newServiceAdmin;
        }
        function updateParameterAdmin(address newParameterAdmin) public {
          require(newParameterAdmin != address(0));
          require(msg.sender == superAdmin);
          parameterAdmin = newParameterAdmin;
        }
        function updateFeeCollector(address payable newFeeCollector) public {
          require(newFeeCollector != address(0));
          require(msg.sender == superAdmin);
          feeCollector = newFeeCollector;
        }
        function setPendingAdmin(address newPendingAdmin) public {
          require(msg.sender == admin);
          pendingAdmin = newPendingAdmin;
        }
        function acceptAdmin() public {
          require(msg.sender == pendingAdmin && msg.sender != address(0), "not pendingAdmin");
          admin = pendingAdmin;
          pendingAdmin = address(0);
        }
        function setPendingSuperAdmin(address newPendingSuperAdmin) public {
          require(msg.sender == superAdmin, "not superAdmin");
          pendingSuperAdmin = newPendingSuperAdmin;
        }
        function acceptSuperAdmin() public {
          require(msg.sender == pendingSuperAdmin && msg.sender != address(0), "not pendingSuperAdmin");
          superAdmin = pendingSuperAdmin;
          pendingSuperAdmin = address(0);
        }
        function isEntityActive(address entity) public view returns (bool) {
          return entityActive[entity] || (doesNodeExist(entity, 1) && !hasNodeExpired(entity, 1));
        }
        function updateRewardPerBlock(uint256 numerator, uint256 denominator) public {
          require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin);
          require(denominator != 0);
          rewardPerBlockNumerator = numerator;
          rewardPerBlockDenominator = denominator;
        }
        function updateNaaSRewardPerBlock(uint256 numerator, uint256 denominator) public {
          require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin);
          require(denominator != 0);
          naasRewardPerBlockNumerator = numerator;
          naasRewardPerBlockDenominator = denominator;
        }
        function updateRewardPerBlockNew(
          uint256 numerator,
          uint256 denominator,
          uint256 numeratorNass,
          uint256 denominatorNass,
          uint256 effectiveBlock
        ) public {
          require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin);
          rewardPerBlockNumeratorNew = numerator;
          rewardPerBlockDenominatorNew = denominator;
          naasRewardPerBlockNumeratorNew = numeratorNass;
          naasRewardPerBlockDenominatorNew = denominatorNass;
          rewardPerBlockNewEffectiveBlock = effectiveBlock != 0 ? effectiveBlock : block.number;
        }
        function deposit(uint256 amount) public {
          require(msg.sender == superAdmin);
          require(amount > 0);
          strongToken.transferFrom(msg.sender, address(this), amount);
          rewardBalance = rewardBalance.add(amount);
        }
        function withdraw(address destination, uint256 amount) public {
          require(msg.sender == superAdmin);
          require(amount > 0);
          require(rewardBalance >= amount, "not enough");
          strongToken.transfer(destination, amount);
          rewardBalance = rewardBalance.sub(amount);
        }
        function updateRequestingFee(uint256 feeInWei) public {
          require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin);
          requestingFeeInWei = feeInWei;
        }
        function updateStrongFee(uint256 feeInWei) public {
          require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin);
          strongFeeInWei = feeInWei;
        }
        function updateNaasRequestingFee(uint256 feeInWei) public {
          require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin);
          naasRequestingFeeInWei = feeInWei;
        }
        function updateNaasStrongFee(uint256 feeInWei) public {
          require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin);
          naasStrongFeeInWei = feeInWei;
        }
        function updateClaimingFee(uint256 numerator, uint256 denominator) public {
          require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin);
          require(denominator != 0);
          claimingFeeNumerator = numerator;
          claimingFeeDenominator = denominator;
        }
        function updateRecurringFee(uint256 feeInWei) public {
          require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin);
          recurringFeeInWei = feeInWei;
        }
        function updateRecurringNaaSFee(uint256 feeInWei) public {
          require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin);
          recurringNaaSFeeInWei = feeInWei;
        }
        function updateRecurringPaymentCycleInBlocks(uint256 blocks) public {
          require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin);
          require(blocks > 0);
          recurringPaymentCycleInBlocks = blocks;
        }
        function updateGracePeriodInBlocks(uint256 blocks) public {
          require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin);
          require(blocks > 0);
          gracePeriodInBlocks = blocks;
        }
        function requestAccess(bool isNaaS) public payable {
          require(entityNodeCount[msg.sender] < maxNodes, "limit reached");
          uint256 rFee;
          uint256 sFee;
          if (hasLegacyNode(msg.sender)) {
            migrateLegacyNode(msg.sender);
          }
          uint128 nodeId = entityNodeCount[msg.sender] + 1;
          bytes memory id = getNodeId(msg.sender, nodeId);
          if (isNaaS) {
            rFee = naasRequestingFeeInWei;
            sFee = naasStrongFeeInWei;
            activeEntities = activeEntities.add(1);
          } else {
            rFee = requestingFeeInWei;
            sFee = strongFeeInWei;
            entityNodeIsBYON[id] = true;
          }
          require(msg.value == rFee, "invalid fee");
          entityNodePaidOnBlock[id] = block.number;
          entityNodeClaimedOnBlock[id] = block.number;
          entityNodeCount[msg.sender] = entityNodeCount[msg.sender] + 1;
          feeCollector.transfer(msg.value);
          strongToken.transferFrom(msg.sender, address(this), sFee);
          strongToken.transfer(feeCollector, sFee);
          emit Paid(msg.sender, nodeId, entityNodeIsBYON[id], false, entityNodePaidOnBlock[id].add(recurringPaymentCycleInBlocks));
        }
        function setEntityActiveStatus(address entity, bool status) public {
          require(msg.sender == admin || msg.sender == serviceAdmin || msg.sender == superAdmin);
          uint256 index = entityIndex[entity];
          require(entities[index] == entity, "invalid entity");
          require(entityActive[entity] != status, "already set");
          entityActive[entity] = status;
          if (status) {
            activeEntities = activeEntities.add(1);
            entityBlockLastClaimedOn[entity] = block.number;
          } else {
            activeEntities = activeEntities.sub(1);
            entityBlockLastClaimedOn[entity] = 0;
          }
        }
        function payFee(uint128 nodeId) public payable {
          address sender = msg.sender == address(this) ? tx.origin : msg.sender;
          bytes memory id = getNodeId(sender, nodeId);
          if (hasLegacyNode(sender)) {
            migrateLegacyNode(sender);
          }
          require(doesNodeExist(sender, nodeId), "doesnt exist");
          require(hasNodeExpired(sender, nodeId) == false, "too late");
          require(hasMaxPayments(sender, nodeId) == false, "too soon");
          if (entityNodeIsBYON[id]) {
            require(msg.value == recurringFeeInWei, "invalid fee");
          } else {
            require(msg.value == recurringNaaSFeeInWei, "invalid fee");
          }
          feeCollector.transfer(msg.value);
          entityNodePaidOnBlock[id] = entityNodePaidOnBlock[id].add(recurringPaymentCycleInBlocks);
          emit Paid(sender, nodeId, entityNodeIsBYON[id], true, entityNodePaidOnBlock[id]);
        }
        function getReward(address entity, uint128 nodeId) public view returns (uint256) {
          return getRewardByBlock(entity, nodeId, block.number);
        }
        function getRewardByBlock(address entity, uint128 nodeId, uint256 blockNumber) public view returns (uint256) {
          bytes memory id = getNodeId(entity, nodeId);
          if (hasLegacyNode(entity)) {
            return getRewardByBlockLegacy(entity, blockNumber);
          }
          uint256 blockLastClaimedOn = entityNodeClaimedOnBlock[id] != 0 ? entityNodeClaimedOnBlock[id] : entityNodePaidOnBlock[id];
          if (hasNodeExpired(entity, nodeId)) return 0;
          if (blockNumber > block.number) return 0;
          if (blockLastClaimedOn == 0) return 0;
          if (blockNumber < blockLastClaimedOn) return 0;
          if (activeEntities == 0) return 0;
          if (entityNodeIsBYON[id] && !entityNodeIsActive[id]) return 0;
          uint256 rewardNumerator = entityNodeIsBYON[id] ? rewardPerBlockNumerator : naasRewardPerBlockNumerator;
          uint256 rewardDenominator = entityNodeIsBYON[id] ? rewardPerBlockDenominator : naasRewardPerBlockDenominator;
          uint256 newRewardNumerator = entityNodeIsBYON[id] ? rewardPerBlockNumeratorNew : naasRewardPerBlockNumeratorNew;
          uint256 newRewardDenominator = entityNodeIsBYON[id] ? rewardPerBlockDenominatorNew : naasRewardPerBlockDenominatorNew;
          uint256 bonus = address(strongNFTBonus) != address(0)
          ? strongNFTBonus.getBonus(entity, nodeId, blockLastClaimedOn, blockNumber)
          : 0;
          uint256[2] memory rewardBlocks = rewards.blocks(blockLastClaimedOn, rewardPerBlockNewEffectiveBlock, blockNumber);
          uint256 rewardOld = rewardDenominator > 0 ? rewardBlocks[0].mul(rewardNumerator).div(rewardDenominator) : 0;
          uint256 rewardNew = newRewardDenominator > 0 ? rewardBlocks[1].mul(newRewardNumerator).div(newRewardDenominator) : 0;
          return rewardOld.add(rewardNew).add(bonus);
        }
        function getRewardByBlockLegacy(address entity, uint256 blockNumber) public view returns (uint256) {
          if (blockNumber > block.number) return 0;
          if (entityBlockLastClaimedOn[entity] == 0) return 0;
          if (blockNumber < entityBlockLastClaimedOn[entity]) return 0;
          if (activeEntities == 0) return 0;
          uint256 blockResult = blockNumber.sub(entityBlockLastClaimedOn[entity]);
          uint256 rewardNumerator;
          uint256 rewardDenominator;
          if (entityIsNaaS[entity]) {
            rewardNumerator = naasRewardPerBlockNumerator;
            rewardDenominator = naasRewardPerBlockDenominator;
          } else {
            rewardNumerator = rewardPerBlockNumerator;
            rewardDenominator = rewardPerBlockDenominator;
          }
          uint256 rewardPerBlockResult = blockResult.mul(rewardNumerator).div(rewardDenominator);
          return rewardPerBlockResult;
        }
        function claim(uint128 nodeId, uint256 blockNumber, bool toStrongPool) public payable returns (bool) {
          address sender = msg.sender == address(this) || msg.sender == address(strongNFTBonus) ? tx.origin : msg.sender;
          bytes memory id = getNodeId(sender, nodeId);
          if (hasLegacyNode(sender)) {
            migrateLegacyNode(sender);
          }
          uint256 blockLastClaimedOn = entityNodeClaimedOnBlock[id] != 0 ? entityNodeClaimedOnBlock[id] : entityNodePaidOnBlock[id];
          uint256 blockLastPaidOn = entityNodePaidOnBlock[id];
          require(blockLastClaimedOn != 0, "never claimed");
          require(blockNumber <= block.number, "invalid block");
          require(blockNumber > blockLastClaimedOn, "too soon");
          require(!entityNodeIsBYON[id] || entityNodeIsActive[id], "not active");
          if (
            (!entityNodeIsBYON[id] && recurringNaaSFeeInWei != 0) || (entityNodeIsBYON[id] && recurringFeeInWei != 0)
          ) {
            require(blockNumber < blockLastPaidOn.add(recurringPaymentCycleInBlocks), "pay fee");
          }
          uint256 reward = getRewardByBlock(sender, nodeId, blockNumber);
          require(reward > 0, "no reward");
          uint256 fee = reward.mul(claimingFeeNumerator).div(claimingFeeDenominator);
          require(msg.value >= fee, "invalid fee");
          feeCollector.transfer(msg.value);
          if (toStrongPool) {
            strongToken.approve(address(strongPool), reward);
            strongPool.mineFor(sender, reward);
          } else {
            strongToken.transfer(sender, reward);
          }
          rewardBalance = rewardBalance.sub(reward);
          entityNodeClaimedOnBlock[id] = blockNumber;
          emit Claimed(sender, reward);
          return true;
        }
        function getRewardAll(address entity, uint256 blockNumber) public view returns (uint256) {
          uint256 rewardsAll = 0;
          for (uint128 i = 1; i <= entityNodeCount[entity]; i++) {
            rewardsAll = rewardsAll.add(getRewardByBlock(entity, i, blockNumber > 0 ? blockNumber : block.number));
          }
          return rewardsAll;
        }
        function canBePaid(address entity, uint128 nodeId) public view returns (bool) {
          return !isNodeBYON(entity, nodeId) && !hasNodeExpired(entity, nodeId) && !hasMaxPayments(entity, nodeId);
        }
        function doesNodeExist(address entity, uint128 nodeId) public view returns (bool) {
          bytes memory id = getNodeId(entity, nodeId);
          return entityNodePaidOnBlock[id] > 0;
        }
        function hasNodeExpired(address entity, uint128 nodeId) public view returns (bool) {
          bytes memory id = getNodeId(entity, nodeId);
          uint256 blockLastPaidOn = entityNodePaidOnBlock[id];
          if (entityNodeIsBYON[id]) return entityNodeIsActive[id] == false;
          if (doesNodeExist(entity, nodeId) == false) return true;
          return block.number > blockLastPaidOn.add(recurringPaymentCycleInBlocks).add(gracePeriodInBlocks);
        }
        function hasMaxPayments(address entity, uint128 nodeId) public view returns (bool) {
          bytes memory id = getNodeId(entity, nodeId);
          uint256 blockLastPaidOn = entityNodePaidOnBlock[id];
          uint256 limit = block.number.add(recurringPaymentCycleInBlocks.mul(maxPaymentPeriods));
          return blockLastPaidOn.add(recurringPaymentCycleInBlocks) >= limit;
        }
        function getNodeId(address entity, uint128 nodeId) public view returns (bytes memory) {
          uint128 id = nodeId != 0 ? nodeId : entityNodeCount[entity] + 1;
          return abi.encodePacked(entity, id);
        }
        function getNodePaidOn(address entity, uint128 nodeId) public view returns (uint256) {
          bytes memory id = getNodeId(entity, nodeId);
          return entityNodePaidOnBlock[id];
        }
        function isNodeActive(address entity, uint128 nodeId) public view returns (bool) {
          bytes memory id = getNodeId(entity, nodeId);
          return entityNodeIsActive[id] || !entityNodeIsBYON[id];
        }
        function isNodeBYON(address entity, uint128 nodeId) public view returns (bool) {
          bytes memory id = getNodeId(entity, nodeId);
          return entityNodeIsBYON[id];
        }
        function hasLegacyNode(address entity) public view returns (bool) {
          return entityActive[entity] && entityNodeCount[entity] == 0;
        }
        function approveBYONNode(address entity, uint128 nodeId) public {
          require(msg.sender == admin || msg.sender == serviceAdmin || msg.sender == superAdmin);
          bytes memory id = getNodeId(entity, nodeId);
          entityNodeIsActive[id] = true;
          entityNodeClaimedOnBlock[id] = block.number;
          activeEntities = activeEntities.add(1);
        }
        function suspendBYONNode(address entity, uint128 nodeId) public {
          require(msg.sender == admin || msg.sender == serviceAdmin || msg.sender == superAdmin);
          bytes memory id = getNodeId(entity, nodeId);
          entityNodeIsActive[id] = false;
          activeEntities = activeEntities.sub(1);
        }
        function setNodeIsActive(address entity, uint128 nodeId, bool isActive) public {
          require(msg.sender == admin || msg.sender == serviceAdmin || msg.sender == superAdmin);
          bytes memory id = getNodeId(entity, nodeId);
          if (isActive && !entityNodeIsActive[id]) {
            activeEntities = activeEntities.add(1);
            entityNodeClaimedOnBlock[id] = block.number;
          }
          if (!isActive && entityNodeIsActive[id]) {
            activeEntities = activeEntities.sub(1);
          }
          entityNodeIsActive[id] = isActive;
        }
        function setNodeIsNaaS(address entity, uint128 nodeId, bool isNaaS) public {
          require(msg.sender == admin || msg.sender == serviceAdmin || msg.sender == superAdmin);
          bytes memory id = getNodeId(entity, nodeId);
          entityNodeIsBYON[id] = !isNaaS;
        }
        function migrateLegacyNode(address entity) private {
          bytes memory id = getNodeId(entity, 1);
          entityNodeClaimedOnBlock[id] = entityBlockLastClaimedOn[entity];
          entityNodePaidOnBlock[id] = paidOnBlock[entity];
          entityNodeIsBYON[id] = !entityIsNaaS[entity];
          if (entityNodeIsBYON[id]) {
            entityNodeIsActive[id] = true;
          }
          entityNodeCount[msg.sender] = 1;
        }
        function claimAll(uint256 blockNumber, bool toStrongPool) public payable {
          uint256 value = msg.value;
          for (uint16 i = 1; i <= entityNodeCount[msg.sender]; i++) {
            uint256 reward = getRewardByBlock(msg.sender, i, blockNumber);
            uint256 fee = reward.mul(claimingFeeNumerator).div(claimingFeeDenominator);
            require(value >= fee, "invalid fee");
            if (reward > 0) {
              require(this.claim{value : fee}(i, blockNumber, toStrongPool), "claim failed");
            }
            value = value.sub(fee);
          }
        }
        function payAll(uint256 nodeCount) public payable {
          require(nodeCount > 0, "invalid value");
          require(msg.value == recurringNaaSFeeInWei.mul(nodeCount), "invalid fee");
          for (uint16 nodeId = 1; nodeId <= entityNodeCount[msg.sender]; nodeId++) {
            if (!canBePaid(msg.sender, nodeId)) {
              continue;
            }
            this.payFee{value : recurringNaaSFeeInWei}(nodeId);
            nodeCount = nodeCount.sub(1);
          }
          require(nodeCount == 0, "invalid count");
        }
        function addNFTBonusContract(address _contract) public {
          require(msg.sender == admin || msg.sender == serviceAdmin || msg.sender == superAdmin);
          strongNFTBonus = StrongNFTBonusInterface(_contract);
        }
        function disableNodeAdmin(address entity, uint128 nodeId) public {
          require(msg.sender == admin || msg.sender == serviceAdmin || msg.sender == superAdmin);
          bytes memory id = getNodeId(entity, nodeId);
          entityNodePaidOnBlock[id] = 0;
          entityNodeClaimedOnBlock[id] = 0;
          emit Deactivated(entity, nodeId, entityNodeIsBYON[id], block.number);
        }
        function updateLimits(uint128 _maxNodes, uint256 _maxPaymentPeriods) public {
          require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin);
          maxNodes = _maxNodes;
          maxPaymentPeriods = _maxPaymentPeriods;
        }
      }
      // SPDX-License-Identifier: MIT
      pragma solidity >=0.6.0 <0.8.0;
      /**
       * @dev Interface of the ERC20 standard as defined in the EIP.
       */
      interface IERC20 {
          /**
           * @dev Returns the amount of tokens in existence.
           */
          function totalSupply() external view returns (uint256);
          /**
           * @dev Returns the amount of tokens owned by `account`.
           */
          function balanceOf(address account) external view returns (uint256);
          /**
           * @dev Moves `amount` tokens from the caller's account to `recipient`.
           *
           * Returns a boolean value indicating whether the operation succeeded.
           *
           * Emits a {Transfer} event.
           */
          function transfer(address recipient, uint256 amount) external returns (bool);
          /**
           * @dev Returns the remaining number of tokens that `spender` will be
           * allowed to spend on behalf of `owner` through {transferFrom}. This is
           * zero by default.
           *
           * This value changes when {approve} or {transferFrom} are called.
           */
          function allowance(address owner, address spender) external view returns (uint256);
          /**
           * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
           *
           * Returns a boolean value indicating whether the operation succeeded.
           *
           * IMPORTANT: Beware that changing an allowance with this method brings the risk
           * that someone may use both the old and the new allowance by unfortunate
           * transaction ordering. One possible solution to mitigate this race
           * condition is to first reduce the spender's allowance to 0 and set the
           * desired value afterwards:
           * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
           *
           * Emits an {Approval} event.
           */
          function approve(address spender, uint256 amount) external returns (bool);
          /**
           * @dev Moves `amount` tokens from `sender` to `recipient` using the
           * allowance mechanism. `amount` is then deducted from the caller's
           * allowance.
           *
           * Returns a boolean value indicating whether the operation succeeded.
           *
           * Emits a {Transfer} event.
           */
          function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
          /**
           * @dev Emitted when `value` tokens are moved from one account (`from`) to
           * another (`to`).
           *
           * Note that `value` may be zero.
           */
          event Transfer(address indexed from, address indexed to, uint256 value);
          /**
           * @dev Emitted when the allowance of a `spender` for an `owner` is set by
           * a call to {approve}. `value` is the new allowance.
           */
          event Approval(address indexed owner, address indexed spender, uint256 value);
      }
      // SPDX-License-Identifier: MIT
      pragma solidity >=0.6.0 <0.8.0;
      /**
       * @dev Wrappers over Solidity's arithmetic operations with added overflow
       * checks.
       *
       * Arithmetic operations in Solidity wrap on overflow. This can easily result
       * in bugs, because programmers usually assume that an overflow raises an
       * error, which is the standard behavior in high level programming languages.
       * `SafeMath` restores this intuition by reverting the transaction when an
       * operation overflows.
       *
       * Using this library instead of the unchecked operations eliminates an entire
       * class of bugs, so it's recommended to use it always.
       */
      library SafeMath {
          /**
           * @dev Returns the addition of two unsigned integers, with an overflow flag.
           *
           * _Available since v3.4._
           */
          function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
              uint256 c = a + b;
              if (c < a) return (false, 0);
              return (true, c);
          }
          /**
           * @dev Returns the substraction of two unsigned integers, with an overflow flag.
           *
           * _Available since v3.4._
           */
          function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
              if (b > a) return (false, 0);
              return (true, a - b);
          }
          /**
           * @dev Returns the multiplication of two unsigned integers, with an overflow flag.
           *
           * _Available since v3.4._
           */
          function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
              // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
              // benefit is lost if 'b' is also tested.
              // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
              if (a == 0) return (true, 0);
              uint256 c = a * b;
              if (c / a != b) return (false, 0);
              return (true, c);
          }
          /**
           * @dev Returns the division of two unsigned integers, with a division by zero flag.
           *
           * _Available since v3.4._
           */
          function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
              if (b == 0) return (false, 0);
              return (true, a / b);
          }
          /**
           * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
           *
           * _Available since v3.4._
           */
          function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
              if (b == 0) return (false, 0);
              return (true, a % b);
          }
          /**
           * @dev Returns the addition of two unsigned integers, reverting on
           * overflow.
           *
           * Counterpart to Solidity's `+` operator.
           *
           * Requirements:
           *
           * - Addition cannot overflow.
           */
          function add(uint256 a, uint256 b) internal pure returns (uint256) {
              uint256 c = a + b;
              require(c >= a, "SafeMath: addition overflow");
              return c;
          }
          /**
           * @dev Returns the subtraction of two unsigned integers, reverting on
           * overflow (when the result is negative).
           *
           * Counterpart to Solidity's `-` operator.
           *
           * Requirements:
           *
           * - Subtraction cannot overflow.
           */
          function sub(uint256 a, uint256 b) internal pure returns (uint256) {
              require(b <= a, "SafeMath: subtraction overflow");
              return a - b;
          }
          /**
           * @dev Returns the multiplication of two unsigned integers, reverting on
           * overflow.
           *
           * Counterpart to Solidity's `*` operator.
           *
           * Requirements:
           *
           * - Multiplication cannot overflow.
           */
          function mul(uint256 a, uint256 b) internal pure returns (uint256) {
              if (a == 0) return 0;
              uint256 c = a * b;
              require(c / a == b, "SafeMath: multiplication overflow");
              return c;
          }
          /**
           * @dev Returns the integer division of two unsigned integers, reverting on
           * division by zero. The result is rounded towards zero.
           *
           * Counterpart to Solidity's `/` operator. Note: this function uses a
           * `revert` opcode (which leaves remaining gas untouched) while Solidity
           * uses an invalid opcode to revert (consuming all remaining gas).
           *
           * Requirements:
           *
           * - The divisor cannot be zero.
           */
          function div(uint256 a, uint256 b) internal pure returns (uint256) {
              require(b > 0, "SafeMath: division by zero");
              return a / b;
          }
          /**
           * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
           * reverting when dividing by zero.
           *
           * Counterpart to Solidity's `%` operator. This function uses a `revert`
           * opcode (which leaves remaining gas untouched) while Solidity uses an
           * invalid opcode to revert (consuming all remaining gas).
           *
           * Requirements:
           *
           * - The divisor cannot be zero.
           */
          function mod(uint256 a, uint256 b) internal pure returns (uint256) {
              require(b > 0, "SafeMath: modulo by zero");
              return a % b;
          }
          /**
           * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
           * overflow (when the result is negative).
           *
           * CAUTION: This function is deprecated because it requires allocating memory for the error
           * message unnecessarily. For custom revert reasons use {trySub}.
           *
           * Counterpart to Solidity's `-` operator.
           *
           * Requirements:
           *
           * - Subtraction cannot overflow.
           */
          function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
              require(b <= a, errorMessage);
              return a - b;
          }
          /**
           * @dev Returns the integer division of two unsigned integers, reverting with custom message on
           * division by zero. The result is rounded towards zero.
           *
           * CAUTION: This function is deprecated because it requires allocating memory for the error
           * message unnecessarily. For custom revert reasons use {tryDiv}.
           *
           * Counterpart to Solidity's `/` operator. Note: this function uses a
           * `revert` opcode (which leaves remaining gas untouched) while Solidity
           * uses an invalid opcode to revert (consuming all remaining gas).
           *
           * Requirements:
           *
           * - The divisor cannot be zero.
           */
          function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
              require(b > 0, errorMessage);
              return a / b;
          }
          /**
           * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
           * reverting with custom message when dividing by zero.
           *
           * CAUTION: This function is deprecated because it requires allocating memory for the error
           * message unnecessarily. For custom revert reasons use {tryMod}.
           *
           * Counterpart to Solidity's `%` operator. This function uses a `revert`
           * opcode (which leaves remaining gas untouched) while Solidity uses an
           * invalid opcode to revert (consuming all remaining gas).
           *
           * Requirements:
           *
           * - The divisor cannot be zero.
           */
          function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
              require(b > 0, errorMessage);
              return a % b;
          }
      }
      // SPDX-License-Identifier: MIT
      pragma solidity ^0.6.12;
      interface StrongPoolInterface {
        function mineFor(address miner, uint256 amount) external;
      }
      // SPDX-License-Identifier: MIT
      pragma solidity ^0.6.2;
      /**
       * @dev Required interface of an ERC1155 compliant contract, as defined in the
       * https://eips.ethereum.org/EIPS/eip-1155[EIP].
       *
       * _Available since v3.1._
       */
      interface IERC1155Preset {
          /**
           * @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`.
           */
          event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);
          /**
           * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all
           * transfers.
           */
          event TransferBatch(address indexed operator, address indexed from, address indexed to, uint256[] ids, uint256[] values);
          /**
           * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to
           * `approved`.
           */
          event ApprovalForAll(address indexed account, address indexed operator, bool approved);
          /**
           * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI.
           *
           * If an {URI} event was emitted for `id`, the standard
           * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value
           * returned by {IERC1155MetadataURI-uri}.
           */
          event URI(string value, uint256 indexed id);
          /**
           * @dev Returns the amount of tokens of token type `id` owned by `account`.
           *
           * Requirements:
           *
           * - `account` cannot be the zero address.
           */
          function balanceOf(address account, uint256 id) external view returns (uint256);
          /**
           * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}.
           *
           * Requirements:
           *
           * - `accounts` and `ids` must have the same length.
           */
          function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids) external view returns (uint256[] memory);
          /**
           * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`,
           *
           * Emits an {ApprovalForAll} event.
           *
           * Requirements:
           *
           * - `operator` cannot be the caller.
           */
          function setApprovalForAll(address operator, bool approved) external;
          /**
           * @dev Returns true if `operator` is approved to transfer ``account``'s tokens.
           *
           * See {setApprovalForAll}.
           */
          function isApprovedForAll(address account, address operator) external view returns (bool);
          /**
           * @dev Transfers `amount` tokens of token type `id` from `from` to `to`.
           *
           * Emits a {TransferSingle} event.
           *
           * Requirements:
           *
           * - `to` cannot be the zero address.
           * - If the caller is not `from`, it must be have been approved to spend ``from``'s tokens via {setApprovalForAll}.
           * - `from` must have a balance of tokens of type `id` of at least `amount`.
           * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
           * acceptance magic value.
           */
          function safeTransferFrom(address from, address to, uint256 id, uint256 amount, bytes calldata data) external;
          /**
           * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.
           *
           * Emits a {TransferBatch} event.
           *
           * Requirements:
           *
           * - `ids` and `amounts` must have the same length.
           * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
           * acceptance magic value.
           */
          function safeBatchTransferFrom(address from, address to, uint256[] calldata ids, uint256[] calldata amounts, bytes calldata data) external;
          /**
           * @dev Returns true if this contract implements the interface defined by
           * `interfaceId`. See the corresponding
           * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
           * to learn more about how these ids are created.
           *
           * This function call must use less than 30 000 gas.
           */
          function supportsInterface(bytes4 interfaceId) external view returns (bool);
          /**
           * @dev Creates `amount` new tokens for `to`, of token type `id`.
           *
           * See {ERC1155-_mint}.
           *
           * Requirements:
           *
           * - the caller must have the `MINTER_ROLE`.
           */
          function mint(address to, uint256 id, uint256 amount, bytes memory data) external;
          /**
           * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] variant of {mint}.
           */
          function mintBatch(address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data) external;
          function getOwnerIdByIndex(address owner, uint256 index) external view returns (uint256);
          function getOwnerIdIndex(address owner, uint256 id) external view returns (uint256);
      }
      // SPDX-License-Identifier: MIT
      pragma solidity ^0.6.12;
      interface StrongNFTBonusInterface {
        function getBonus(address _entity, uint128 _nodeId, uint256 _fromBlock, uint256 _toBlock) external view returns (uint256);
      }
      // SPDX-License-Identifier: MIT
      pragma solidity 0.6.12;
      import "@openzeppelin/contracts/math/SafeMath.sol";
      library rewards {
          using SafeMath for uint256;
          function blocks(uint256 lastClaimedOnBlock, uint256 newRewardBlock, uint256 blockNumber) internal pure returns (uint256[2] memory) {
              if (lastClaimedOnBlock >= blockNumber) return [uint256(0), uint256(0)];
              if (blockNumber <= newRewardBlock || newRewardBlock == 0) {
                  return [blockNumber.sub(lastClaimedOnBlock), uint256(0)];
              }
              else if (lastClaimedOnBlock >= newRewardBlock) {
                  return [uint256(0), blockNumber.sub(lastClaimedOnBlock)];
              }
              else {
                  return [newRewardBlock.sub(lastClaimedOnBlock), blockNumber.sub(newRewardBlock)];
              }
          }
      }