lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.8.0
/*
 * - `sender` cannot be the zero address.
 * - `recipient` cannot be the zero address.
 * - `sender` must have a balance of at least `amount`.
 */
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
        require(sender != address(0), "ERC20: transfer from the zero address");
        require(recipient != address(0), "ERC20: transfer to the zero address");
        uint256 senderBalance = _balances[sender];
        require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
        _balances[sender] = senderBalance - amount;
        _balances[recipient] += amount;

        emit Transfer(sender, recipient, amount);
    }
// Solidity 0.5.11
// Purchase tokens
function buyTokens(address beneficiary) public nonReentrant payable whenNotPaused {
    require(beneficiary != address(0));
    require(validPurchase());
    
    
    uint256 weiAmount = msg.value;
    uint256 returnWeiAmount;
    
    // calculate token amount to be created
    uint rate = getRate();
    assert(rate > 0);
    uint256 tokens = weiAmount.mul(rate);
    
    uint256 newsoldTokens = soldTokens.add(tokens);
    
    if (newsoldTokens > contractCap) {
      newsoldTokens = contractCap;
      tokens = contractCap.sub(soldTokens);
      uint256 newWeiAmount = tokens.div(rate);
      returnWeiAmount = weiAmount.sub(newWeiAmount);
      weiAmount = newWeiAmount;
    }
    
    // update state
    weiRaised = weiRaised.add(weiAmount);
    
    token.transfer(beneficiary, tokens);
    soldTokens = newsoldTokens;
    if (returnWeiAmount > 0){
      msg.sender.transfer(returnWeiAmount);
    }
    
    emit TokenPurchase(msg.sender, beneficiary, weiAmount, tokens);
    
    forwardFunds();
  }
// Solidity 0.6.2
/**
 * @dev Bootstrap the supply distribution and fund the UniswapV2 liquidity pool
 */
function bootstrap() external returns (bool){


      require(isBootStrapped == false, 'Require unintialized token');
      require(msg.sender == owner, 'Require ownership');

      //Distribute tokens
      uint256 premineAmount = 100000000 * (10 ** 18); //100 mil 
      uint256 marketingAmount = 1000000000 * (10 ** 18); // 1 bil for justin sun

      balances[marketingAccount] = marketingAmount;
      emit Transfer(address(0), marketingAccount, marketingAmount);


      for (uint256 i = 0; i < 15; i++) {
        balances[ambassadorList[i]] = premineAmount;
        emit Transfer(address(0), ambassadorList[i], balances[ambassadorList[i]]);
      }
      balances[owner] = _totalSupply.sub(marketingAmount + 15 * premineAmount);

      emit Transfer(address(0), owner, balances[owner]);

      isBootStrapped = true;

      return isBootStrapped;

  }
// Solidity 0.5.16
// the function is name differently to not cause inheritance clash in truffle and allows tests
function initializeVault(address _storage,
        address _underlying,
        uint256 _toInvestNumerator,
        uint256 _toInvestDenominator
    ) public initializer {
        require(_toInvestNumerator <= _toInvestDenominator, "cannot invest more than 100%");
        require(_toInvestDenominator != 0, "cannot divide by 0");

        ERC20Detailed.initialize(
        string(abi.encodePacked("DELTA_", ERC20Detailed(_underlying).symbol())),
        string(abi.encodePacked("d", ERC20Detailed(_underlying).symbol())),
        ERC20Detailed(_underlying).decimals()
        );
        ControllableInit.initialize(
        _storage
        );

        uint256 underlyingUnit = 10 ** uint256(ERC20Detailed(address(_underlying)).decimals());
        uint256 implementationDelay = 12 hours;
        uint256 strategyChangeDelay = 12 hours;
        VaultStorage.initialize(
        _underlying,
        _toInvestNumerator,
        _toInvestDenominator,
        underlyingUnit,
        implementationDelay,
        strategyChangeDelay
        );
    }
// Solidity 0.8.0
//Get the tokens that exist for this wallet
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.8.7
// if any applicable tokens are held by this contract, it should be able to deposit them
function _depositAssets ()
    internal {
        uint LPBalance = IERC20(liquidity).balanceOf(address(this));    // load LP balance into memory

        if(LPBalance > 0)                                               // are there any LP tokens?
            IStakingRewards(staking).deposit(LPBalance);             // deposit the entire amount into the StakingRewards contract

        uint krillBalance = IERC20(krill).balanceOf(address(this));      // load KRILL balance into memory

        if(krillBalance > 0 )                                           // is there any krill here dumped from another contract?
            ICompounder(cKrill).buy(krillBalance);                          // buy cKRILL with whatever balance is held
    }
