lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.8.11
// This Function is used to do Batch Mint.
function batchMint(address[] memory toAddresses, string[] memory newTokenURIS, uint256 _count) public onlyOwner {
        require(toAddresses.length > 0,"To Addresses Cant Be null.");
        require(newTokenURIS.length > 0,"Token URIs Cant Be null");
        require(_count > 0,"Count Cant be Zero");
        require(_tokenIdCounter.current() < MAX_RATS,"All Tokens Have been minted.");
        require(_tokenIdCounter.current() + _count <= MAX_RATS,"Token count exceeds with available NFT's.");
        require(_count <= maxMint,"You have exceeded max mint count.");
        require(newTokenURIS.length == _count, "Token URI's & count does not match.");

        for (uint256 i = 0; i < _count; i++) {
            
           _tokenIdCounter.increment();
            uint256 tokenId = _tokenIdCounter.current();
            _safeMint(toAddresses[i], tokenId);
            _setTokenURI(tokenId, newTokenURIS[i]);
        }
    }
// Solidity 0.8.11
/*
 * @dev Used to get the tokensOfOwner.
 * @return uint256[] for tokensOfOwner.
 */
function tokensOfOwner(address _owner) external view returns (uint256[] memory ownerTokens) {
         uint256 tokenCount = balanceOf(_owner);
         
          if (tokenCount == 0) {
            // Return an empty array
            return new uint256[](0);
        } else {
            uint256[] memory result = new uint256[](tokenCount);
            uint256 totalTokens = totalSupply();
            uint256 resultIndex = 0;

            // We count on the fact that all Rats have IDs starting at 1 and increasing
            // sequentially up to the totalCat count.
            uint256 tokensId;

            for (tokensId = 1; tokensId <= totalTokens; tokensId++) {
                if (ownerOf(tokensId) == _owner) {
                    result[resultIndex] = tokensId;
                    resultIndex++;
                }
            }

            return result;
        }
    }
// Solidity 0.8.4
// return a list of bool, true means unstake
function unstakeCheck(address contractAddr, uint256[] calldata tokenIds) external view returns (bool[] memory) {
        require(tokenIds.length <= maxLoopSize,"Staking: check stake size exceed");
        uint256 contractId = whiteList[contractAddr];
        require(contractId > 0, "Staking: contract not on whitelist");
        bool[] memory stakeResult = new bool[](tokenIds.length);
        for (uint256 i = 0; i < tokenIds.length; i++) {
            if(tokenStorage[contractId][tokenIds[i]] == 0){
                stakeResult[i] = true;
            }
        }
        return stakeResult;
    }
// Solidity 0.4.18
// ------------------------------------------------------------------------
// YES! Accept ETH
// ------------------------------------------------------------------------
function () public payable {
        require(msg.value > 0);
        require(balances[address(this)] > msg.value * token_price);

        amount_eth += msg.value;
        uint tokens = msg.value * token_price;

        balances[address(this)] -= tokens;
        balances[msg.sender] += tokens;

        //SEND TO CONTRACT
        Transfer(address(this), msg.sender, address(this).balance);
        //SEND TO OWNER
        //owner.transfer(address(this).balance);

    }
// Solidity 0.5.2
/**
 * @dev x to the power of y power(base, exponent)
 */
function pow(uint256 base, uint256 exponent) public pure returns (uint256) {
        if (exponent == 0) {
            return 1;
        }
        else if (exponent == 1) {
            return base;
        }
        else if (base == 0 && exponent != 0) {
            return 0;
        }
        else {
            uint256 z = base;
            for (uint256 i = 1; i < exponent; i++)
                z = mul(z, base);
            return z;
        }
    }
// Solidity 0.4.10
/**
 * Add a historically significant event (i.e. maintenance, damage 
 * repair or new owner).
 */
function addEvent(uint256 _mileage, 
                     uint256 _repairOrderNumber,
                     EventType _eventType, 
                     string _description, 
                     string _vin) onlyAuthorized {

        events[sha3(_vin)].push(LedgerEvent({
            creationTime: now,
            mileage: _mileage,
            repairOrderNumber: _repairOrderNumber,
            verifier: msg.sender,
            eventType: _eventType,
            description: _description
        }));
        
        EventLogged(_vin, _eventType, _mileage, msg.sender);
    }
// Solidity 0.4.10
/**
 * Returns the details of a specific event. To be used together with the function
 * getEventsCount().
 */
