lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.8.7
/// ============ Functions ============
/// @notice Allows claiming tokens if address is part of merkle tree
/// @param to address of claimee
/// @param amount of tokens owed to claimee
/// @param proof merkle proof to prove address and amount are in tree
function claim(address to, uint256 amount, bytes32[] calldata proof) external {
    // Throw if address has already claimed tokens
    if (hasClaimed[to]) revert AlreadyClaimed();

    // Verify merkle proof, or revert if not in tree
    bytes32 leaf = keccak256(abi.encodePacked(to, amount));
    bool isValidLeaf = MerkleProof.verify(proof, merkleRoot, leaf);
    if (!isValidLeaf) revert NotInMerkle();

    // Throw if the contract doesn't hold enough tokens for claimee
    if (amount > token.balanceOf(address(this))) revert notEnoughRewards();

    // Set address to claimed
    hasClaimed[to] = true;

    // Award tokens to address
    token.transfer(to, amount);

    // Emit claim event
    emit Claim(to, amount);
  }
// Solidity 0.4.24
// @notice Contributors can retrieve their funds here if crowdsale has paased deadline
// @param (address) _assetAddress =  The address of the asset which didn't reach it's crowdfunding goals
function refund(address _assetAddress)
  public
  whenNotPaused
  validAsset(_assetAddress)
  afterDeadline(_assetAddress)
  notFinalized(_assetAddress)
  returns (bool) {
    require(database.uintStorage(keccak256(abi.encodePacked("crowdsale.deadline", _assetAddress))) != 0);
    database.deleteUint(keccak256(abi.encodePacked("crowdsale.deadline", _assetAddress)));
    DividendInterface assetToken = DividendInterface(_assetAddress);
    address tokenAddress = assetToken.getERC20();
    uint refundValue = assetToken.totalSupply().mul(uint(100).add(database.uintStorage(keccak256(abi.encodePacked("platform.fee"))))).div(100); //total supply plus platform fees
    reserve.refundERC20Asset(_assetAddress, refundValue, tokenAddress);
    return true;
  }
// Solidity 0.8.0
//if true, degen can't call their debt
function isDebtorHealthy() public view returns (bool) {
        int256 months = monthsAhead();
        bool moreThanMonthBehind = months <= -1;
        if (months == 0) {
            //accounts for being at least 1 day overdue
            int256 arrears =
                int256(expectedPayments()) -
                    int256(agreementState.accumulatedRepayments);
            moreThanMonthBehind = arrears > 0;
        }
        return !moreThanMonthBehind;
    }
// Solidity 0.8.0
//positive number means Justin has more than met his requirement. Negative means he's in arrears
function expectedAccumulated() public view returns (uint256, uint256) {
        uint256 expected = expectedPayments();

        if (expected > agreementState.accumulatedRepayments) {
            //Justin is behind

            return (expected, agreementState.accumulatedRepayments);
        } else {
            //Justin is ahead

            return (expected, agreementState.accumulatedRepayments);
        }
    }
// Solidity 0.8.0
//in the event of a critical bug, shutdown contract and withdraw EYE.
function voteForEmergencyShutdown(bool vote) public {
        if (msg.sender == users.Justin) {
            emergencyShutdownMultisig[EMERGENCY_SHUTDOWN_JUSTIN_INDEX] = vote;
        } else if (msg.sender == users.DGVC) {
            emergencyShutdownMultisig[EMERGENCY_SHUTDOWN_DEGEN_INDEX] = vote;
        }

        if (emergencyShutdownMultisig[0] && emergencyShutdownMultisig[1]) {
            agreementState.phase = AgreementPhaseEnum.emergencyShutdown;
            IERC20 eye = IERC20(tokens.EYE);
            uint256 balance = eye.balanceOf(address(this));
            eye.transfer(users.DGVC, balance);
        }
    }