// Solidity 0.8.7
// claim rewards from NFTs, staking, and cKRILL position
function _claimRewardsAndDisburse()
    internal {
        IClaimable(staking).claim();    // Claim rewards from the LP staking contract
        IClaimable(whalesGame).claim(); // Claim rewards from the whales game contract

        if(ICompounder(cKrill).dividendsOf(address(this)) > 0)      // If this contract has rewards to claim
            ICompounder(cKrill).withdraw();                         // Claim rewards from the cKRILL held by this contract

        uint krillBalance = IERC20(krill).balanceOf(address(this)); // load KRILL balance into memory
        
        if(krillBalance > 0)                                // is there any krill here dumped from another contract?
            IERC20(krill).burn(krillBalance);               // burn it all
    }
// Solidity 0.4.24
// Callback function, distribute tokens to sender when ETH donation is recieved
function () payable public {
        
        require(isLive);
        uint256 donation = msg.value;
        uint256 amountZNT = donation * rateOfZNT;
        uint256 amountZLT = donation * rateOfZLT;
        require(availableZNT >= amountZNT && availableZLT >= amountZLT);
        donationOf[msg.sender] += donation;
        amountEthRaised += donation;
        availableZNT -= amountZNT;
        availableZLT -= amountZLT;
        tokenZNT.transfer(msg.sender, amountZNT);
        tokenZLT.transfer(msg.sender, amountZLT);
        beneficiary.transfer(donation);
    }
// Solidity 0.4.24
/**
 * @dev Resets the player's current progress.
 */
function resetProgress()
        public
        returns (bool) {
            
            if (playerCurrentProgress[msg.sender] > 0) {
                
                playerCurrentProgress[msg.sender] = 0;
                
                playerAddressToBid[msg.sender] = 0;
                
                playerAddressToRollUnder[msg.sender] = 0;

                emit ResetProgress(
                    msg.sender, 
                    true
                );

                return true;
               
            } else {
                
                return false;
            }
            
        }
// Solidity 0.4.24
/**
 * @dev Calculates the payout based on roll under in Wei.
 */
function _calculatePayout(
        uint256 rollUnder,
        uint256 value)
        internal
        view
        isWithinLimits(value)
        returns (uint256) {
            
            require(rollUnder >= minRoll && rollUnder <= maxRoll, "invalid roll under number!");
            
            uint256 _totalPayout = 0 wei;
            
            _totalPayout = ((((value * (100-(SafeMath.sub(rollUnder,1)))) / (SafeMath.sub(rollUnder,1))+value))*platformCutPayout/platformCutPayoutDivisor)-value;
            
            return _totalPayout;
        }
// Solidity 0.4.18
/*  at initialization, setup the owner */
function WowanderICOPrivateCrowdSale(
        address addressOfTokenUsedAsReward,
		address addressOfBeneficiary
    ) public
    {
        beneficiary = addressOfBeneficiary;
        //startTime = 1516021200;
        startTime = 1516021200 - 3600 * 24; // TODO remove
        duration = 744 hours;
		tokensContractBalance =  5 * 0.1 finney;
        price = 0.000000000005 * 1 ether;
        discountPrice = 0.000000000005 * 1 ether * 0.9;
        tokenReward = WWWToken(addressOfTokenUsedAsReward);
    }
// Solidity 0.5.12
/**
 * @dev Transfer several token for a specified addresses
 * @param _to The array of addresses to transfer to.
 * @param _value The array of amounts to be transferred.
 */
function massTransfer(address[] memory _to, uint[] memory _value) public returns (bool){
        require(_to.length == _value.length, "You have different amount of addresses and amounts");

        uint len = _to.length;
        for(uint i = 0; i < len; i++){
            if(!_transfer(_to[i], _value[i])){
                return false;
            }
        }
        return true;
    }
// Solidity 0.5.12
/**
 * @dev Emit new tokens and transfer from 0 to client address. This function will generate 21.5% of tokens for management address as well.
 * @param _to The address to transfer to.
 * @param _value The amount to be transferred.
 */