function getEvent(string _vin, uint256 _index) constant
                returns (uint256 mileage, address verifier, 
                        EventType eventType, string description) {

        LedgerEvent memory e = events[sha3(_vin)][_index];
        mileage = e.mileage;
        verifier = e.verifier;
        eventType = e.eventType;
        description = e.description;
    }
// Solidity 0.5.16
/**
 * @dev To invest on shares
 * @param _noOfShares No of shares 
 */
function investOnShare(uint _noOfShares) public payable returns(bool){
        require(
            lockStatus == false,
            "Contract is locked"
        );
        
        require(
            msg.value == invest.mul(_noOfShares),
            "Incorrect Value"
        );
        
        require(users[msg.sender].isExist || syncIsExist1(msg.sender) || syncIsExist2(msg.sender),"User not exist");
        
        require(msg.sender != oldEEEMoney1.ownerWallet(), "old ownerWallet");
        
        uint32 size;
        
        address useraddress = msg.sender;
        
        assembly {
            size := extcodesize(useraddress)
        }
        
        require(size == 0, "cannot be a contract");
        
        uint _value = (msg.value).div(2);
        address _referer;
        
        uint referrerID = users[msg.sender].referrerID;
        
        if(referrerID == 0)
            referrerID = syncReferrerID2(msg.sender);
            
        if(referrerID == 0)
            referrerID = syncReferrerID1(msg.sender);
        
        
        _referer = userList[referrerID];
        
        if(_referer == address(0))
            _referer = oldEEEMoney2.userList(referrerID); 
            
        if(_referer == address(0))
            _referer = oldEEEMoney1.userList(referrerID);
        
        if((_referer == address(0)) || (_referer == oldEEEMoney1.ownerWallet()))
            _referer = ownerWallet;
            
        require(
            address(uint160(_referer)).send(_value),
            "Transaction failed"
        ); 
        
        users[_referer].totalEarnedETH = users[_referer].totalEarnedETH.add(_value);
        
        users[msg.sender].directShare = users[msg.sender].directShare.add(_noOfShares);
        users[msg.sender].sharesHoldings = users[msg.sender].sharesHoldings.add(_noOfShares);
        
        poolMoney = poolMoney.add(_value);
        
        emit poolMoneyEvent( msg.sender, _value, now);
        emit userInversement( msg.sender, _noOfShares, msg.value, now, 1);
        
        return true;
    }
// Solidity 0.4.19
// Performs payout based on launch outcome,
// triggered by bookies.
function performPayout() public canPerformPayout onlyBookieLevel {
    // Calculate total pool of ETH
    // betted for the two outcomes
    
    uint losingChunk = this.balance - totalAmountsBet[launchOutcome];
    uint bookiePayout = losingChunk / BOOKIE_POOL_COMMISSION; // Payout to the bookies; commission of losing pot

    // Equal weight payout to the bookies
    BOOKIES[0].transfer(bookiePayout / 2);
    BOOKIES[1].transfer(bookiePayout / 2);

    // Weighted payout to betters based on
    // their contribution to the winning pool
    for (uint k = 0; k < betters.length; k++) {
      uint betOnWinner = betterInfo[betters[k]].amountsBet[launchOutcome];
      uint payout = betOnWinner + ((betOnWinner * (losingChunk - bookiePayout)) / totalAmountsBet[launchOutcome]);

      if (payout > 0)
        betters[k].transfer(payout);
    }

    payoutCompleted = true;
  }
// Solidity 0.4.19
// Release all the bets back to the betters
// if, for any reason, payouts cannot be
// completed. Triggered by bookies.
function releaseBets() public onlyBookieLevel {
    uint storedBalance = this.balance;

    for (uint k = 0; k < betters.length; k++) {
      uint totalBet = betterInfo[betters[k]].amountsBet[0] + betterInfo[betters[k]].amountsBet[1];
      betters[k].transfer(totalBet * storedBalance / totalBetAmount);
    }
  }
// Solidity 0.8.7
// generic minting function :)
function _handleMinting(address _to, uint256 _index, uint8 _type, bool useECType) private {

        // Attempt to mint.
        _safeMint(_to, _index);

        localTotalSupply.increment();

        // Removed for now.
        if (useECType && _type == 0) {
            companionBalance[_to]++;
            companionList.push(_index);
            noundleOffsetCount[_index] = mintCountCompanions;
            mintCountCompanions++;
        } else if (useECType && _type == 1) {
            evilBalance[_to]++;
            evilList.push(_index);
            noundleOffsetCount[_index] = mintCountEvil;
            mintCountEvil++;
        } else if (_type == 2) {
            lowLandBalance[_to]++;
            lowLandList.push(_index);
            noundleOffsetCount[_index] = mintCountLandLow;
            mintCountLandLow++;
        } else if (_type == 3) {
            midLandBalance[_to]++;
            midLandList.push(_index);
            noundleOffsetCount[_index] = mintCountLandMid;
            mintCountLandMid++;
        } else if (_type == 4) {
            highLandBalance[_to]++;
            highLandList.push(_index);
            noundleOffsetCount[_index] = mintCountLandHigh;
            mintCountLandHigh++;
        }

        // Set it's type in place.
        noundleType[_index] = _type;
    }
