lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.7.6
// Returns the latest block number that oracles should be reporting balances for
function getLatestReportableBlock() override external view returns (uint256) {
        // Load contracts
        RocketDAOProtocolSettingsNetworkInterface rocketDAOProtocolSettingsNetwork = RocketDAOProtocolSettingsNetworkInterface(getContractAddress("rocketDAOProtocolSettingsNetwork"));
        // Get the block balances were lasted updated and the update frequency
        uint256 updateFrequency = rocketDAOProtocolSettingsNetwork.getSubmitBalancesFrequency();
        // Calculate the last reportable block based on update frequency
        return block.number.div(updateFrequency).mul(updateFrequency);
    }
// Solidity 0.8.9
/**
 * Revealing of next token in line
 * if the token is staked & is bee move it to the next available hive
 */
function tryReveal() public returns (bool) {
        if (unrevealedTokenIndex >= minted) return false;
        if (tokenData[unrevealedTokenIndex + 1]._type != 0) return true;

        uint256 seed = randomizerContract.revealSeed(unrevealedTokenIndex);
        if (seed == 0) return false;
        address trueOwner = ownerOf(unrevealedTokenIndex + 1) == address(hiveContract)
            ? hiveContract.getWaitingRoomOwner(unrevealedTokenIndex + 1)
            : ownerOf(unrevealedTokenIndex + 1);
        Token memory t = traitsContract.generate(seed);
        tokenData[unrevealedTokenIndex + 1] = t;
        if (t._type == 2) bearsMinted++;
        if (t._type == 3) beekeepersMinted++;
        if (t._type == 1 && ownerOf(unrevealedTokenIndex + 1) == address(hiveContract)) {
            hiveContract.removeFromWaitingRoom(unrevealedTokenIndex + 1, 0);
        }

        emit MintRevealed(trueOwner, unrevealedTokenIndex + 1, t._type, ownerOf(unrevealedTokenIndex + 1) == address(hiveContract) ? true : false);
        unrevealedTokenIndex += 1;
        return true;
    }
// Solidity 0.8.9
/**
 * adds honey to a address pot when clamin bee honey or when stealing/collecting
 */
function increaseTokensPot(address _owner, uint256 amount) external {
        require(_msgSender() == address(attackContract) || _msgSender() == address(hiveContract), "BEES:DONT CHEAT:POT");
        require(totalHoneyEarned + amount < MAXIMUM_GLOBAL_HONEY, "NO MORE HONEY");
        totalHoneyEarned += amount;
        pot[_owner] += amount;
    }
// Solidity 0.8.9
/**
 * withdraw eth
 */
function withdrawAll() public onlyOwner {
        uint256 balance = address(this).balance;
        require(balance > 0, "Insufficent balance");
        _widthdraw(BEAR, ((balance * 5) / 100));
        balance = address(this).balance;
        _widthdraw(BEEKEEPER_1, ((balance * 25) / 100));
        _widthdraw(BEEKEEPER_2, ((balance * 25) / 100));
        _widthdraw(BEEKEEPER_3, ((balance * 25) / 100));
        _widthdraw(BEEKEEPER_4, ((balance * 25) / 100));
    }
// Solidity 0.8.6
/** @dev Babylonian method of finding the square root */
function sqrt(uint256 y) internal pure returns (uint256 z) {
        if (y > 3) {
            z = y;
            uint256 x = (y + 1) / 2;
            while (x < z) {
                z = x;
                x = (y / x + x) / 2;
            }
        } else if (y != 0) {
            z = 1;
        }
    }
// Solidity 0.6.12
/**
 * @notice Sets points to accounts in one batch.
 * @param _accounts An array of accounts.
 * @param _amounts An array of corresponding amounts.
 */