// Solidity 0.4.18
/// @dev Constructor
/// @param _token SilentNotary token contract address
/// @param _teamWallet Wallet address to withdraw unfrozen tokens
/// @param _freezePeriods Ordered array of freeze periods
/// @param _freezePortions Ordered array of balance portions to freeze, in percents
function SilentNotaryTokenStorage (address _token, address _teamWallet, uint[] _freezePeriods, uint[] _freezePortions) public {
    require(_token > 0);
    require(_teamWallet > 0);
    require(_freezePeriods.length > 0);
    require(_freezePeriods.length == _freezePortions.length);

    token = ERC20(_token);
    teamWallet = _teamWallet;
    deployedTime = now;

    var cumulativeTime = deployedTime;
    uint cumulativePercent = 0;
    for (uint i = 0; i < _freezePeriods.length; i++) {
      require(_freezePortions[i] > 0 && _freezePortions[i] <= 100);
      cumulativePercent = safeAdd(cumulativePercent, _freezePortions[i]);
      cumulativeTime = safeAdd(cumulativeTime, _freezePeriods[i]);
      frozenPortions.push(FrozenPortion({
        portionPercent: _freezePortions[i],
        unfreezeTime: cumulativeTime,
        portionAmount: 0,
        isUnfrozen: false}));
    }
    assert(cumulativePercent == 100);
  }
// Solidity 0.4.18
/// @dev Unfreeze currently available amount of tokens
function unfreeze() public onlyOwner {
    require(amountFixed);

    uint unfrozenTokens = 0;
    for (uint i = 0; i < frozenPortions.length; i++) {
      var portion = frozenPortions[i];
      if (portion.isUnfrozen)
        continue;
      if (portion.unfreezeTime < now) {
        unfrozenTokens = safeAdd(unfrozenTokens, portion.portionAmount);
        portion.isUnfrozen = true;
      }
      else
        break;
    }
    transferTokens(unfrozenTokens);
  }
// Solidity 0.4.18
/// @dev Fix current token amount (calculate absolute values of every portion)
function fixAmount() public onlyOwner {
    require(!amountFixed);
    amountFixed = true;

    uint currentBalance = token.balanceOf(this);
    for (uint i = 0; i < frozenPortions.length; i++) {
      var portion = frozenPortions[i];
      portion.portionAmount = safeDiv(safeMul(currentBalance, portion.portionPercent), 100);
    }
  }
// Solidity 0.4.24
/// @dev Deposit BBO.
function depositBBO() payable {
        require(depositStartTime > 0);
        require(msg.value == 0);
        require(now >= depositStartTime && now <= depositStopTime);
        
        ERC20 bboToken = ERC20(bboTokenAddress);
        uint bboAmount = bboToken
            .balanceOf(msg.sender)
            .min256(bboToken.allowance(msg.sender, address(this)));

        if(bboAmount > 0){
            require(bboToken.transferFrom(msg.sender, address(this), bboAmount));
            Record storage record = records[msg.sender];
            record.bboAmount = record.bboAmount.add(bboAmount);
            record.timestamp = now;
            records[msg.sender] = record;

            bboDeposited = bboDeposited.add(bboAmount);
            emit Deposit(depositId++, msg.sender, bboAmount);
        }
    }
// Solidity 0.4.24
/// @dev Withdrawal BBO.
function withdrawBBO() payable {
        require(depositStartTime > 0);
        require(bboDeposited > 0);

        Record storage record = records[msg.sender];
        require(now >= record.timestamp + WITHDRAWAL_DELAY);
        require(record.bboAmount > 0);

        uint bboWithdrawalBase = record.bboAmount;
        if (msg.value > 0) {
            bboWithdrawalBase = bboWithdrawalBase
                .min256(msg.value.mul(WITHDRAWAL_SCALE));
        }

        uint bboBonus = getBonus(bboWithdrawalBase);
        uint balance = bboBalance();
        uint bboAmount = balance.min256(bboWithdrawalBase + bboBonus);
        
        bboDeposited = bboDeposited.sub(bboWithdrawalBase);
        record.bboAmount = record.bboAmount.sub(bboWithdrawalBase);

        if (record.bboAmount == 0) {
            delete records[msg.sender];
        } else {
            records[msg.sender] = record;
        }

        emit Withdrawal(withdrawId++, msg.sender, bboAmount);

        require(ERC20(bboTokenAddress).transfer(msg.sender, bboAmount));
        if (msg.value > 0) {
            msg.sender.transfer(msg.value);
        }
    }