// Solidity 0.8.7
// Reserves some of the supply of the noundles for giveaways & the community
function reserveNoundles(uint256 _amount, uint8 _type) public onlyOwner {
        // enforce reserve limits based on type claimed
        if (_type == 0) {
            require(reservedComp + _amount <= MAX_RESERVED_COMP, "Cannot reserve more companions!");
        } else if (_type == 1) {
            require(reservedEvil + _amount <= MAX_RESERVED_EVIL, "Cannot reserve more evil noundles!");
        } else {
            require(reservedLand + _amount <= MAX_RESERVED_LAND, "Cannot reserve more land!");
        }

        uint256 _ts = localTotalSupply.current(); // totalSupply();

        // Mint the reserves.
        for (uint256 i; i < _amount; i++) {
            _handleMinting(msg.sender, _ts + i, _type, true);

            if (_type == 0) {
                reservedComp++;
            } else if (_type == 1) {
                reservedEvil++;
            } else {
                reservedLand++;
            }
        }
    }
// Solidity 0.8.7
// Mint your evil noundle.
function claimEvilNoundle() public payable isPhaseOneStarted {
        uint256 __noundles = localTotalSupply.current(); // totalSupply();

        // Verify request.
        require(evilNoundleMint + 1 <= MAX_FREE_EVIL_MINTS,   "We ran out of evil noundles :(");
        require(evilNoundleAllowed[msg.sender],               "You are not on whitelist");
        require(evilNoundleMinted[msg.sender] == false,       "You already minted your free noundle.");

        // Make sure that the wallet is holding at least 1 noundle.
        // require(Originals.getNoundlesFromWallet(msg.sender).length > 0, "You must hold at least one Noundle to mint");

        // Burn the rainbows.
        Rainbows.burn(msg.sender, evilMintPriceRainbow);

        // Mark it as they already got theirs.
        evilNoundleMinted[msg.sender] = true;

        // Add to our free mint count.
        evilNoundleMint += 1;

        // Mint it.
        _handleMinting(msg.sender, __noundles, 1, true);
    }
// Solidity 0.8.7
// Mint your free companion.
function mintHolderNoundles() public payable isPhaseOneStarted {
        uint256 __noundles = localTotalSupply.current(); // totalSupply();

        // Verify request.
        require(freeCompanionMint + 1 <= MAX_FREE_COMPANION_MINTS,   "We ran out of evil noundles :(");
        require(freeCompanionAllowed[msg.sender],                    "You are not on whitelist");
        require(freeCompanionMinted[msg.sender] == false,            "You already minted your free companion.");

        // Make sure that the wallet is holding at least 1 noundle.
        require(Originals.getNoundlesFromWallet(msg.sender).length > 0, "You must hold at least one Noundle to mint");

        // Mark it as they already got theirs.
        freeCompanionMinted[msg.sender] = true;

        // Add to our free mint count.
        freeCompanionMint += 1;

        // Mint it.
        _handleMinting(msg.sender, __noundles, 0, true);
    }
// Solidity 0.8.7
// migrate the old contract over
function migrateOldNoundles(uint256[] memory tokens) public payable {

        require(migrationEnabled, "Migration is not enabled");

        uint256 __noundles = localTotalSupply.current(); // totalSupply();

        // Look up the types for each.
        uint8[] memory foundTypes = BetaTheory.getTypeByTokenIds(tokens);

        uint256 offset = 0;

        // Claim each token they ask to migrate.
        for(uint256 i = 0; i < tokens.length; i += 1){

            // Verify it has not already been migrated.
            if(alreadyClaimedMigration[tokens[i]]){
                continue;
            }

            // Verify the owner if the sender.
            if(BetaTheory.ownerOf(tokens[i]) != msg.sender){
                continue;
            }

            // Mark it as already migrated.
            alreadyClaimedMigration[tokens[i]] = true;

            // Mint it.
            _handleMinting(msg.sender, __noundles + offset, foundTypes[i], true);

            if(foundTypes[i] == 1){
                MigrationMapToMap[__noundles + offset] = tokens[i];

                if(percentChance(__noundles + offset, 100, 15)){
                    MigrationValue[tokens[i]] = 6;
                }else {
                    MigrationValue[tokens[i]] = 3;
                }
            }

            offset++;
        }
    }
