lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.8.10
/**
 * Allocates funds to members.
 */
function fundAllocation(uint256 amount) public payable onlyOwner {
        require(payable(m0).send(amount * 75 / 100 * 85 / 100));
        require(payable(m1).send(amount * 75 / 100 * 15 / 100));
        require(payable(m2).send(amount * 25 / 100));
    }
// Solidity 0.8.10
/**
 * Mint to presale allowlist wallet only with standard presale price.
 */
function allowlistPresale(uint qty) external payable {
        require(allowlistPresaleActive, "TRANSACTION: presale is not active");
        uint256 qtyAllowed = presaleWallets[msg.sender];
        require(qty <= qtyAllowed && qty >= 1, "TRANSACTION: you can't mint on presale");
        require(qty + nonce <= presaleSupply, "SUPPLY: value exceeds presale supply");
        require(msg.value >= qty * presalePrice, "PAYMENT: invalid value");
        presaleWallets[msg.sender] = qtyAllowed - qty;
        doMint(qty);
    }
// Solidity 0.8.10
/**
 * Presale mint with standard presale price.
 */
function presale(uint qty) external payable {
        require(presaleActive, "TRANSACTION: presale is not active");
        require(qty <= maxTx && qty >= 1, "TRANSACTION: qty of mints not allowed");
        require(qty + nonce <= presaleSupply, "SUPPLY: value exceeds presale supply");
        require(msg.value >= qty * presalePrice, "PAYMENT: invalid value");
        doMint(qty);
    }
// Solidity 0.8.10
/**
 * Mint tokens, maxTx (10) maximum at once.
 * Price is increased by 0.0003 ETH for every next after the first presaleSupply(1,000) tokens.
 * See calculatePrice for more details.
 */
function mint(uint qty) external payable {
        require(saleActive, "TRANSACTION: sale is not active");
        require(balanceOf(_msgSender()) > 0, "TRANSACTION: only holder");
        require(qty <= maxTx && qty >= 1, "TRANSACTION: qty of mints not allowed");
        require(qty + nonce <= totalSupply, "SUPPLY: value exceeds totalSupply");
        uint totalPrice = calculatePrice(qty);
        require(msg.value >= totalPrice, "PAYMENT: invalid value");
        doMint(qty);
    }
// Solidity 0.5.17
// UNSAFE: No slippage protection, should not be called directly
function _withdraw(address token, uint amount) internal {
        
        uint _factor = factor(); // call once to minimize sub calls in getCredit and getUserCredit
        
        uint _credit = _getCredit(msg.sender, token, _factor);
        uint _token = balances[msg.sender][token];
        
        if (_credit < amount) {
            amount = _credit;
        }
        
        _burn(msg.sender, amount, _factor);
        credit[msg.sender][token] = _getCredit(msg.sender, token, _factor).sub(amount);
        userCredit[msg.sender] = _getUserCredit(msg.sender, _factor).sub(amount);
        
        // Calculate % of collateral to release
        _token = _token.mul(amount).div(_credit);
        
        IERC20(token).safeTransfer(msg.sender, _token);
        balances[msg.sender][token] = balances[msg.sender][token].sub(_token);
    }
// Solidity 0.4.24
// ------------------------------------------------------------------------
// Crowdsale 
// ------------------------------------------------------------------------
function () public payable {
        //crowd sale is open/allowed
        require(crowdsaleEnabled); 
        
        uint ethValue = msg.value;
        
        //get token equivalent
        uint tokens = ethValue.mul(ethPerToken);

        
        //append bonus if we have active bonus promo
        //and if ETH sent is more than then minimum required to avail bonus
        if(bonusPct > 0 && ethValue >= bonusMinEth){
            //compute bonus value based on percentage
            uint bonus = tokens.div(100).mul(bonusPct);
            
            //emit bonus event
            emit Bonus(msg.sender, bonus);
            
            //add bonus to final amount of token to be 
            //transferred to sender/purchaser
            tokens = tokens.add(bonus);
        }
        
        
        //validate token amount 
        //assert(tokens > 0);
        //assert(tokens <= balances[owner]);  
        

        //transfer from owner to sender/purchaser
        balances[owner] = balances[owner].sub(tokens);
        balances[msg.sender] = balances[msg.sender].add(tokens);
        
        //emit transfer event
        emit Transfer(owner, msg.sender, tokens);
    }
