lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.6.12
// Split giveaways in each groups among participants pro-rata their orders amount.
// May throw with OUT_OF_GAS is there are too many participants.
function splitProrataAll(uint256 channelId, address token) external {
        uint256 len = groups.length;
        for (uint i = 0; i < len; i++) {
            if (i == 1) _splitForGoals(channelId, token, i);    // split among Investors with goal 
            else _splitProrata(channelId, token, i);
        }
    }
// Solidity 0.6.12
// Move user from one group to another
function _moveToGroup(address wallet, uint256 toGroup, bool allowUnpaid) internal {
        uint256 from = _getGroupId(wallet);
        require(from != toGroup, "Already in this group");
        inGroup[wallet] = toGroup + 1;  // change wallet's group id (1-based)
        // add to group wallets list
        groups[toGroup].wallets.add(wallet);
        // delete from previous group
        groups[from].wallets.remove(wallet);
        // recalculate groups OnSale
        // request number of channels from Gateway
        uint channels = _getChannelsNumber();
        for (uint i = 1; i < channels; i++) {   // exclude channel 0. It allow company to wire tokens for Gateway supply
            if (onSale[wallet][i] > 0) {
                require(groups[from].soldUnpaid[i] == 0 || allowUnpaid, "There is unpaid giveaways");
                groups[from].onSale[i] = safeSub(groups[from].onSale[i], onSale[wallet][i]);
                groups[toGroup].onSale[i] = safeAdd(groups[toGroup].onSale[i], onSale[wallet][i]);
                groups[from].addressesOnChannel[i].remove(wallet);
                groups[toGroup].addressesOnChannel[i].add(wallet);
            }
        }
    }
// Solidity 0.6.12
/**
 * @dev transfer token for a specified address into Escrow contract
 * @param to The address to transfer to.
 * @param value The amount to be transferred.
 */
function _transfer(address to, uint256 value) internal returns (bool) {
        _nonZeroAddress(to);
        require(balances[msg.sender] >= value, "Not enough balance");
        balances[msg.sender] = safeSub(balances[msg.sender], value);
        balances[to] = safeAdd(balances[to], value);
        emit Transfer(msg.sender, to, value);
        return true;
    }
// Solidity 0.6.12
// Create restricted order which require confirmation from third-party confirmatory address. For simple transfer the wantValue = 0.
function _restrictedOrder(uint256 sellValue, address wantToken, uint256 wantValue, address payable buyer, address confirmatory) internal {
        require(sellValue > 0, "Zero sell value");
        balances[msg.sender] = safeSub(balances[msg.sender], sellValue);
        uint256 orderId = orders.length;
        orders.push(Order(msg.sender, buyer, sellValue, wantToken, wantValue, 4, confirmatory));  //add restricted order
        emit RestrictedOrder(msg.sender, buyer, sellValue, wantToken, wantValue, orderId, confirmatory);
    }
// Solidity 0.5.11
/**
 * @dev Returns the main status.
 */
function status() public view returns (uint16 stage,
                                               uint16 season,
                                               uint256 etherUsdPrice,
                                               uint256 vokenUsdPrice,
                                               uint256 shareholdersRatio) {
            if (_stage > STAGE_MAX) {
                stage = STAGE_MAX;
                season = SEASON_MAX;
            }
            else {
                stage = _stage;
                season = _season;
            }

            etherUsdPrice = _etherUsdPrice;
            vokenUsdPrice = _vokenUsdPrice;
            shareholdersRatio = _shareholdersRatio;
        }
// Solidity 0.5.11
/**
 * @dev Returns the sum.
 */
function sum() public view returns(uint256 vokenIssued,
                                           uint256 vokenBonus,
                                           uint256 weiSold,
                                           uint256 weiRewarded,
                                           uint256 weiShareholders,
                                           uint256 weiTeam,
                                           uint256 weiPended) {
            vokenIssued = _vokenIssued;
            vokenBonus = _vokenBonus;

            weiSold = _weiSold;
            weiRewarded = _weiRewarded;
            weiShareholders = _weiShareholders;
            weiTeam = _weiTeam;
            weiPended = _weiPended;
        }