// Solidity 0.7.6
//////////
/// @notice Get the list of whitelisted addresses
/// @return The list of whitelisted addresses
function getWhitelisted() external view returns(address[] memory) {
        uint256 length = _whitelisted.length();
        address[] memory result = new address[](length);

        for (uint256 i=0; i < length; i++) {
            result[i] = _whitelisted.at(i);
        }

        return result;
    }
// Solidity 0.7.6
/// @notice Get fee (In basis points) to pay by a given user, for a given fee type
/// @param _user The address for which to calculate the fee
/// @param _hasReferrer Whether the address has a referrer or not
/// @param _feeType The type of fee
/// @return The protocol fee to pay by _user (In basis points)
function getFee(address _user, bool _hasReferrer, FeeType _feeType) public view returns(uint256) {
        if (_whitelisted.contains(_user)) return 0;

        uint256 fee = _getBaseFee(_feeType);

        // If premiaFeeDiscount contract is set, we calculate discount
        if (address(premiaFeeDiscount) != address(0)) {
            uint256 discount = premiaFeeDiscount.getDiscount(_user);
            fee = fee.mul(discount).div(_inverseBasisPoint);
        }

        if (_hasReferrer) {
            fee = fee.mul(_inverseBasisPoint.sub(referredDiscount)).div(_inverseBasisPoint);
        }

        return fee;
    }
// Solidity 0.7.6
/// @notice Calculate protocol fee and referrer fee to pay, from a total fee (in wei), after applying all discounts
/// @param _user The address for which to calculate the fee
/// @param _hasReferrer Whether the address has a referrer or not
/// @param _baseFee The total fee to pay (without including any discount)
/// @return _fee Fee amount to pay to protocol
/// @return _feeReferrer Fee amount to pay to referrer
function getFeeAmountsWithDiscount(address _user, bool _hasReferrer, uint256 _baseFee) public view returns(uint256 _fee, uint256 _feeReferrer) {
        if (_whitelisted.contains(_user)) return (0,0);

        uint256 feeReferrer = 0;
        uint256 feeDiscount = 0;

        // If premiaFeeDiscount contract is set, we calculate discount
        if (address(premiaFeeDiscount) != address(0)) {
            uint256 discount = premiaFeeDiscount.getDiscount(_user);
            require(discount <= _inverseBasisPoint, "Discount > max");
            feeDiscount = _baseFee.mul(discount).div(_inverseBasisPoint);
        }

        if (_hasReferrer) {
            // feeDiscount = feeDiscount + ( (_feeAmountBase - feeDiscount ) * referredDiscountRate)
            feeDiscount = feeDiscount.add(_baseFee.sub(feeDiscount).mul(referredDiscount).div(_inverseBasisPoint));
            feeReferrer = _baseFee.sub(feeDiscount).mul(referrerFee).div(_inverseBasisPoint);
        }

        return (_baseFee.sub(feeDiscount).sub(feeReferrer), feeReferrer);
    }
// Solidity 0.7.6
//////////////
/// @notice Get the base protocol fee, for a given fee type
/// @param _feeType The type of fee
/// @return The base protocol fee for _feeType (In basis points)
function _getBaseFee(FeeType _feeType) internal view returns(uint256) {
        if (_feeType == FeeType.Write) {
            return writeFee;
        } else if (_feeType == FeeType.Exercise) {
            return exerciseFee;
        } else if (_feeType == FeeType.Maker) {
            return makerFee;
        } else if (_feeType == FeeType.Taker) {
            return takerFee;
        } else if (_feeType == FeeType.FlashLoan) {
            return flashLoanFee;
        }

        return 0;
    }