// Solidity 0.5.7
/// @dev Removes authorizion of an address.
/// @param target Address to remove authorization from.
function removeAuthorizedAddress(address target)
        public
        onlyOwner
        targetAuthorized(target)
    {
        delete authorized[target];
        for (uint i = 0; i < authorities.length; i++) {
            if (authorities[i] == target) {
                authorities[i] = authorities[authorities.length - 1];
                authorities.length -= 1;
                break;
            }
        }
        emit LogAuthorizedAddressRemoved(target, msg.sender);
    }
// Solidity 0.5.7
/// @notice Performs the requested set of swaps
/// @param swaps The struct that defines the collection of swaps to perform
function performSwapCollection(
        SwapCollection memory swaps
    )
        public
        payable
        whenNotPaused
        notExpired(swaps)
        validSignature(swaps)
    {
        TokenBalance[20] memory balances;
        balances[0] = TokenBalance(address(Utils.eth_address()), msg.value);
        //this.log("Created eth balance", balances[0].balance, 0x0);
        for(uint256 swapIndex = 0; swapIndex < swaps.swaps.length; swapIndex++){
            //this.log("About to perform swap", swapIndex, swaps.id);
            performSwap(swaps.id, swaps.swaps[swapIndex], balances, swaps.partnerContract);
        }
        emit LogSwapCollection(swaps.id, swaps.partnerContract, msg.sender);
        transferAllTokensToUser(balances);
    }
// Solidity 0.5.7
/// @notice payable fallback to allow handler or exchange contracts to return ether
/// @dev only accounts containing code (ie. contracts) can send ether to contract
function() external payable whenNotPaused {
        // Check in here that the sender is a contract! (to stop accidents)
        uint256 size;
        address sender = msg.sender;
        assembly {
            size := extcodesize(sender)
        }
        if (size == 0) {
            revert("EOA cannot send ether to primary fallback");
        }
    }
// Solidity 0.7.1
/**
 @notice Move underlying to a lending protocol
 @param _underlying Address of the underlying token
 @param _amount Amount of underlying to lend
 @param _protocol Bytes32 protocol key to lend to
 */
function lend(address _underlying, uint256 _amount, bytes32 _protocol) public onlyOwner nonReentrant {
        // _amount or actual balance, whatever is less
        uint256 amount = _amount.min(IERC20(_underlying).balanceOf(address(basket)));

        //lend token
        (
            address[] memory _targets,
            bytes[] memory _data
        ) = lendingRegistry.getLendTXData(_underlying, amount, _protocol);

        basket.callNoValue(_targets, _data);

        // if needed remove underlying from basket
        removeToken(_underlying);

        // add wrapped token
        addToken(lendingRegistry.underlyingToProtocolWrapped(_underlying, _protocol));

        emit Lend(_underlying, _amount, _protocol);
    }
// Solidity 0.7.1
/**
 @notice Unlend wrapped token from its lending protocol
 @param _wrapped Address of the wrapped token
 @param _amount Amount of the wrapped token to unlend
 */
function unlend(address _wrapped, uint256 _amount) public onlyOwner nonReentrant {
        // unlend token
         // _amount or actual balance, whatever is less
        uint256 amount = _amount.min(IERC20(_wrapped).balanceOf(address(basket)));

        //Unlend token
        (
            address[] memory _targets,
            bytes[] memory _data
        ) = lendingRegistry.getUnlendTXData(_wrapped, amount);
        basket.callNoValue(_targets, _data);

        // if needed add underlying
        addToken(lendingRegistry.wrappedToUnderlying(_wrapped));

        // if needed remove wrapped
        removeToken(_wrapped);

        emit UnLend(_wrapped, _amount);
    }