function _mint(address _to, uint _value) private returns (bool){
        require(_to != address(0), "Receiver address cannot be null");
        require(_to != address(this), "Receiver address cannot be ITCM contract address");
        require(_value > 0 && _value <= leftToMint, "Looks like we are unable to mint such amount");

        // 21.5% of token amount to management address
        uint managementAmount = _value.mul(215).div(1000);
        
        leftToMint = leftToMint.sub(_value);
        totalSupply = totalSupply.add(_value);
        totalSupply = totalSupply.add(managementAmount);
        
        balances[_to] = balances[_to].add(_value);
        balances[managementProfitAddr] = balances[managementProfitAddr].add(managementAmount);

        emit Transfer(address(0), _to, _value);
        emit Transfer(address(0), managementProfitAddr, managementAmount);

        return true;
    }
// Solidity 0.5.12
/**
 * @dev This is wrapper for _mint.
 * @param _to The address to transfer to.
 * @param _value The amount to be transferred.
 */
function mint(address _to, uint _value) public returns (bool){
        require(msg.sender != address(0), "Sender address cannon be null");
        require(msg.sender == mintingAllowedForAddr || mintingAllowedForAddr == address(0) && msg.sender == contractCreator, "You are unavailable to mint tokens");

        return _mint(_to, _value);
    }
// Solidity 0.5.12
/**
 * @dev Similar to mint function but take array of addresses and values.
 * @param _to The addresses to transfer to.
 * @param _value The amounts to be transferred.
 */
function mint(address[] memory _to, uint[] memory _value) public returns (bool){
        require(_to.length == _value.length, "You have different amount of addresses and amounts");
        require(msg.sender != address(0), "Sender address cannon be null");
        require(msg.sender == mintingAllowedForAddr || mintingAllowedForAddr == address(0) && msg.sender == contractCreator, "You are unavailable to mint tokens");

        uint len = _to.length;
        for(uint i = 0; i < len; i++){
            if(!_mint(_to[i], _value[i])){
                return false;
            }
        }
        return true;
    }
// Solidity 0.5.12
/**
 * @dev Set a contract address that allowed to mint tokens.
 * @param _address The address of another contract.
 */
function setMintingContractAddress(address _address) public returns (bool){
        require(mintingAllowedForAddr == address(0) && msg.sender == contractCreator, "Only contract creator can set minting contract and only when it is not set");
        mintingAllowedForAddr = _address;
        return true;
    }
// Solidity 0.5.17
// Guards against integer overflows
function safeMultiply(uint256 a, uint256 b) internal pure returns (uint256) {
        if (a == 0) {
            return 0;
        } else {
            uint256 c = a * b;
            assert(c / a == b);
            return c;
        }
    }
// Solidity 0.5.0
/**
 * @dev this function will send the Team tokens to given address
 * @param _teamAddress ,address of the bounty receiver.
 * @param _value , number of tokens to be sent.
 */
function sendTeamTokens(address _teamAddress, uint256 _value) external whenNotPaused onlyOwner returns (bool) {

        require(teamTokens >= _value);
        totalReleased = totalReleased.add(_value);
        require(totalReleased <= totalSupply());
        teamTokens = teamTokens.sub(_value);
        teamTokenHolder[_teamAddress] = true;
        teamTokenInitially[_teamAddress] = teamTokenInitially[_teamAddress].add((_value.mul(95)).div(100));
        teamLockPeriodStart[_teamAddress] = now; 
        super._transfer(address(this),_teamAddress,(_value.mul(5)).div(100));
        return true;

   }
// Solidity 0.8.3
/**
 * @notice Mints the vault shares to the msg.sender
 * @param amount is the amount of `asset` deposited
 */
function _deposit(uint256 amount) private {
        uint256 totalWithDepositedAmount = totalBalance();

        // amount needs to be subtracted from totalBalance because it has already been
        // added to it from either IWETH.deposit and IERC20.safeTransferFrom
        uint256 total = totalWithDepositedAmount.sub(amount);

        uint256 shareSupply = totalSupply();

        // Following the pool share calculation from Alpha Homora:
        // solhint-disable-next-line
        // https://github.com/AlphaFinanceLab/alphahomora/blob/340653c8ac1e9b4f23d5b81e61307bf7d02a26e8/contracts/5/Bank.sol#L104
        uint256 share = shareSupply == 0
            ? amount
            : amount.mul(shareSupply).div(total);

        _mint(msg.sender, share);
    }
// Solidity 0.8.3
/**
 * @dev Get withdraw amount of shares value
 * @param shares How many shares will be exchanged
 */