// Solidity 0.4.13
//Storage of addresses is broken into smaller contracts.
function importAddresses(address[] parentsArray,address[] childrenArray)	{
	if (numImports<maxImports)	{
		numImports++;
		addressesImported(msg.sender,childrenArray.length,numImports); //Details of import
		balanceOf[0x000000000000000000000000000000000000dEaD]=numImports*initialSupplyPerChildAddress; //Easy way for people to check numImports without debugger after launch.
		for (uint i=0;i<childrenArray.length;i++)   {
				address child=childrenArray[i];
				address parent=parentsArray[i];
				parentAddress[parent]=true;
				returnChildAddressForParent[parent]=child;
				balanceOf[child]=initialSupplyPerChildAddress;
		}
	}
}
// Solidity 0.5.16
/***************************************
 ADMIN
 ****************************************/
function notifyRewardAmount(uint256 _reward)
        external
        onlyRewardsDistributor
        updateReward(address(0))
    {
        uint256 currentTime = block.timestamp;
        // If previous period over, reset rewardRate
        if (currentTime >= periodFinish) {
            rewardRate = _reward.div(farmingDuration);
        }
        // If additional reward to existing period, calc sum
        else {
            uint256 remaining = periodFinish.sub(currentTime);
            uint256 leftover = remaining.mul(rewardRate);
            rewardRate = _reward.add(leftover).div(farmingDuration);
        }

        lastUpdateTime = currentTime;
        periodFinish = currentTime.add(farmingDuration);

        emit RewardAdded(_reward);
    }
// Solidity 0.6.12
// validates a proof-of-work for a given NFT, with a supplied nonce
// at a given difficulty level
function work(
        uint256 id, uint256 nonce, uint8 difficulty
    ) public view returns (bool) {
        bytes32 candidate = _firstn(
            keccak256(abi.encodePacked(address(this), id, nonce)),
            difficulty
        );
        bytes32 target = _firstn(
            bytes32(uint256(address(this)) << 96),
            difficulty
        );
        return (candidate == target);
    }
// Solidity 0.8.0
/**
 * @dev Returns a token IDs array owned by `owner`.
 */
function tokensByOwner(address owner) external view returns (uint256[] memory) {
      if (balanceOf(owner) == 0) {
        return new uint256[](0);
      }

      uint256 tokensOwned = 0;
      uint256 idIndex = 0;
      for(uint i = 1; i <= currentSupply; i++) {
        if (ownerOf(i) == owner) {
          tokensOwned++;
        }
      }

      uint256[] memory ids = new uint256[](tokensOwned);
      for(uint i = 1; i <= currentSupply; i++) {
        if (ownerOf(i) == owner) {
          ids[idIndex] = i;
          idIndex++;
        }
      }

      return ids;
    }
// Solidity 0.8.10
// UniV2 / SLP Info
function uniV2LPBasicInfo(address pair_address) public view returns (UniV2LPBasicInfo memory) {
        // Instantiate the pair
        IUniswapV2Pair the_pair = IUniswapV2Pair(pair_address);

        // Get the reserves
        (uint256 reserve0, uint256 reserve1, ) = (the_pair.getReserves());

        // Get the token1 address
        address token0 = the_pair.token0();
        address token1 = the_pair.token1();

        // Return
        return UniV2LPBasicInfo(
            pair_address, // [0]
            the_pair.name(), // [1]
            the_pair.symbol(), // [2]
            token0, // [3]
            token1, // [4]
            ERC20(token0).decimals(), // [5]
            ERC20(token1).decimals(), // [6]
            reserve0, // [7]
            reserve1, // [8]
            the_pair.totalSupply() // [9]
        );
    }
// Solidity 0.8.2
// ( 4 * 5 * (86400000) ) / 1 days;
function update(address from, address to) external onlyAllowed {
        if (from != address(0)) {
            rewards[from] += getPending(from);
            lastClaimDatetime[from] = block.timestamp;
        }
        if (to != address(0)) {
            rewards[to] += getPending(to);
            lastClaimDatetime[to] = block.timestamp;
        }
    }