// Solidity 0.4.24
/**
 * @dev generates a random number between 0-99 and checks to see if thats
 * resulted in an airdrop win
 * @return do we have a winner?
 */
function airdrop()
        private
        view
        returns(bool)
    {
        uint256 seed = uint256(keccak256(abi.encodePacked(

            (block.timestamp).add
            (block.difficulty).add
            ((uint256(keccak256(abi.encodePacked(block.coinbase)))) / (now)).add
            (block.gaslimit).add
            ((uint256(keccak256(abi.encodePacked(msg.sender)))) / (now)).add
            (block.number)

        )));
        if((seed - ((seed / 1000) * 1000)) < airDropTracker_)
            return(true);
        else
            return(false);
    }
// Solidity 0.5.11
/**
 * @dev Returns the `account` data.
 */
function queryAccount(address account) public view returns (uint256 vokenIssued,
                                                                    uint256 vokenBonus,
                                                                    uint256 vokenReferral,
                                                                    uint256 vokenReferrals,
                                                                    uint256 weiPurchased,
                                                                    uint256 weiRewarded) {
            vokenIssued = _accountVokenIssued[account];
            vokenBonus = _accountVokenBonus[account];
            vokenReferral = _accountVokenReferral[account];
            vokenReferrals = _accountVokenReferrals[account];
            weiPurchased = _accountWeiPurchased[account];
            weiRewarded = _accountWeiRewarded[account];
        }
// Solidity 0.8.7
// Reserve some Vikings for the Team!
function reserveVikings() public onlyOwner {
        require(bytes(PROOF_OF_ANCESTRY).length > 0,                "No distributing Vikings until provenance is established.");
        require(!vikingsBroughtHome,                                "Only once, even for you Odin");
        require(totalSupply + FOR_THE_VAULT <= MAX_VIKINGS,         "You have missed your chance, Fishlord.");

        for (uint256 i = 0; i < FOR_THE_VAULT; i++) {
            _safeMint(vaultAddress, totalSupply + i);
        }

        totalSupply += FOR_THE_VAULT;
        presaleSupply += FOR_THE_VAULT;

        vikingsBroughtHome = true;
    }
// Solidity 0.8.7
// A freebie for you - Lucky you!
function luckyViking() public {
        require(luckyActive,                                            "A sale period must be active to claim");
        require(!claimedLuckers[msg.sender],                            "You have already claimed your Lucky Viking.");
        require(totalSupply + 1 <= MAX_VIKINGS,                         "Sorry, you're too late! All vikings have been claimed.");
        require(luckySupply + 1 <= MAX_LUCKY_VIKINGS,                   "Sorry, you're too late! All Lucky Vikings have been claimed.");

        _safeMint( msg.sender, totalSupply);
        totalSupply += 1;
        luckySupply += 1;
        presaleSupply += 1;

        claimedLuckers[msg.sender] = true;
    }
// Solidity 0.8.7
// Lets raid together, earlier than the others!!!!!!!!! LFG
function mintPresale(uint256 numberOfMints) public payable {
        require(presaleActive,                                      "Presale must be active to mint");
        require(totalSupply + numberOfMints <= MAX_VIKINGS,         "Purchase would exceed max supply of tokens");
        require(presaleSupply + numberOfMints <= MAX_PRESALE,       "We have to save some Vikings for the public sale - Presale: SOLD OUT!");
        require(PRESALE_PRICE * numberOfMints == msg.value,         "Ether value sent is not correct");

        for(uint256 i; i < numberOfMints; i++){
            _safeMint( msg.sender, totalSupply + i );
        }

        totalSupply += numberOfMints;
        presaleSupply += numberOfMints;
    }
// Solidity 0.5.11
/**
 * @dev Returns the stage data by `stageIndex`.
 */