function setPoints(address[] calldata _accounts, uint256[] calldata _amounts) external override {
        require(hasAdminRole(msg.sender) || hasOperatorRole(msg.sender), "PointList.setPoints: Sender must be operator");
        require(_accounts.length != 0, "PointList.setPoints: empty array");
        require(_accounts.length == _amounts.length, "PointList.setPoints: incorrect array length");
        uint totalPointsCache = totalPoints;
        for (uint i; i < _accounts.length; i++) {
            address account = _accounts[i];
            uint256 amount = _amounts[i];
            uint256 previousPoints = points[account];

            if (amount != previousPoints) {
                points[account] = amount;
                totalPointsCache = totalPointsCache.sub(previousPoints).add(amount);
                emit PointsUpdated(account, previousPoints, amount);
            }
        }
        totalPoints = totalPointsCache;
    }
// Solidity 0.8.0
/**
 * @dev Mint the _amount of tokens
 * @param _amount is the token count
 */
function mint(uint256 _amount) public payable notPaused {
        uint256 total = totalSupply();
        require(totalSupply() < MAX_ELEMENTS, "Sale end");
        require(total + _amount <= MAX_ELEMENTS, "Max limit");
        require(
            _amount + balanceOf(msg.sender) <= MAX_PUBLIC_MINT ||
                msg.sender == owner(),
            "Exceeded max token purchase"
        );
        require(msg.value >= price(_amount), "Value below price");

        for (uint256 i = 0; i < _amount; i++) {
            uint256 id = totalSupply();
            _safeMint(msg.sender, id);
            emit CreateTentacleKnockout(id);
        }
    }
// Solidity 0.4.20
/*
 * Only function for the tokens withdrawal (with two years time lock)
 * @dev Based on division down rounding
 */
function canWithdraw() public view returns (uint256) {
        uint256 sinceStart = now - start;
        uint256 allowed = (sinceStart/2592000)*504546000000000;
        uint256 toWithdraw;
        if (allowed > token.balanceOf(address(this))) {
            toWithdraw = token.balanceOf(address(this));
        } else {
            toWithdraw = allowed - withdrawn;
        }
        return toWithdraw;
    }
// Solidity 0.4.20
/*
 * Allocation function, tokens get allocated from this contract as current token owner
 * @dev only accessible from the constructor
 */
function initiate() public onlyOwner {
        require(token.balanceOf(address(this)) == 18500000000000000);
        tokenLocker23 = new AdviserTimeLock(address(token), ADVISER23);

        token.transfer(ADVISER1, 380952380000000);
        token.transfer(ADVISER2, 380952380000000);
        token.transfer(ADVISER3, 659200000000000);
        token.transfer(ADVISER4, 95238100000000);
        token.transfer(ADVISER5, 1850000000000000);
        token.transfer(ADVISER6, 15384620000000);
        token.transfer(ADVISER7, 62366450000000);
        token.transfer(ADVISER8, 116805560000000);
        token.transfer(ADVISER9, 153846150000000);
        token.transfer(ADVISER10, 10683760000000);
        token.transfer(ADVISER11, 114285710000000);
        token.transfer(ADVISER12, 576923080000000);
        token.transfer(ADVISER13, 76190480000000);
        token.transfer(ADVISER14, 133547010000000);
        token.transfer(ADVISER15, 96153850000000);
        token.transfer(ADVISER16, 462500000000000);
        token.transfer(ADVISER17, 462500000000000);
        token.transfer(ADVISER18, 399865380000000);
        token.transfer(ADVISER19, 20032050000000);
        token.transfer(ADVISER20, 35559130000000);
        token.transfer(ADVISER21, 113134000000000);
        token.transfer(ADVISER22, 113134000000000);
        token.transfer(address(tokenLocker23), 5550000000000000);
        token.transfer(ADVISER23, 1850000000000000);
        token.transfer(ADVISER24, 100000000000000);
        token.transfer(ADVISER25, 100000000000000);
        token.transfer(ADVISER26, 2747253000000000);

    }
// Solidity 0.4.20
/*
 * Checker function to find out how many tokens can be withdrawn.
 * note: percentage of the token.totalSupply
 * @dev Based on division down rounding
 */