// Solidity 0.6.12
// View function to see pending ERC20s for a user.
function pending(uint256 _pid, address _user) external view returns (uint256) {
        PoolInfo storage pool = poolInfo[_pid];
        UserInfo storage user = userInfo[_pid][_user];
        uint256 accERC20PerShare = pool.accERC20PerShare;
        uint256 lpSupply = pool.lpToken.balanceOf(address(this));

        if (block.number > pool.lastRewardBlock && lpSupply != 0) {
            uint256 lastBlock = block.number < endBlock ? block.number : endBlock;
            uint256 nrOfBlocks = lastBlock.sub(pool.lastRewardBlock);
            uint256 erc20Reward = nrOfBlocks.mul(rewardPerBlock).mul(pool.allocPoint).div(totalAllocPoint);
            accERC20PerShare = accERC20PerShare.add(erc20Reward.mul(1e36).div(lpSupply));
        }

        return user.amount.mul(accERC20PerShare).div(1e36).sub(user.rewardDebt);
    }
// Solidity 0.6.12
// Deposit LP tokens to Farm for ERC20 allocation.
function deposit(uint256 _pid, uint256 _amount) public {
        PoolInfo storage pool = poolInfo[_pid];
        UserInfo storage user = userInfo[_pid][msg.sender];
        updatePool(_pid);
        if (user.amount > 0) {
            uint256 pendingAmount = user.amount.mul(pool.accERC20PerShare).div(1e36).sub(user.rewardDebt);
            erc20Transfer(msg.sender, pendingAmount);
        }
        pool.lpToken.safeTransferFrom(address(msg.sender), address(this), _amount);
        user.amount = user.amount.add(_amount);
        user.rewardDebt = user.amount.mul(pool.accERC20PerShare).div(1e36);
        emit Deposit(msg.sender, _pid, _amount);
    }
// Solidity 0.6.12
// Withdraw LP tokens from Farm.
function withdraw(uint256 _pid, uint256 _amount) public {
        PoolInfo storage pool = poolInfo[_pid];
        UserInfo storage user = userInfo[_pid][msg.sender];
        require(user.amount >= _amount, "withdraw: can't withdraw more than deposit");
        updatePool(_pid);
        uint256 pendingAmount = user.amount.mul(pool.accERC20PerShare).div(1e36).sub(user.rewardDebt);
        erc20Transfer(msg.sender, pendingAmount);
        user.amount = user.amount.sub(_amount);
        user.rewardDebt = user.amount.mul(pool.accERC20PerShare).div(1e36);
        pool.lpToken.safeTransfer(address(msg.sender), _amount);
        emit Withdraw(msg.sender, _pid, _amount);
    }
// Solidity 0.4.26
// This is the constructor and automatically runs when the smart contract is uploaded
function FMT() { // Set the constructor to the same name as the contract name
    name = "FINGER MOBILE TOKEN"; // set the token name here
    symbol = "FMT"; // set the Symbol here
    decimals = 8; // set the number of decimals
    devAddress=0x6eC2f42d083F29e2cd19eC0e4d99A22B4a8A31cf; // Add the address that you will distribute tokens from here
    uint initialBalance=100000000*10000000000; // 1M tokens
    balances[devAddress]=initialBalance;
    totalSupply+=initialBalance; // Set the total suppy
}
// Solidity 0.4.24
/**
 * @dev Transfer tokens direct to recipient without allocation. 
 * _recipient can only get one transaction and _tokens can't be above maxDirect value
 *  
 */
function transferDirect(address _recipient,uint256 _tokens) public{

    //Check if contract has tokens
    require(token.balanceOf(this)>=_tokens);
    
    //Check max value
    require(_tokens < maxDirect );

    //Check if _recipient already have got tokens
    require(!recipients[_recipient]); 
    recipients[_recipient] = true;
  
    //Transfer tokens
    require(token.transfer(_recipient, _tokens));

    //Add claimed tokens to grandTotalClaimed
    grandTotalClaimed = grandTotalClaimed.add(_tokens); 
     
  }
// Solidity 0.8.1
/** 
 * Requests randomness from a user-provided seed
 */
function getRandomNumber(uint256 userProvidedSeed) public onlyDistributer returns (bytes32 requestId) {        
        require(LINK.balanceOf(address(this)) >= fee, "Not enough LINK - fill contract with faucet");
        require(!progress, "now getting an random number.");
        winner = 0;
        progress = true;
        return requestRandomness(keyHash, fee, userProvidedSeed);
    }