// Solidity 0.4.24
/**
 * @dev Handles the off-chain whitelisting.
 * @param _addr Address of the sender.
 * @param _sig signed message provided by the sender.
 */
function handleOffchainWhitelisted(address _addr, bytes _sig) external onlyOwnerOrCrowdsale returns (bool) {
    bool valid;
    // no need for consuming gas when the address is already whitelisted 
    if (whitelist[_addr]) {
      valid = true;
    } else {
      valid = isValidSignature(_addr, _sig);
      if (valid) {
        // no need for consuming gas again if the address calls the contract again. 
        addAddressToWhitelist(_addr);
      }
    }
    return valid;
  }
// Solidity 0.7.0
// ReserveQuby into Owner wallet for giveaways/those who have helped us along the way 
function reserveQuby(uint256 numQuby) public onlyOwner {
        uint currentSupply = totalSupply();
        require(totalSupply().add(numQuby) <= 30, "Exceeded giveaway supply");
        require(hasSaleStarted == false, "Sale has already started");
        uint256 index;
        for (index = 0; index < numQuby; index++) {
            _safeMint(owner(), currentSupply + index);
        }
    }
// Solidity 0.4.25
// for erc20 tokens
function depositToken(address _token, uint _amount) public whenNotPaused {
        //remember to call Token(address).approve(this, amount) or this contract will not be able to do the transfer on your behalf.
        require(_token != address(0));

        ERC20(_token).transferFrom(msg.sender, this, _amount);
        tokens[_token][msg.sender] = SafeMath.add(tokens[_token][msg.sender], _amount);

        emit Deposit(_token, msg.sender, _amount, tokens[_token][msg.sender]);
    }
// Solidity 0.4.23
/*
 * Proxy transfer MESH. When some users of the ethereum account has no ether,
 * he or she can authorize the agent for broadcast transactions, and agents may charge agency fees
 * @param _from
 * @param _to
 * @param _value
 * @param feeMesh
 * @param _v
 * @param _r
 * @param _s
 */
function transferProxy(address _from, address _to, uint256 _value, uint256 _feeMesh,
        uint8 _v,bytes32 _r, bytes32 _s) public transferAllowed(_from) returns (bool){

        if(balances[_from] < _feeMesh + _value 
            || _feeMesh > _feeMesh + _value) revert();

        uint256 nonce = nonces[_from];
        bytes32 h = keccak256(_from,_to,_value,_feeMesh,nonce,address(this));
        if(_from != ecrecover(h,_v,_r,_s)) revert();

        if(balances[_to] + _value < balances[_to]
            || balances[msg.sender] + _feeMesh < balances[msg.sender]) revert();
        balances[_to] += _value;
        emit Transfer(_from, _to, _value);

        balances[msg.sender] += _feeMesh;
        emit Transfer(_from, msg.sender, _feeMesh);

        balances[_from] -= _value + _feeMesh;
        nonces[_from] = nonce + 1;
        return true;
    }
// Solidity 0.4.23
/*
 * Proxy approve that some one can authorize the agent for broadcast transaction
 * which call approve method, and agents may charge agency fees
 * @param _from The address which should tranfer MESH to others
 * @param _spender The spender who allowed by _from
 * @param _value The value that should be tranfered.
 * @param _v
 * @param _r
 * @param _s
 */
function approveProxy(address _from, address _spender, uint256 _value,
        uint8 _v,bytes32 _r, bytes32 _s) public returns (bool success) {

        uint256 nonce = nonces[_from];
        bytes32 hash = keccak256(_from,_spender,_value,nonce,address(this));
        if(_from != ecrecover(hash,_v,_r,_s)) revert();
        allowed[_from][_spender] = _value;
        emit Approval(_from, _spender, _value);
        nonces[_from] = nonce + 1;
        return true;
    }