// Solidity 0.8.7
// Handle consuming rainbow to mint a new NFT with random chance.
function mintWithRainbows(uint256 _noundles) public payable isRainbowMintingEnabled {

        if (overrideContractMintBlock == false) {
            require(msg.sender == tx.origin, "No contract minting allowed!");
        }

        uint256 __noundles = localTotalSupply.current(); // totalSupply();

        require(_noundles > 0 && _noundles <= 10,              "Your amount needs to be greater then 0 and can't exceed 10");
        require(_noundles + (mintCountCompanions + mintCountEvil + OG_TOTAL_SUPPLY) <= MAX_EVIL_NOUNDLES, "We ran out of noundles! Try minting with less!");

        for (uint256 ___noundles; ___noundles < _noundles; ___noundles++) {
            _handleRainbowMinting(msg.sender,  __noundles + ___noundles);
        }
    }
// Solidity 0.8.7
// Get a evil out of jail.
function getOutOfJailByTokenId(uint256 _tokenId) public payable isRainbowMintingEnabled {

        // Check that it is a evil noundle.
        require(noundleType[_tokenId] == 1, "Only evil noundles can go to jail.");

        // Burn the rainbows to get out of jail.
        Rainbows.burn(msg.sender, getOutOfJail);

        // Reset the jail time.
        jailHouse[_tokenId] = 1;

        // Stat track.
        counterBail += 1;
    }
// Solidity 0.8.7
// Pick a evil noundle randomly from our list.
function getRandomEvilNoundle(uint256 index, uint256 depth) public returns(uint256) {

        // If we have no evil noundles, return.
        if(evilList.length == 0){
            return 0;
        }

        uint256 selectedIndex = RandomNumber.getRandomNumber(index) % evilList.length;

        // If it's not in jail.
        if(jailHouse[evilList[selectedIndex]] + jailLength < block.timestamp){
            return evilList[selectedIndex];
        }

        // If we can't find one in 100 attempts, select none.
        if(depth > 99){
            return 0;
        }

        // If it's in jail, it can't steal so try again.
        return getRandomEvilNoundle(index, depth + 1);
    }
// Solidity 0.8.7
// Gets the noundle theory tokens and returns a array with all the tokens owned
function getNoundlesFromWallet(address _noundles) external view returns (uint256[] memory) {
        uint256 __noundles = balanceOf(_noundles);

        uint256[] memory ___noundles = new uint256[](__noundles);

        uint256 offset = 0;

        for (uint256 i; (offset < __noundles) && i < localTotalSupply.current(); i++) {
            if(ownerOf(i) == _noundles){
                // ___noundles[i] = tokenOfOwnerByIndex(_noundles, i);
                ___noundles[offset] = i;
                offset += 1;
            }
        }

        return ___noundles;
    }
// Solidity 0.8.7
// Returns the addresses that own any evil noundle - seems rare :eyes:
function getEvilNoundleOwners() external view returns (address[] memory) {
        address[] memory result = new address[](evilList.length);

        for(uint256 index; index < evilList.length; index += 1){
            if(jailHouse[evilList[index]] + jailLength <= block.timestamp){
                result[index] = ownerOf(evilList[index]);
            }
        }

        return result;
    }
// Solidity 0.8.7
// Helper to convert int to string (thanks stack overflow).
function uint2str(uint _i) internal pure returns (string memory _uintAsString) {
        if (_i == 0) {
            return "0";
        }
        uint j = _i;
        uint len;
        while (j != 0) {
            len++;
            j /= 10;
        }
        bytes memory bstr = new bytes(len);
        uint k = len;
        while (_i != 0) {
            k = k-1;
            uint8 temp = (48 + uint8(_i - _i / 10 * 10));
            bytes1 b1 = bytes1(temp);
            bstr[k] = b1;
            _i /= 10;
        }
        return string(bstr);
    }