function getWithdrawAmount(uint256 shares, address _addr)
        public
        view
        returns (uint256 amount)
    {
        uint256 PPS;

        //check if last user: cannot use shares, could be partial withdraw
        uint256 userShareBalance = balanceOf(_addr);

        if (userShareBalance == totalSupply()) {
            //last user
            PPS = getPricePerShare(currentRound);
        } else {
            PPS = getPricePerShare(currentRound.sub(1));
        }

        amount = (shares.mul(PPS)).div(ppsMultiplier);
    }
// Solidity 0.8.3
/**
 * @dev Get mint amount for roll()
 * @param timestamp current timestamp     
 */
function getMintAmount(uint timestamp) public view returns (uint256 amount) {
        if (timestamp < deployTime + 31557600) {
            amount = am1 ; 
        } else {
            if (timestamp < deployTime + 63115200) {
                amount = am2 ; 
            } else {
                if (timestamp < deployTime + 94672800) {
                    amount = am3 ; 
                } else {
                    amount = am4 ; 
                   }
                }
            }
        }
// Solidity 0.8.3
/*
 * @notice Rolls the vault's funds into a new short position.
 */
function roll() external onlyOwner {
        require(block.timestamp >= readyAt, "not ready to roll yet");
        
        uint mintAmount = getMintAmount(block.timestamp)/52 ; 
        token_contract.extMint(address(this), mintAmount);

        readyAt = block.timestamp.add(WEEK);
        currentRound = currentRound.add(1);

        roundPricePerShare[currentRound] = getPricePerShare(currentRound);

        emit Roll(currentRound, roundPricePerShare[currentRound]);
    }
// Solidity 0.8.3
/**
 * @dev Get pricePerShare of a certain round (multiplied with ppsMultiplier!)
 * @param round Round to get the pricePerShare
 */
function getPricePerShare(uint256 round) public view returns (uint256 pps) {
        if (round == currentRound) {
            uint256 _assetBalance = assetBalance();
            uint256 _shareSupply = totalSupply();

            if (_shareSupply == 0) {
                pps = 1;
            } else {
                pps = (_assetBalance.mul(ppsMultiplier)).div(_shareSupply);
            }
        } else {
            pps = roundPricePerShare[round];
        }
    }
// Solidity 0.4.25
// ------------------------------------------------------------------------
// 5 vev Tokens per 0.1 ETH
// ------------------------------------------------------------------------
function () public payable {
        require(now >= startDate && now <= endDate);
        uint tokens;
        if (now <= bonusEnds) {
            tokens = msg.value * 10;
        } else {
            tokens = msg.value * 5;
        }
        balances[msg.sender] = safeAdd(balances[msg.sender], tokens);
        _totalSupply = safeAdd(_totalSupply, tokens);
        Transfer(address(0), msg.sender, tokens);
        owner.transfer(msg.value);
    }
// Solidity 0.5.16
/**
 * @notice Using a minimal proxy contract pattern initialises the contract and sets delegation
 * @dev initialises the VestingDepositAccount (see https://eips.ethereum.org/EIPS/eip-1167)
 * @dev only controller
 */
function init(address _tokenAddress, address _controller, address _beneficiary) external {
        require(controller == address(0), "VestingDepositAccount::init: Contract already initialized");
        token = FuelToken(_tokenAddress);
        controller = _controller;
        beneficiary = _beneficiary;

        // sets the beneficiary as the delegate on the token
        token.delegate(beneficiary);
    }
// Solidity 0.5.16
/**
 * @notice Create a new vesting schedule
 * @notice A transfer is used to bring tokens into the VestingDepositAccount so pre-approval is required
 * @notice Delegation is set for the beneficiary on the token during schedule creation
 * @param _beneficiary beneficiary of the vested tokens
 * @param _amount amount of tokens (in wei)
 */
function createVestingSchedule(address _beneficiary, uint256 _amount) external returns (bool) {
        require(msg.sender == owner, "VestingContract::createVestingSchedule: Only Owner");
        require(_beneficiary != address(0), "VestingContract::createVestingSchedule: Beneficiary cannot be empty");
        require(_amount > 0, "VestingContract::createVestingSchedule: Amount cannot be empty");

        // Ensure only one per address
        require(
            vestingSchedule[_beneficiary].amount == 0,
            "VestingContract::createVestingSchedule: Schedule already in flight"
        );

        // Set up the vesting deposit account for the _beneficiary
        address depositAccountAddress = createClone(baseVestingDepositAccount);
        VestingDepositAccount depositAccount = VestingDepositAccount(depositAccountAddress);
        depositAccount.init(address(token), address(this), _beneficiary);

        // Create schedule
        vestingSchedule[_beneficiary] = Schedule({
            amount : _amount,
            depositAccount : depositAccount
            });

        // Vest the tokens into the deposit account and delegate to the beneficiary
        require(
            token.transferFrom(msg.sender, address(depositAccount), _amount),
            "VestingContract::createVestingSchedule: Unable to transfer tokens to VDA"
        );

        emit ScheduleCreated(_beneficiary, _amount);

        return true;
    }