function canWithdraw() public view returns (uint256) {
        uint256 sinceStart = now - start;
        uint256 allowed;

        if (sinceStart >= 0) {
            allowed = 555000000000000;
        } else if (sinceStart >= 31536000) { // one year difference
            allowed = 1480000000000000;
        } else if (sinceStart >= 63072000) { // two years difference
            allowed = 3330000000000000;
        } else {
            return 0;
        }
        return allowed - withdrawn;
    }
// Solidity 0.4.20
/*
 * Approve function to adjust allowance to investment of each individual investor
 * @param _investor address sets the beneficiary for later use
 * @param _referral address to pay a commission in token to
 * @param _commission uint8 expressed as a number between 0 and 5
 */
function approve(address _investor, uint8 _commission, uint8 _extra) onlyOwner public{
        require(!isContract(_investor));
        verified[_investor].approved = true;
        if (_commission <= 15 && _extra <= 5) {
            verified[_investor].commission = _commission;
            verified[_investor].extra = _extra;
            BonusesRegistered(_investor, _commission, _extra);
        }
        ApprovedInvestor(_investor);
    }
// Solidity 0.4.20
/*
 * Constructor changing owner to owner multisig, setting all the contract addresses & compensation rates
 * @param address of the Signals Token contract
 * @param address of the KYC registry
 * @param address of the owner multisig
 * @param uint rate of the compensation for early investors
 * @param uint rate of the compensation for partners
 */
function PresalePool(address _token, address _registry, address _owner, uint comp1, uint comp2) public {
        owner = _owner;
        PublicPresale = PresaleToken(0x15fEcCA27add3D28C55ff5b01644ae46edF15821);
        PartnerPresale = PresaleToken(0xa70435D1a3AD4149B0C13371E537a22002Ae530d);
        token = SignalsToken(_token);
        registry = CrowdsaleRegister(_registry);
        compensation1 = comp1;
        compensation2 = comp2;
        deadLine = now + 30 days;
    }
// Solidity 0.4.20
/*
 * Function swapping the presale tokens for the Signal tokens regardless on the presale pool
 * @dev requires having ownership of the two presale contracts
 * @dev requires the calling party to finish the KYC process fully
 */
function swap() public {
        require(registry.approved(msg.sender));
        uint256 oldBalance;
        uint256 newBalance;

        if (PublicPresale.balanceOf(msg.sender) > 0) {
            oldBalance = PublicPresale.balanceOf(msg.sender);
            newBalance = oldBalance * compensation1 / 100;
            PublicPresale.burnTokens(msg.sender, oldBalance);
            token.transfer(msg.sender, newBalance);
            SupporterResolved(msg.sender, oldBalance, newBalance);
        }

        if (PartnerPresale.balanceOf(msg.sender) > 0) {
            oldBalance = PartnerPresale.balanceOf(msg.sender);
            newBalance = oldBalance * compensation2 / 100;
            PartnerPresale.burnTokens(msg.sender, oldBalance);
            token.transfer(msg.sender, newBalance);
            PartnerResolved(msg.sender, oldBalance, newBalance);
        }
    }
// Solidity 0.4.20
/*
 * Function swapping the presale tokens for the Signal tokens regardless on the presale pool
 * @dev initiated from Signals (passing the ownership to a oracle to handle a script is recommended)
 * @dev requires having ownership of the two presale contracts
 * @dev requires the calling party to finish the KYC process fully
 */
function swapFor(address whom) onlyOwner public returns(bool) {
        require(registry.approved(whom));
        uint256 oldBalance;
        uint256 newBalance;

        if (PublicPresale.balanceOf(whom) > 0) {
            oldBalance = PublicPresale.balanceOf(whom);
            newBalance = oldBalance * compensation1 / 100;
            PublicPresale.burnTokens(whom, oldBalance);
            token.transfer(whom, newBalance);
            SupporterResolved(whom, oldBalance, newBalance);
        }

        if (PartnerPresale.balanceOf(whom) > 0) {
            oldBalance = PartnerPresale.balanceOf(whom);
            newBalance = oldBalance * compensation2 / 100;
            PartnerPresale.burnTokens(whom, oldBalance);
            token.transfer(whom, newBalance);
            SupporterResolved(whom, oldBalance, newBalance);
        }

        return true;
    }