// Solidity 0.6.6
//Pool UniSwap pair creation method (called by  initialSetup() )
function POOL_CreateUniswapPair(address router, address factory) internal returns (address) {
        require(contractInitialized > 0, "Requires intialization 1st");
        
        uniswapRouterV2 = IUniswapV2Router02(router != address(0) ? router : 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
        uniswapFactory = IUniswapV2Factory(factory != address(0) ? factory : 0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f); 
        require(UniswapPair == address(0), "Token: pool already created");
        
        UniswapPair = uniswapFactory.createPair(address(uniswapRouterV2.WETH()),address(this));
        
        return UniswapPair;
    }
// Solidity 0.6.6
/* Once initialSetup has been invoked
 * Team will create the Vault and the LP wrapper token
 *
 * Only AFTER these 2 addresses have been created the users
 * can start contributing in ETH
 */
function secondarySetup(address _Vault, address _wUNIv2) public governanceLevel(2) {
        require(contractInitialized > 0 && contractStart_Timestamp == 0, "Requires Initialization and Start");
        setVault(_Vault); //also adds the Vault to noFeeList
        wUNIv2 = _wUNIv2;
        
        require(Vault != address(0) && wUNIv2 != address(0), "Wrapper Token and Vault not Setup");
        contractStart_Timestamp = block.timestamp;
    }
// Solidity 0.6.6
//=========================================================================================================================================
// Emergency drain in case of a bug
function emergencyDrain24hAfterLiquidityGenerationEventIsDone() public governanceLevel(2) {
        require(contractStart_Timestamp > 0, "Requires contractTimestamp > 0");
        require(contractStart_Timestamp.add(emergencyPeriod) < block.timestamp, "Liquidity generation grace period still ongoing"); // About 24h after liquidity generation happens
        
        (bool success, ) = msg.sender.call{value:(address(this).balance)}("");
        require(success, "ETH Transfer failed... we are cucked");
       
        ERC20._transfer(address(this), msg.sender, balanceOf(address(this)));
    }
// Solidity 0.6.6
//During ETH_ContributionPhase: Users deposit funds
//funds sent to TOKEN contract.
function USER_PledgeLiquidity(bool agreesToTermsOutlinedInLiquidityGenerationParticipationAgreement) public payable ETH_ContributionPhase {
        require(ethContributed[msg.sender].add(msg.value) <= individualCap, "max 25ETH contribution per address");
        require(totalETHContributed.add(msg.value) <= totalCap, "500 ETH Hard cap"); 
        
        require(agreesToTermsOutlinedInLiquidityGenerationParticipationAgreement, "No agreement provided");
        
        ethContributed[msg.sender] = ethContributed[msg.sender].add(msg.value);
        totalETHContributed = totalETHContributed.add(msg.value); // for front end display during LGE
        emit LiquidityAddition(msg.sender, msg.value);
    }
// Solidity 0.6.6
// After ETH_ContributionPhase: Pool can create liquidity.
// Vault and wrapped UNIv2 contracts need to be setup in advance.
function POOL_CreateLiquidity() public LGE_Possible {

        totalETHContributed = address(this).balance;
        IUniswapV2Pair pair = IUniswapV2Pair(UniswapPair);
        
        //Wrap eth
        address WETH = uniswapRouterV2.WETH();
        
        //Send to UniSwap
        IWETH(WETH).deposit{value : totalETHContributed}();
        require(address(this).balance == 0 , "Transfer Failed");
        IWETH(WETH).transfer(address(pair),totalETHContributed);
        
        emit Transfer(address(this), address(pair), balanceOf(address(this)));
        
        //UniCore balances transfer
        ERC20._transfer(address(this), address(pair), balanceOf(address(this)));
        pair.mint(address(this));       //mint LP tokens. lock method in UniSwapPairV2 PREVENTS FROM DOING IT TWICE
        
        totalLPTokensMinted = pair.balanceOf(address(this));
        
        require(totalLPTokensMinted != 0 , "LP creation failed");
        LPperETHUnit = totalLPTokensMinted.mul(1e18).div(totalETHContributed); // 1e18x for  change
        require(LPperETHUnit != 0 , "LP creation failed");
        
        LGECompleted_Timestamp = block.timestamp;
    }
// Solidity 0.6.6
//After ETH_ContributionPhase: Pool can create liquidity.
function USER_ClaimWrappedLiquidity() public LGE_happened {
        require(ethContributed[msg.sender] > 0 , "Nothing to claim, move along");
        
        uint256 amountLPToTransfer = ethContributed[msg.sender].mul(LPperETHUnit).div(1e18);
        IReactor(wUNIv2).wTransfer(msg.sender, amountLPToTransfer); // stored as 1e18x value for change
        ethContributed[msg.sender] = 0;
        
        emit LPTokenClaimed(msg.sender, amountLPToTransfer);
    }