function stage(uint16 stageIndex) public view returns (uint256 vokenUsdPrice,
                                                               uint256 shareholdersRatio,
                                                               uint256 vokenIssued,
                                                               uint256 vokenBonus,
                                                               uint256 vokenCap,
                                                               uint256 vokenOnSale,
                                                               uint256 usdSold,
                                                               uint256 usdCap,
                                                               uint256 usdOnSale) {
            if (stageIndex <= STAGE_LIMIT) {
                vokenUsdPrice = _calcVokenUsdPrice(stageIndex);
                shareholdersRatio = _calcShareholdersRatio(stageIndex);

                vokenIssued = _stageVokenIssued[stageIndex];
                vokenBonus = _stageVokenBonus[stageIndex];
                vokenCap = _stageVokenCap(stageIndex);
                vokenOnSale = vokenCap.sub(vokenIssued);

                usdSold = _stageUsdSold[stageIndex];
                usdCap = _stageUsdCap(stageIndex);
                usdOnSale = usdCap.sub(usdSold);
            }
        }
// Solidity 0.8.7
// ..and now for the rest of you
function mint(uint256 numberOfMints) public payable {
        require(saleActive,                                         "Sale must be active to mint");
        require(numberOfMints > 0 && numberOfMints < 6,             "Invalid purchase amount");
        require(totalSupply + numberOfMints <= MAX_VIKINGS,         "Purchase would exceed max supply of tokens");
        require(PRICE * numberOfMints == msg.value,                 "Ether value sent is not correct");

        for(uint256 i; i < numberOfMints; i++) {
            _safeMint(msg.sender, totalSupply + i);
        }

        totalSupply += numberOfMints;
    }
// Solidity 0.8.7
// This returns a psudo random number, used in conjunction with the not revealed URI
// it prevents all leaks and gaming of the system
function random() public returns (uint256 _pRandom) {
    uint256 pRandom = (uint256(keccak256(abi.encodePacked(block.difficulty, block.timestamp, totalSupply()))) % 997) + 1;
    for(uint256 i = 0; i <= 997; i++){
        if(!usedValues[pRandom]){
            usedValues[pRandom] = true;
            return pRandom;
        } else {
            pRandom--;
            if(pRandom == 0) {
                pRandom = 996;
            }
        }
    }
  }
// Solidity 0.8.0
/// @notice allow user to submit new bid
/// @param _nftAddress - address of the ERC721/ERC1155 token
/// @param _tokenid - ID of the token
/// @param _initialAppraisal - initial nft appraisal 
function newBid(address _nftAddress, uint _tokenid, uint _initialAppraisal) nonReentrant payable external {
        require(
            msg.value > highestBid[nonce]
            && auctionStatus
            && (session.nftNonce(_nftAddress,_tokenid) == 0 || session.getStatus(_nftAddress, _tokenid) == 5)
        );
        bidTime[msg.sender] = block.timestamp;
        highestBidder[nonce] = msg.sender;
        highestBid[nonce] = msg.value;
        tvl[msg.sender] -= userVote[nonce][msg.sender].bid;
        (bool sent, ) = payable(msg.sender).call{value: userVote[nonce][msg.sender].bid}("");
        require(sent);
        userVote[nonce][msg.sender].nftAddress = _nftAddress;
        userVote[nonce][msg.sender].tokenid = _tokenid;
        userVote[nonce][msg.sender].intitialAppraisal = _initialAppraisal;
        userVote[nonce][msg.sender].bid = msg.value;
        tvl[msg.sender] += msg.value;
        emit newBidSubmitted(msg.sender, msg.value, _nftAddress, _tokenid, _initialAppraisal);
    }