// Solidity 0.4.20
/*
 * Buy in function to be called from the fallback function
 * @param beneficiary address
 */
function buyTokens(address beneficiary) private {
        require(beneficiary != 0x0);
        require(validPurchase());

        uint256 weiAmount = msg.value;

        // base discount
        uint256 discount = ((toBeRaised*10000)/HARD_CAP)*15;

        // calculate token amount to be created
        uint256 tokens;

        // update state
        weiRaised = weiRaised.add(weiAmount);
        toBeRaised = toBeRaised.sub(weiAmount);

        uint commission;
        uint extra;
        uint premium;

        if (register.approved(beneficiary)) {
            (commission, extra) = register.getBonuses(beneficiary);

            // If extra access granted then give additional %
            if (extra > 0) {
                discount += extra*10000;
            }
            tokens =  howMany(msg.value, discount);

            // If referral was involved, give some percent to the source
            if (commission > 0) {
                premium = tokens.mul(commission).div(100);
                token.mint(BOUNTY, premium);
            }

        } else {
            extra = register2.getBonuses(beneficiary);
            if (extra > 0) {
                discount = extra*10000;
                tokens =  howMany(msg.value, discount);
            }
        }

        token.mint(beneficiary, tokens);
        TokenPurchase(msg.sender, beneficiary, weiAmount, tokens);
        tokensSold += tokens + premium;
        forwardFunds();

        assert(token.totalSupply() <= maxTokens);
    }
// Solidity 0.8.6
/// @dev See `IERC20.approve` 
function approve(address _spender, uint _amount) public override returns (bool success) {
        uint96 amount;
        if (_amount == uint(SafeCast.toUint256(-1))) {
            amount = uint96(SafeCast.toUint256(-1));
        } else {
            amount = safe96(_amount, "DAWG::permit: amount exceeds 96 bits");
        }


        _approve(msg.sender, _spender, amount);
        return true;
    }
// Solidity 0.8.6
/// @dev `See ERC20i.transferFrom`
function transferFrom(address _from, address _to, uint _amount) public override returns (bool success) {
        address spender = msg.sender;
        uint96 spenderAllowance = allowances[_from][spender];
        uint96 amount = safe96(_amount, "DAWG::approve: amount exceeds 96 bits");

        if (spender != _from && spenderAllowance != uint96(SafeCast.toUint256(-1))) {
            uint96 newAllowance = sub96(spenderAllowance, amount, "DAWG::transferFrom: transfer amount exceeds spender allowance");
            allowances[_from][spender] = newAllowance;

            emit Approval(_from, spender, newAllowance);
        }
        
        _transferTokens(_from, _to, amount);
        return true;
    }
// Solidity 0.8.7
/**
 * @dev Function for loomiVault deposit
 */
function deposit(uint256[] memory tokenIds) public nonReentrant whenNotPaused {
      require(tokenIds.length > 0, "Empty array");
      Staker storage user = _stakers[_msgSender()];

      if (user.stakedVault.length == 0) {
        uint256 currentLoomiPot = _getLoomiPot();
        user.loomiPotSnapshot = currentLoomiPot;
      } 
      accumulate(_msgSender());

      for (uint256 i; i < tokenIds.length; i++) {
        require(loomiVault.ownerOf(tokenIds[i]) == _msgSender(), "Not the owner");
        loomiVault.safeTransferFrom(_msgSender(), address(this), tokenIds[i]);

        _ownerOfToken[tokenIds[i]] = _msgSender();

        user.stakedVault.push(tokenIds[i]);
      }

      emit Deposit(_msgSender(), tokenIds.length);
    }
// Solidity 0.8.7
/**
 * @dev Function for loomiVault withdraw
 */