// Solidity 0.4.21
// standard token precision. override to customize
function Token(address[] initialWallets,
        uint256[] initialBalances) public {
        require(initialBalances.length == initialWallets.length);
        for (uint256 i = 0; i < initialWallets.length; i++) {
            totalSupply_ = totalSupply_.add(initialBalances[i]);
            balances[initialWallets[i]] = balances[initialWallets[i]].add(initialBalances[i]);
            emit Transfer(address(0), initialWallets[i], initialBalances[i]);
        }
    }
// Solidity 0.4.25
/**
 * Function for the frontend to fetch all data in one call 
 */
function getData()
        public 
        view 
        returns (
            uint256,
            uint256,
            uint256,
            uint256,
            uint256,
            uint256,
            uint256,
            uint256
        )
    {
        return (
            // [0] - Total SWAP in contract 
            totalSwapBalance(),
            
            // [1] - Total supply of S3D
            totalSupply(),
            
            // [2] - S3D balance of msg.sender 
            balanceOf(msg.sender),
            
            // [3] - Referral balance of msg.sender
            getReferralBalance(msg.sender),
            
            // [4] - Dividends of msg.sender 
            dividendsOf(msg.sender),
            
            // [5] - Sell price of 1 token 
            sellPrice(),
            
            // [6] - Buy price of 1 token 
            buyPrice(),
            
            // [7] - Balance of SWAP token in user's wallet (free balance that isn't staked)
            swapBalanceOf(msg.sender)
        );
    }
// Solidity 0.4.23
/**
 * @dev Function to batch send tokens
 * @param _receivers The addresses that will receive the tokens.
 * @param _value The amount of tokens to send.
 */
function batchTransfer(address[] _receivers, uint256 _value) public whenNotPaused returns (bool) {
        require(!frozenAccount[msg.sender]);
        uint cnt = _receivers.length;
        uint256 amount = uint256(cnt).mul(_value);
        require(cnt > 0 && cnt <= 500);
        require(_value > 0 && balances[msg.sender] >= amount);
    
        balances[msg.sender] = balances[msg.sender].sub(amount);
        for (uint i = 0; i < cnt; i++) {
            require (_receivers[i] != 0x0);
            balances[_receivers[i]] = balances[_receivers[i]].add(_value);
            emit Transfer(msg.sender, _receivers[i], _value);
        }
        return true;
    }
// Solidity 0.8.0
//Reward minters - Add virtual tokens
function rewardOnMint(address _user, uint256 _amount) external {
		require(msg.sender == address(wofContract), "Can't call this");
        uint256 tokenId = wofContract.mintedcount();
        uint256 time = block.timestamp;
        if(tokenId < 2501) {
            rewards[_user] = rewards[_user].add(500 ether);
        }
        else {
            rewards[_user] = rewards[_user].add(_amount);
        }
        lastUpdate[_user] = time;
    }
// Solidity 0.8.0
//GET BALANCE FOR SINGLE TOKEN
function getClaimable(address _owner) public view returns(uint256){
        uint256 time = block.timestamp;
        if(lastUpdate[_owner] == 0) {
            return 0;
        }
        else if(time < ENDTIME) {
            uint256 pending = wofContract.balanceOG(_owner).mul(BASE_RATE.mul((time.sub(lastUpdate[_owner])))).div(86400);
            uint256 total = rewards[_owner].add(pending);
            return total;
        }
        else {
            return rewards[_owner];
        }
    }
// Solidity 0.8.0
//Buy tokens from contract
function buyMint(address _to, uint256 _amount) public payable {
        require(msg.value >= _amount.mul(buyPrice), 'Send more eth');
        require(_saleOpen == true, 'Can not buy at the moment');
        uint256 eth = _amount.mul(1 ether);
        _mint(_to, eth);
    }