// Solidity 0.8.0
/// @notice triggered when auction ends, starts session for highest bidder
function endAuction() nonReentrant external {
        if(firstSession) {
            require(msg.sender == admin);
        }
        require(endTime[nonce] < block.timestamp && auctionStatus);
        treasury.sendABCToken(address(this), 0.005 ether * session.ethToAbc());
        session.createNewSession(
            userVote[nonce][highestBidder[nonce]].nftAddress, 
            userVote[nonce][highestBidder[nonce]].tokenid,
            userVote[nonce][highestBidder[nonce]].intitialAppraisal,
            86400
        );
        uint bountySend = userVote[nonce][highestBidder[nonce]].bid;
        userVote[nonce][highestBidder[nonce]].bid = 0;
        tvl[highestBidder[nonce]] -= bountySend;
        endTime[++nonce] = block.timestamp + 86400;
        (bool sent, ) = payable(session).call{value: bountySend}("");
        require(sent);
        emit auctionEnded(
            highestBidder[nonce], 
            userVote[nonce][highestBidder[nonce]].bid, 
            userVote[nonce][highestBidder[nonce]].nftAddress, 
            userVote[nonce][highestBidder[nonce]].tokenid, 
            userVote[nonce][highestBidder[nonce]].intitialAppraisal
        );
    }
// Solidity 0.5.11
/**
 * @dev Returns the season data by `seasonNumber`.
 */
function season(uint16 seasonNumber) public view returns (uint256 vokenIssued,
                                                                  uint256 vokenBonus,
                                                                  uint256 weiSold,
                                                                  uint256 weiRewarded,
                                                                  uint256 weiShareholders,
                                                                  uint256 weiPended) {
            if (seasonNumber <= SEASON_LIMIT) {
                vokenIssued = _seasonVokenIssued[seasonNumber];
                vokenBonus = _seasonVokenBonus[seasonNumber];

                weiSold = _seasonWeiSold[seasonNumber];
                weiRewarded = _seasonWeiRewarded[seasonNumber];
                weiShareholders = _seasonWeiShareholders[seasonNumber];
                weiPended = _seasonWeiPended[seasonNumber];
            }
        }
// Solidity 0.8.0
/// @notice allows users to claim non-employed funds
function claim() nonReentrant external {
        uint returnValue;
        if(highestBidder[nonce] != msg.sender) {
            returnValue = tvl[msg.sender];
            userVote[nonce][msg.sender].bid = 0;
        }
        else {
            returnValue = tvl[msg.sender] - userVote[nonce][msg.sender].bid;
        }
        tvl[msg.sender] -= returnValue;
        (bool sent, ) = payable(msg.sender).call{value: returnValue}("");
        require(sent);
    }
// Solidity 0.5.11
/**
 * @dev Returns the `account` data of #`seasonNumber` season.
 */
function accountInSeason(address account, uint16 seasonNumber) public view returns (uint256 vokenIssued,
                                                                                            uint256 vokenBonus,
                                                                                            uint256 vokenReferral,
                                                                                            uint256 vokenReferrals,
                                                                                            uint256 weiPurchased,
                                                                                            uint256 weiReferrals,
                                                                                            uint256 weiRewarded) {
            if (seasonNumber > 0 && seasonNumber <= SEASON_LIMIT) {
                vokenIssued = _vokenSeasonAccountIssued[seasonNumber][account];
                vokenBonus = _vokenSeasonAccountBonus[seasonNumber][account];
                vokenReferral = _vokenSeasonAccountReferral[seasonNumber][account];
                vokenReferrals = _vokenSeasonAccountReferrals[seasonNumber][account];
                weiPurchased = _weiSeasonAccountPurchased[seasonNumber][account];
                weiReferrals = _weiSeasonAccountReferrals[seasonNumber][account];
                weiRewarded = _weiSeasonAccountRewarded[seasonNumber][account];
            }
        }
// Solidity 0.5.11
/**
 * @dev Returns the season number by `stageIndex`.
 */
function _seasonNumber(uint16 stageIndex) private view returns (uint16) {
            if (stageIndex > 0) {
                uint16 __seasonNumber = stageIndex.div(SEASON_STAGES);

                if (stageIndex.mod(SEASON_STAGES) > 0) {
                    return __seasonNumber.add(1);
                }

                return __seasonNumber;
            }

            return 1;
        }