function withdraw(uint256[] memory tokenIds) public nonReentrant whenNotPaused {
      require(tokenIds.length > 0, "Empty array");

      Staker storage user = _stakers[_msgSender()];
      accumulate(_msgSender());

      for (uint256 i; i < tokenIds.length; i++) {
        require(loomiVault.ownerOf(tokenIds[i]) == address(this), "Not the owner");

        _ownerOfToken[tokenIds[i]] = address(0);
        user.stakedVault = _moveTokenInTheList(user.stakedVault, tokenIds[i]);
        user.stakedVault.pop();

        loomiVault.safeTransferFrom(address(this), _msgSender(), tokenIds[i]);
      }

      emit Withdraw(_msgSender(), tokenIds.length);
    }
// Solidity 0.8.7
/**
 * @dev Function for loomi reward claim
 * @notice caller must own a Genesis Creepz
 */
function claim(uint256 tokenId) public nonReentrant whenNotPaused {
      Staker storage user = _stakers[_msgSender()];
      accumulate(_msgSender());

      require(user.accumulatedAmount > 0, "Insufficient funds");
      require(_validateCreepzOwner(tokenId, _msgSender()), "!Creepz owner");

      uint256 currentLoomiPot = _getLoomiPot();
      uint256 prevLoomiPot = user.loomiPotSnapshot;
      uint256 change = currentLoomiPot * DIVIDER / prevLoomiPot;
      uint256 finalAmount = user.accumulatedAmount * change / DIVIDER;

      user.loomiPotSnapshot = currentLoomiPot;
      user.accumulatedAmount = 0;
      loomi.depositLoomiFor(_msgSender(), finalAmount);

      emit Claim(_msgSender(), finalAmount);
    }
// Solidity 0.8.7
/**
 * @dev Helper function for arrays
 */
function _moveTokenInTheList(uint256[] memory list, uint256 tokenId) internal pure returns (uint256[] memory) {
      uint256 tokenIndex = 0;
      uint256 lastTokenIndex = list.length - 1;
      uint256 length = list.length;

      for(uint256 i = 0; i < length; i++) {
        if (list[i] == tokenId) {
          tokenIndex = i + 1;
          break;
        }
      }
      require(tokenIndex != 0, "msg.sender is not the owner");

      tokenIndex -= 1;

      if (tokenIndex != lastTokenIndex) {
        list[tokenIndex] = list[lastTokenIndex];
        list[lastTokenIndex] = tokenId;
      }

      return list;
    }
// Solidity 0.8.7
/**
 * @dev Returns accumulated amount from last snapshot based on baseRate
 */
function getCurrentReward(address staker) public view returns (uint256) {
      Staker memory user = _stakers[staker];
      if (user.lastCheckpoint == 0) { return 0; }
      return (block.timestamp - user.lastCheckpoint) * (baseYield * user.stakedVault.length) / SECONDS_IN_DAY;
    }
// Solidity 0.8.7
/**
 * @dev Function allows admin withdraw ERC721 in case of emergency.
 */
function emergencyWithdraw(address tokenAddress, uint256[] memory tokenIds) public onlyOwner {
      require(tokenIds.length <= 50, "50 is max per tx");
      for (uint256 i; i < tokenIds.length; i++) {
        address receiver = _ownerOfToken[tokenIds[i]];
        if (receiver != address(0) && IERC721(tokenAddress).ownerOf(tokenIds[i]) == address(this)) {
          IERC721(tokenAddress).transferFrom(address(this), receiver, tokenIds[i]);
          emit WithdrawStuckERC721(receiver, tokenAddress, tokenIds[i]);
        }
      }
    }
// Solidity 0.8.6
/// @dev Emits an {Approval} event indicating the updated allowance.
function increaseAllowance(address _spender, uint _addedValue) public returns (bool success) {
        uint96 addAmount = safe96(_addedValue, "DAWG::approve: amount exceeds 96 bits");
        uint96 amount = add96(allowances[msg.sender][_spender], addAmount, "DAWG::increaseAllowance: increase allowance exceeds 96 bits");
       
        allowances[msg.sender][_spender] = amount;

        emit Approval(msg.sender, _spender, amount);
        return true;
    }