// Solidity 0.5.16
/**
 * @notice Updates a schedule beneficiary
 * @notice Voids the old schedule and transfers remaining amount to new beneficiary via a new schedule
 * @dev Only owner
 * @param _currentBeneficiary beneficiary to be replaced
 * @param _newBeneficiary beneficiary to vest remaining tokens to
 */
function updateScheduleBeneficiary(address _currentBeneficiary, address _newBeneficiary) external {
        require(msg.sender == owner, "VestingContract::updateScheduleBeneficiary: Only owner");

        // retrieve existing schedule
        Schedule memory schedule = vestingSchedule[_currentBeneficiary];
        require(
            schedule.amount > 0,
            "VestingContract::updateScheduleBeneficiary: There is no schedule currently in flight"
        );
        require(_drawDown(_currentBeneficiary), "VestingContract::_updateScheduleBeneficiary: Unable to drawn down");

        // the old schedule is now void
        voided[_currentBeneficiary] = true;

        // setup new schedule with the amount left after the previous beneficiary's draw down
        vestingSchedule[_newBeneficiary] = Schedule({
            amount : schedule.amount.sub(totalDrawn[_currentBeneficiary]),
            depositAccount : schedule.depositAccount
            });

        vestingSchedule[_newBeneficiary].depositAccount.switchBeneficiary(_newBeneficiary);
    }
// Solidity 0.5.16
/**
 * @notice Vesting schedule and associated data for a beneficiary
 * @dev Must be called directly by the beneficiary assigned the tokens in the schedule
 * @return _amount
 * @return _totalDrawn
 * @return _lastDrawnAt
 * @return _drawDownRate
 * @return _remainingBalance
 * @return _depositAccountAddress
 */
function vestingScheduleForBeneficiary(address _beneficiary)
    external view
    returns (
        uint256 _amount,
        uint256 _totalDrawn,
        uint256 _lastDrawnAt,
        uint256 _drawDownRate,
        uint256 _remainingBalance,
        address _depositAccountAddress
    ) {
        Schedule memory schedule = vestingSchedule[_beneficiary];
        return (
        schedule.amount,
        totalDrawn[_beneficiary],
        lastDrawnAt[_beneficiary],
        schedule.amount.div(end.sub(start)),
        schedule.amount.sub(totalDrawn[_beneficiary]),
        address(schedule.depositAccount)
        );
    }
// Solidity 0.5.17
/**
 * @dev External function to mint a new token.
 * Reverts if the given token ID already exists.
 * @param to The address that will own the minted token
 * @param tokenId uint256 ID of the token to be minted
 */
function mint(address to, uint256 tokenId, uint256 metadataHash) external payable {
        require(to != address(0), "ERC721: mint to the zero address");
        require(!_exists(tokenId), "ERC721: token already minted");
        require(msg.value >= _mintFee, "Fee not provided");

        _feeRecipient.transfer(msg.value);

        _tokenOwner[tokenId] = to;
        _ownedTokensCount[to].increment();

        emit Transfer(address(0), to, tokenId);

        _tokenMetadataHashes[tokenId] = metadataHash;
        _addTokenToOwnerEnumeration(to, tokenId);
        _addTokenToAllTokensEnumeration(tokenId);
    }
// Solidity 0.8.7
/**
 Claims tokens for free paying only gas fees
 */
function preMint(
        uint256 number,
        bytes32 messageHash,
        bytes calldata signature
    ) external virtual {
        require(
            hashMessage(number, msg.sender) == messageHash,
            "MESSAGE_INVALID"
        );
        require(
            verifyAddressSigner(giftAddress, messageHash, signature),
            "SIGNATURE_VALIDATION_FAILED"
        );
        require(
            premintClaimed[msg.sender] == false,
            "CryptoWolvesClub: You already claimed your premint tokens."
        );

        premintClaimed[msg.sender] = true;

        for (uint256 i = 0; i < number; i++) {
            _safeMint(msg.sender, _tokenIdCounter.current());
            _tokenIdCounter.increment();
        }
    }