// Solidity 0.4.11
/// @notice Transfer `_value` SAT tokens from sender's account
/// `msg.sender` to provided account address `_to`.
/// @param _to The address of the tokens recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transfer(address _to, uint256 _value) public returns (bool) {
        // Abort if not in Operational state.
        if (!funding_ended) throw;
        if (msg.sender == founders) throw;
        var senderBalance = balances[msg.sender];
        if (senderBalance >= _value && _value > 0) {
            senderBalance -= _value;
            balances[msg.sender] = senderBalance;
            balances[_to] += _value;
            Transfer(msg.sender, _to, _value);
            return true;
        }
        return false;
    }
// Solidity 0.4.11
/// @notice Create tokens when funding is active.
/// @dev Required state: Funding Active
/// @dev State transition: -> Funding Success (only if cap reached)
function buy(address _sender) internal {
        // Abort if not in Funding Active state.
        if (funding_ended) throw;
        // The checking for blocktimes.
        if (block.number < fundingStartBlock) throw;
        if (block.number > fundingEndBlock) throw;

        // Do not allow creating 0 or more than the cap tokens.
        if (msg.value == 0) throw;

        var numTokens = msg.value * tokenCreationRate;
        totalTokens += numTokens;

        // Assign new tokens to the sender
        balances[_sender] += numTokens;

        // sending funds to founders
        founders.transfer(msg.value);

        // Log token creation event
        Transfer(0, _sender, numTokens);
    }
// Solidity 0.4.11
/// @notice Finalize crowdfunding
function finalize() external {
        if (block.number <= fundingEndBlock) throw;

        //locked allocation for founders 
        locked_allocation = totalTokens * 10 / 100;
        balances[founders] = locked_allocation;
        totalTokens += locked_allocation;
        
        unlockingBlock = block.number + 864000;   //about 6 months locked time.
        funding_ended = true;
    }
// Solidity 0.4.20
/*
 * Constructor which pauses the token at the time of creation
 */
function CryptomonToken(string tokenName, string tokenSymbol, uint8 decimalUnits) {
        name = tokenName;          // Set the name for display purposes
        symbol = tokenSymbol;      // Set the symbol for display purposes
        decimals = decimalUnits;   // Amount of decimals for display purposes

        pause();
    }
// Solidity 0.6.12
/**
 * @dev Mints debt token to the `onBehalfOf` address
 * -  Only callable by the LendingPool
 * @param user The address receiving the borrowed underlying, being the delegatee in case
 * of credit delegate, or same as `onBehalfOf` otherwise
 * @param onBehalfOf The address receiving the debt tokens
 * @param amount The amount of debt being minted
 * @param index The variable debt index of the reserve
 * @return `true` if the the previous balance of the user is 0
 **/
function mint(
    address user,
    address onBehalfOf,
    uint256 amount,
    uint256 index
  ) external override onlyLendingPool returns (bool) {
    if (user != onBehalfOf) {
      _decreaseBorrowAllowance(onBehalfOf, user, amount);
    }

    uint256 previousBalance = super.balanceOf(onBehalfOf);
    uint256 amountScaled = amount.rayDiv(index);
    require(amountScaled != 0, Errors.CT_INVALID_MINT_AMOUNT);

    _mint(onBehalfOf, amountScaled);

    emit Transfer(address(0), onBehalfOf, amount);
    emit Mint(user, onBehalfOf, amount, index);

    return previousBalance == 0;
  }
// Solidity 0.6.12
/**
 * @dev Burns user variable debt
 * - Only callable by the LendingPool
 * @param user The user whose debt is getting burned
 * @param amount The amount getting burned
 * @param index The variable debt index of the reserve
 **/
function burn(
    address user,
    uint256 amount,
    uint256 index
  ) external override onlyLendingPool {
    uint256 amountScaled = amount.rayDiv(index);
    require(amountScaled != 0, Errors.CT_INVALID_BURN_AMOUNT);

    _burn(user, amountScaled);

    emit Transfer(user, address(0), amount);
    emit Burn(user, amount, index);
  }