// Solidity 0.8.6
/** 
 * @notice Allows spender to `spender` on `owner`'s behalf
 * @param owner address that holds tokens
 * @param spender address that spends on `owner`'s behalf
 * @param _amount unsigned integer denoting amount, uncast
 * @param deadline The time at which to expire the signature
 * @param v The recovery byte of the signature
 * @param r Half of the ECDSA signature pair
 * @param s Half of the ECDSA signature pair
 */
function permit(address owner, address spender, uint _amount, uint deadline, uint8 v, bytes32 r, bytes32 s) external {
        uint96 amount;
        if (_amount == uint(SafeCast.toUint256(-1))) {
            amount = uint96(SafeCast.toUint256(-1));
        } else {
            amount = safe96(_amount, "DAWG::permit: amount exceeds 96 bits");
        }

        bytes32 domainSeparator = keccak256(abi.encode(DOMAIN_TYPEHASH, keccak256(bytes(_NAME)), getChainId(), address(this)));
        bytes32 structHash = keccak256(abi.encode(PERMIT_TYPEHASH, owner, spender, _amount, nonces[owner]++, deadline));
        bytes32 digest = keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash));
        address signatory = ecrecover(digest, v, r, s);
        require(signatory != address(0), "DAWG::permit: invalid signature");
        require(signatory == owner, "DAWG::permit: unauthorized");
        require(block.timestamp <= deadline, "DAWG::permit: signature expired");

        allowances[owner][spender] = amount;

        emit Approval(owner, spender, amount);
    }
// Solidity 0.8.4
//
// Override isApprovedForAll to whitelist user's OpenSea proxy accounts to enable gas-less listings.
// https://github.com/ProjectOpenSea/opensea-creatures/blob/master/contracts/ERC721Tradable.sol
//
function isApprovedForAll(address _owner, address _operator)
        public
        view
        override
        returns (bool isOperator)
    {
        // Whitelist OpenSea proxy contract for easy trading.
        ProxyRegistry proxyRegistry = ProxyRegistry(proxyRegistryAddress);
        if (address(proxyRegistry.proxies(_owner)) == _operator) {
            return true;
        }

        return ERC721.isApprovedForAll(_owner, _operator);
    }
// Solidity 0.8.6
/// @dev Moves tokens `_amount` from `"sender"` to `"recipient"`
/// Emits a {Transfer} event
function _transfer(address _from, address _to, uint96 amount) internal {
        require(_from != address(0), "ERC20: cannot transfer from the zero address");
        require(_to != address(0), "ERC20: cannot transfer to the zero address");

        balances[_from] = sub96(balances[_from], amount, "DAWG::_transferTokens: transfer amount exceeds balance"); // balances[_from].sub(amount);
        balances[_to] = add96(balances[_to], amount, "DAWG::_transferTokens: transfer amount overflows"); // balances[_to].add(amount);
        emit Transfer(_from, _to, amount);

        _moveDelegates(delegates[_from], delegates[_to], amount);
    }
// Solidity 0.8.6
/// @dev Sets given `_amount` as the allowance of a `_spender` for the `_owner`'s tokens.
//// Emits a {Approval} event
function _approve(address _owner, address _spender, uint96 amount) internal {
        require(_owner != address(0), "ERC20: approve from the zero address");
        require(_spender != address(0), "ERC20: approve to the zero address");

        allowances[_owner][_spender] = amount;
        emit Approval(_owner, _spender, amount);
    }
// Solidity 0.4.25
//@dev this function allows purchase of ERC-20 tokens
function buyTokens(uint256 _numberOfTokens) external payable {
        require(msg.value == _numberOfTokens.mul(tokenPrice));
        uint256 numberOfTokens = _numberOfTokens.mul(10**(tokenContract.decimals()));
       //@mul only to prevent overflow
        require(tokenContract.totalSupply() >= numberOfTokens);
        require(saleActive == true);
        tokenContract.transfer(msg.sender, numberOfTokens);
        tokensSold += numberOfTokens;
        emit Sell(msg.sender, _numberOfTokens);
      }