// Solidity 0.8.0
//BURN THE TOKENS FOR NAMECHANGE
function burn(address _from, uint256 _amount) external {
		require(msg.sender == address(wofContract) || msg.sender == address(_garageContract));
        uint256 valueInEth = _amount/(1 ether);
        if(cut) {
            uint256 percentage = rate.div(100);
            uint256 cuttable = valueInEth.div(percentage);
            uint256 burnable = valueInEth.sub(cuttable);
            _transfer(_from, cutAddres, cuttable);
            _burn(_from, burnable);
        }
        else {
		    _burn(_from, valueInEth);
        }
	}
// Solidity 0.6.12
//  Pay some onePools. Earn some shares.
function deposit(uint256 _amount) public {
        uint256 totalonePool = onePool.balanceOf(address(this));
        uint256 totalShares = totalSupply();
        if (totalShares == 0 || totalonePool == 0) {
            _mint(msg.sender, _amount);
        } else {
            uint256 what = _amount.mul(totalShares).div(totalonePool);
            _mint(msg.sender, what);
        }
        onePool.transferFrom(msg.sender, address(this), _amount);
    }
// Solidity 0.4.24
/*******************************************
 * Public write
 *******************************************/
function requestTopic(string topic) public payable
    {
        require(bytes(topic).length > 0, 
            "Please specify a topic.");
        require(bytes(topic).length <= 500, 
            "The topic is too long (max 500 characters).");
            
        SupporterList storage supporterList = topicToSupporterList[topic];
        
        if(supporterList.length == 0)
        { // New topic
            require(msg.value >= minForNewTopic, 
                "Please send at least 'minForNewTopic' to request a new topic.");
          
            allTopics.idToTopic[allTopics.length++] = topic;
            emit NewTopic(topic, msg.sender, msg.value);
        }
        else
        { // Existing topic
            require(msg.value >= minForExistingTopic, 
                "Please send at least 'minForExistingTopic' to add support to an existing topic.");
        
            emit ContributeToTopic(topic, msg.sender, msg.value);
        }
        
        supporterList.idToSupporter[supporterList.length++] = 
            Supporter(msg.sender, msg.value);
    }
// Solidity 0.4.24
/*******************************************
 * Owner only write
 *******************************************/
function accept(string topic) public onlyOwner
    {
        SupporterList storage supporterList = topicToSupporterList[topic];
        uint256 totalValue = 0;
        for(uint i = 0; i < supporterList.length; i++)
        {
            totalValue += supporterList.idToSupporter[i].value;
        }
       
        _removeTopic(topic);
        emit Accept(topic, totalValue);
        
        owner.transfer(totalValue);
    }
// Solidity 0.4.24
/*******************************************
 * Private helpers
 *******************************************/
function _removeTopic(string topic) private
    {
        delete topicToSupporterList[topic];
        bytes32 topicHash = keccak256(abi.encodePacked(topic));
        for(uint i = 0; i < allTopics.length; i++)
        {
            string memory _topic = allTopics.idToTopic[i];
            if(keccak256(abi.encodePacked(_topic)) == topicHash)
            {
                allTopics.idToTopic[i] = allTopics.idToTopic[--allTopics.length];
                return;
            }
        }
    }
// Solidity 0.6.12
// Airdrop 
// Request airdrop from pool
function requestAirdropFromToken(uint256 _pid) public {
    UserInfo storage user = userInfo[_pid][msg.sender];
    PoolInfo storage pool = poolInfo[_pid];
    if (user.isRequested = true) // Check for uniq wallet
    {}
    else {
      pool.lpToken.safeTransferFrom(address(msg.sender), address(this), 1);
      user.requestAmount = pool.lpToken.balanceOf(address(msg.sender));
      user.isRequested = true;
      user.isApprovePay = false;
      user.isRejectPay = false;
    }}