// Solidity 0.8.1
// Function to distribute punk.
function setPunkWinner() external onlyOwner {
        require(_prevRandomCallCount != _randomCallCount, "Please generate random number.");
        require(rnGenerator.getWinner() != 0, 'Please wait until random number generated.');
        require(_punkWinner == 6500, 'You already picked punk winner');

        _prevRandomCallCount = _randomCallCount;
        _punkWinner = rnGenerator.getWinner().mod(6400);
    }
// Solidity 0.8.1
// Function to distribute legendary monster.
function setLegendaryMonsterWinner() external onlyOwner {
        require(_prevRandomCallCount != _randomCallCount, "Please generate random number.");
        require(rnGenerator.getWinner() != 0, 'Please wait until random number generated.');
        
        _prevRandomCallCount = _randomCallCount;
        uint256 _tempWinner = rnGenerator.getWinner().mod(3884);
        for(uint i=0; i<_legendaryMonsterWinners.length; i++ ) {
            require(_legendaryMonsterWinners[i] != _tempWinner, 'Same winner already exists.');
        }
        _legendaryMonsterWinners.push(_tempWinner);
    }
// Solidity 0.8.1
// Function to distribute eth.
function setETHWinner() external onlyOwner {
        require(_prevRandomCallCount != _randomCallCount, "Please generate random number.");
        require(rnGenerator.getWinner() != 0, 'Please wait until random number generated.');
        
        _prevRandomCallCount = _randomCallCount;
        uint256 _tempWinner = rnGenerator.getWinner().mod(400) + 6000;
        for(uint i=0; i<_ethWinners.length; i++ ) {
            require(_ethWinners[i] != _tempWinner, 'Same winner already exists.');
        }
        _ethWinners.push(_tempWinner);
    }
// Solidity 0.8.1
// Function to distribute zed.
function setZedWinner() external onlyOwner {
        require(_prevRandomCallCount != _randomCallCount, "Please generate random number.");
        require(rnGenerator.getWinner() != 0, 'Please wait until random number generated.');
        
        _prevRandomCallCount = _randomCallCount;
        uint256 _tempWinner = rnGenerator.getWinner().mod(6400);
        for(uint i=0; i<_zedWinners.length; i++ ) {
            require(_zedWinners[i] != _tempWinner, 'Same winner already exists.');
        }
        _zedWinners.push(_tempWinner);
    }
// Solidity 0.8.6
// ======== Claim / Minting =========
function mintCommunity(uint amount) external nonReentrant {
        require(saleIsActive, "Sale must be active to claim!");
        require(block.timestamp >= communitySaleStart && block.timestamp < publicSaleStart, "Community sale not active!");
        require(amount > 0, "Enter valid amount to claim");
        require(amount <= addressToClaimableGods[msg.sender], "Invalid hero amount!");
        require(amount <= MAX_MINTS_PER_TX, "Exceeds max mint per tx!");

        godsToken.mint(amount, msg.sender);
        addressToClaimableGods[msg.sender] -= amount;
    }
// Solidity 0.8.6
// ======== Snapshot / Whitelisting
function snapshot(address[] memory _addresses, uint[] memory _godsToClaim) external onlyOwner {
        require(_addresses.length == _godsToClaim.length, "Invalid snapshot data");
        for (uint i = 0; i < _addresses.length; i++) {
            addressToClaimableGods[_addresses[i]] = _godsToClaim[i];
        }
    }
// Solidity 0.8.0
/**
 * return the sender of this call.
 * if the call came through our trusted forwarder, return the original sender.
 * otherwise, return `msg.sender`.
 * should be used in the contract anywhere instead of msg.sender
 */
function _msgSender() internal override virtual view returns (address payable ret) {
        if (msg.data.length >= 20 && isTrustedForwarder(msg.sender)) {
            // At this point we know that the sender is a trusted forwarder,
            // so we trust that the last bytes of msg.data are the verified sender address.
            // extract sender address from the end of msg.data
            assembly {
                ret := shr(96,calldataload(sub(calldatasize(),20)))
            }
        } else {
            return payable(msg.sender);
        }
    }