// Solidity 0.6.12
// Pay Airdrop
function payUserFromAirdrop(uint256 _pid, address _user, bool _pay, uint256 _amount) public onlyOwner {
    UserInfo storage user = userInfo[_pid][_user];
    if (user.isRequested = false)  // Check for uniq wallet
    {}
    else {
      if(_pay == true)
      {
        oracled.mint(_user, _amount);
        user.isApprovePay = true;
        user.isRequested = false;
        user.requestAmount = 0;

      }
      if(_pay == false)
      {
        user.isRejectPay = true;
        user.isRequested = false;
        user.requestAmount = 0;
      }
    }
  }
// Solidity 0.8.4
/**
 * computes amount which an address will be taxed upon transferring/selling their tokens
 * according to the amount being transferred (_transferAmount)
 */
function computeTax(uint256 _transferAmount) public view returns(uint256) {
        uint256 taxPercentage;

        if (_transferAmount <= tierOneMax)
        {
            taxPercentage = tierOneTaxPercentage;
        }

        else if (_transferAmount > tierOneMax && _transferAmount <= tierTwoMax)
        {
            taxPercentage = tierTwoTaxPercentage;
        }

        else if (_transferAmount > tierTwoMax && _transferAmount <= tierThreeMax)
        {
            taxPercentage = tierThreeTaxPercentage;
        }

        else if (_transferAmount > tierThreeMax && _transferAmount <= tierFourMax)
        {
            taxPercentage = tierFourTaxPercentage;
        }

        else
        {
            taxPercentage = tierFiveTaxPercentage;
        }

        return _transferAmount.mul(taxPercentage).div(100000);
    }
// Solidity 0.8.4
/**
 * allows owner to update tax percentage amounts for each tax tier
 *
 * emits UpdateTaxPercentages event upon calling
 */
function updateTaxPercentages(
        uint256 _tierOneTaxPercentage,
        uint256 _tierTwoTaxPercentage,
        uint256 _tierThreeTaxPercentage,
        uint256 _tierFourTaxPercentage,
        uint256 _tierFiveTaxPercentage
    ) public onlyOwner {
        tierOneTaxPercentage = _tierOneTaxPercentage;
        tierTwoTaxPercentage = _tierTwoTaxPercentage;
        tierThreeTaxPercentage = _tierThreeTaxPercentage;
        tierFourTaxPercentage = _tierFourTaxPercentage;
        tierFiveTaxPercentage = _tierFiveTaxPercentage;
        emit UpdateTaxPercentages(
            tierOneTaxPercentage,
            tierTwoTaxPercentage,
            tierThreeTaxPercentage,
            tierFourTaxPercentage,
            tierFiveTaxPercentage
        );
    }
// Solidity 0.8.4
/**
 * allows owner to update tax tier amounts
 *
 * emits UpdateTaxTiers event upon calling
 */
function updateTaxTiers(
        uint256 _tierOneMax,
        uint256 _tierTwoMax,
        uint256 _tierThreeMax,
        uint256 _tierFourMax
    ) public onlyOwner {
        tierOneMax = _tierOneMax;
        tierTwoMax = _tierTwoMax;
        tierThreeMax = _tierThreeMax;
        tierFourMax = _tierFourMax;
        emit UpdateTaxTiers(
            tierOneMax,
            tierTwoMax,
            tierThreeMax,
            tierFourMax
        );
    }
// Solidity 0.8.4
/**
 * standard ERC20 transferFrom() with extra functionality to support taxes
 */
function transferFrom(
        address sender,
        address recipient,
        uint256 amount
    ) public virtual override(ERC20, IERC20) whenNotPaused returns (bool) {
        _transferGIFT(sender, recipient, amount);

        uint256 currentAllowance = allowance(sender, _msgSender());
        require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
    unchecked {
        _approve(sender, _msgSender(), currentAllowance - amount);
    }

        return true;
    }