lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.6.3
/// @notice Allow registered voter to vote 'against' proposal
/// @param _id Proposal id
function voteAgainst(uint256 _id) public {
        require(proposals[_id].start < block.number, "<start");
        require(proposals[_id].end > block.number, ">end");

        uint256 _for = proposals[_id].forVotes[_msgSender()];
        if (_for > 0) {
            proposals[_id].totalForVotes = proposals[_id].totalForVotes.sub(_for);
            proposals[_id].forVotes[_msgSender()] = 0;
        }

        uint256 vote = votesOf(_msgSender()).sub(proposals[_id].againstVotes[_msgSender()]);
        proposals[_id].totalAgainstVotes = proposals[_id].totalAgainstVotes.add(vote);
        proposals[_id].againstVotes[_msgSender()] = votesOf(_msgSender());

        proposals[_id].totalVotesAvailable = totalVotes;
        uint256 _votes = proposals[_id].totalForVotes.add(proposals[_id].totalAgainstVotes);
        proposals[_id].quorum = _votes.mul(10000).div(totalVotes);

        voteLock[_msgSender()] = lock.add(block.number);

        emit Vote(_id, _msgSender(), false, vote);
    }
// Solidity 0.6.3
/// @notice Allow to remove old governance tokens from voter weight, simultaneosly it recalculates reward size according to new weight
/// @param _amount Amount of governance token to withdraw
function withdraw(uint256 _amount) public override updateReward(_msgSender()) {
        require(_amount > 0, "!withdraw 0");
        if (voters[_msgSender()]) {
            votes[_msgSender()] = votes[_msgSender()].sub(_amount);
            totalVotes = totalVotes.sub(_amount);
        }
        if (!breaker) {
            require(voteLock[_msgSender()] < block.number, "!locked");
        }
        super.withdraw(_amount);
        emit Withdrawn(_msgSender(), _amount);
    }
// Solidity 0.6.3
/// @notice Transfer staking reward tokens to voter (msg.sender), simultaneosly it recalculates reward size according to new weight and rewards remaining
function getReward() public updateReward(_msgSender()) {
        if (!breaker) {
            require(voteLock[_msgSender()] > block.number, "!voted");
        }
        uint256 reward = earned(_msgSender());
        if (reward > 0) {
            rewards[_msgSender()] = 0;
            rewardsToken.transfer(_msgSender(), reward);
            emit RewardPaid(_msgSender(), reward);
        }
    }
// Solidity 0.4.24
/** TRANSFER SECTION by Beni Syahroni,S.Pd.I
 */
function _transfer(address _from, address _to, uint _value) internal {
        
        require(_to !=0x0);
        require(balanceOf[_from] >=_value);
        require(balanceOf[_to] + _value >= balanceOf[_to]);
        require(!frozenAccount[msg.sender]);
        
        uint previousBalances = balanceOf[_from] + balanceOf[_to];
        
        balanceOf[_from] -= _value;
        balanceOf[_to] += _value;
        
        emit Transfer (_from, _to, _value);
        assert(balanceOf[_from] + balanceOf[_to] == previousBalances);
    }
// Solidity 0.8.7
/**
 	 * @dev
 	 * Encode team distribution percentage
 	 * Embed all individuals equity and payout to seedz project
 	 * retain at least 0.1 ether in the smart contract
 	 */
function withdraw() public onlyOwner {
		/* Minimum balance */
		require(address(this).balance > 0.5 ether);
		uint256 balance = address(this).balance - 0.1 ether;

		for (uint256 i = 0; i < _team.length; i++) {
			Team storage _st = _team[i];
			_st.addr.transfer((balance * _st.percentage) / 100);
		}
	}
// Solidity 0.8.7
/**
 	 * Set some Apes aside
 	 * We will set aside 50 Vapenapes for community giveaways and promotions
 	 */
function reserveApes() public onlyOwner {
		require(totalSupply().add(NUM_TO_RESERVE) <= MAX_APES, "Reserve would exceed max supply");

		uint256 supply = totalSupply();
		for (uint256 i = 0; i < NUM_TO_RESERVE; i++) {
			_safeMint(_msgSender(), supply + i);
		}
	}
// Solidity 0.8.7
/**
 	 * Mints Apes
 	 */
function mintApe(uint256 numberOfTokens) public payable saleIsOpen {
		require(numberOfTokens <= MAX_APE_PURCHASE, "Can only mint 20 tokens at a time");

		require(totalSupply().add(numberOfTokens) <= MAX_APES, "Purchase would exceed max supply of Apes");
		require(APE_SALEPRICE.mul(numberOfTokens) <= msg.value, "Ether value sent is not correct");

		for (uint256 i = 0; i < numberOfTokens; i++) {
			/* Increment supply and mint token */
			uint256 id = totalSupply();
			_tokenIdTracker.increment();

			/* For each number mint ape */
			if (totalSupply() < MAX_APES) {
				_safeMint(msg.sender, id);

				/* emit mint event */
				emit MintApe(id);
			}
		}

		// If we haven't set the starting index and this is either 1) the last saleable token or 2) the first token to be sold after
		// the end of pre-sale, set the starting index block
		if (startingIndexBlock == 0 && (totalSupply() == MAX_APES || block.timestamp >= revealTimestamp)) {
			startingIndexBlock = block.number;
		}
	}
// Solidity 0.8.9
/**
 * @dev IFoundation
 */
function getFees(uint256 tokenId)
        external
        view
        virtual
        returns (address payable[] memory, uint256[] memory)
    {
        require(_existsRoyalties(tokenId), "Nonexistent token");

        address payable[] memory receivers = new address payable[](1);
        uint256[] memory bps = new uint256[](1);
        receivers[0] = _getReceiver(tokenId);
        bps[0] = _getBps(tokenId);
        return (receivers, bps);
    }
// Solidity 0.4.19
/**
 * CONSTRUCTOR
 *
 * @dev Initialize the EtherSportCrowdsale
 * @param _startTime Start time timestamp
 * @param _endTime End time timestamp
 * @param _token EtherSport ERC20 token
 * @param _from Wallet address with token allowance
 * @param _wallet Wallet address to transfer direct funding to
 */
function EtherSportCrowdsale(
        uint256 _startTime, 
        uint256 _endTime, 
        address _token, 
        address _from, 
        address _wallet
    )
        public 
    {
        require(_startTime < _endTime);
        require(_token != address(0));
        require(_from != address(0));
        require(_wallet != address(0));

        startTime = _startTime;
        endTime = _endTime;
        token = ERC20(_token);
        tokenFrom = _from;
        wallet = _wallet;
    }
// Solidity 0.4.19
/**
 * @dev Makes order for tokens purchase.
 * @param _beneficiary Who will get the tokens
 * @param _referer Beneficiary's referer (optional)
 */
function buyTokensFor(
        address _beneficiary, 
        address _referer
    ) 
        public 
        payable 
    {
        require(_beneficiary != address(0));
        require(_beneficiary != _referer);

        require(msg.value >= MIN_FUNDING_AMOUNT);

        require(liveEtherSportCampaign());
        require(oraclize_getPrice("URL") <= this.balance);

        uint256 _funds = msg.value;
        address _funder = msg.sender;
        bytes32 _orderId = oraclize_query("URL", ethRateURL, oraclizeGasLimit);

        OrderEvent(_beneficiary, _orderId);

        orders[_orderId].beneficiary = _beneficiary;
        orders[_orderId].funds = _funds;
        orders[_orderId].referer = _referer;
        
        uint256 _offerCondition = offers[_funder].condition;

        uint256 _bonus;

        // in case of special offer
        if (_offerCondition > 0 && _offerCondition <= _funds) {
            uint256 _offerPrice = offers[_funder].specialPrice;

            offers[_funder].condition = 0;
            offers[_funder].specialPrice = 0;

            orders[_orderId].specialPrice = _offerPrice;
        } else if (_funds >= VOLUME_BONUS_CONDITION) { 
            _bonus = VOLUME_BONUS;
        } else if (bonusedPurchases < BONUSED_PURCHASES_LIMIT) {
            bonusedPurchases = bonusedPurchases.add(1);
            _bonus = PURCHASES_BONUS;
        }
        orders[_orderId].bonus = _bonus;

        uint256 _transferFunds = _funds.sub(ORACLIZE_COMMISSION);
        wallet.transfer(_transferFunds);

        raised = raised.add(_funds);
        funders[_funder] = true;

        FundingEvent(_funder, _referer, _orderId, _beneficiary, _funds); // solium-disable-line arg-overflow
    }
// Solidity 0.4.19
/**
 * @dev Get current rate from oraclize and transfer tokens.
 * @param _orderId Oraclize order id
 * @param _result Current rate
 */
function __callback(bytes32 _orderId, string _result) public { // solium-disable-line mixedcase
        require(msg.sender == oraclize_cbAddress());

        uint256 _rate = parseInt(_result, RATE_EXPONENT);

        address _beneficiary = orders[_orderId].beneficiary;
        uint256 _funds = orders[_orderId].funds;
        uint256 _bonus = orders[_orderId].bonus;
        address _referer = orders[_orderId].referer;
        uint256 _specialPrice = orders[_orderId].specialPrice;

        orders[_orderId].rate = _rate;
        
        uint256 _tokens = _funds.mul(_rate);

        if (_specialPrice > 0) {
            _tokens = _tokens.div(_specialPrice);
        } else {
            _tokens = _tokens.div(TOKEN_PRICE);
        }
        _tokens = _tokens.mul(10 ** PRICE_EXPONENT).div(10 ** RATE_EXPONENT);

        uint256 _bonusTokens = _tokens.mul(_bonus).div(100);
        _tokens = _tokens.add(_bonusTokens);
        
        //change of funds will be returned to funder
        if (sold.add(_tokens) > TOKENS_HARD_CAP) {
            _tokens = TOKENS_HARD_CAP.sub(sold);
        }
        token.safeTransferFrom(tokenFrom, _beneficiary, _tokens);
        sold = sold.add(_tokens);

        if (funders[_referer]) {
            uint256 _refererBonus = _tokens.mul(5).div(100);
            if (sold.add(_refererBonus) > TOKENS_HARD_CAP) {
                _refererBonus = TOKENS_HARD_CAP.sub(sold);
            }
            if (_refererBonus > 0) {
                token.safeTransferFrom(tokenFrom, _referer, _refererBonus);
                sold = sold.add(_refererBonus);
                RefererBonusEvent(_beneficiary, _referer, _orderId, _refererBonus);
            }
        }
        TokenPurchaseEvent(_beneficiary, _orderId, _funds, _tokens);
    }
// Solidity 0.8.7
// View function to see pending pheonix on frontend.
function pendingPHX(address _user) 
        external 
        view 
        returns (uint256) 
        {
        UserInfo storage user = userInfo[_user];
        uint256 lpSupply = lpToken.balanceOf(address(this));
        uint256 accPhx = accPhxPerShare;
        if (block.number > lastRewardBlock && lpSupply != 0) {
            uint256 multiplier = getMultiplier(lastRewardBlock, block.number);
            
            uint256 phxReward = multiplier.mul(phxPerBlock).mul(allocPoint).div(totalAllocPoint);
            accPhx = accPhx.add(phxReward.mul(1e12).div(lpSupply));
        }
        return (user.amount.mul(accPhx).div(1e12).sub(user.rewardDebt));
    }
// Solidity 0.8.7
// Deposit LP tokens to MasterChef for CAKE allocation.
function deposit( uint256 _amount) public {
        UserInfo storage user = userInfo[msg.sender];
        updatePool();
        if (user.amount > 0) {
            uint256 pending = user.amount.mul(accPhxPerShare).div(1e12).sub(user.rewardDebt);
            if(pending > 0) {
                phx.transfer(msg.sender, pending);
            }
        }
        if (_amount > 0) {
            lpToken.transferFrom(address(msg.sender), address(this), _amount);
            user.amount = user.amount.add(_amount);
        }
        user.rewardDebt = user.amount.mul(accPhxPerShare).div(1e12);
        emit Deposit(msg.sender, _amount);
    }
// Solidity 0.8.7
// function acc() public view returns(uint256){
//     return accPhxPerShare;
// }
// function userInf() public view returns(uint256,uint256){
//     return (userInfo[msg.sender].amount,userInfo[msg.sender].rewardDebt);
// }
// function utils() public view returns(uint256){
//     return (block.number);
// }
// function getPhx() public view returns(uint256){
//     uint256 multiplier = getMultiplier(lastRewardBlock, block.number);
//     uint256 phxReward = multiplier.mul(phxPerBlock).mul(allocPoint).div(totalAllocPoint);
//     return phxReward;
// }
// Withdraw LP tokens from MasterChef.
function withdraw(uint256 _amount) public {

        UserInfo storage user = userInfo[msg.sender];
        require(user.amount >= _amount, "withdraw: not good");

        updatePool();
        uint256 pending = user.amount.mul(accPhxPerShare).div(1e12).sub(user.rewardDebt);
        if(pending > 0) {
           phx.transfer(msg.sender, pending);
        }
        if(_amount > 0) {
            user.amount = user.amount.sub(_amount);
            lpToken.transfer(address(msg.sender), _amount);
        }
        user.rewardDebt = user.amount.mul(accPhxPerShare).div(1e12);
        emit Withdraw(msg.sender, _amount);
    }
// Solidity 0.5.17
/**
 	 * Returns the ratio of the first argument to the second argument.
 	 */
function outOf(uint256 _a, uint256 _b)
		internal
		pure
		returns (uint256 result)
	{
		if (_a == 0) {
			return 0;
		}
		uint256 a = _a.mul(basisValue);
		if (a < _b) {
			return 0;
		}
		return (a.div(_b));
	}
// Solidity 0.5.17
/**
 	 * Validates passed address equals to the three addresses.
 	 */
function validate3Addresses(
		address _addr,
		address _target1,
		address _target2,
		address _target3
	) external pure {
		if (_addr == _target1) {
			return;
		}
		if (_addr == _target2) {
			return;
		}
		require(_addr == _target3, errorMessage);
	}
// Solidity 0.6.2
/**
 * @dev Updates the token metadata if the owner is also the creator.
 * @param _tokenId uint256 ID of the token.
 * @param _uri string metadata URI.
 */
function updateTokenMetadata(uint256 _tokenId, string memory _uri)
      public
    {
        require(_isApprovedOrOwner(msg.sender, _tokenId), "BcaexOwnershipV2: transfer caller is not owner nor approved");
        require(_exists(_tokenId), "ERC721Metadata: URI query for nonexistent token");
        _setTokenURI(_tokenId, _uri);
        emit TokenURIUpdated(_tokenId, _uri);
    }
// Solidity 0.4.11
//~~ Methods based on Token.sol from Ethereum Foundation
//~ Transfer FLIP
function transfer(address _to, uint256 _value) {
        if (_to == 0x0) throw;                               
        if (balanceOf[msg.sender] < _value) throw;           
        if (balanceOf[_to] + _value < balanceOf[_to]) throw; 
        balanceOf[msg.sender] -= _value;                   
        balanceOf[_to] += _value;                           
        Transfer(msg.sender, _to, _value);                   
    }
// Solidity 0.4.21
// ------------------------------------------------------------------------
// 2000000 FCOM Tokens per 1 ETH
// ------------------------------------------------------------------------
function () public payable {
        require(now >= startDate && now <= endDate);
        uint tokens;
        /*
		if (now <= bonusEnds) {
            tokens = msg.value * 1200;
        } else {
            tokens = msg.value * 2000000;
        }
		*/
		
		tokens = msg.value * 2000000;
			
        balances[msg.sender] = safeAdd(balances[msg.sender], tokens);
        _totalSupply = safeAdd(_totalSupply, tokens);
        Transfer(address(0), msg.sender, tokens);
        owner.transfer(msg.value);
    }
// Solidity 0.4.24
//function calcAmount(address _beneficiar) canMint public returns (uint256 amount) { //for test's
function calcAmount(address _beneficiar) canMint internal returns (uint256 amount) {
        if (countClaimsToken[_beneficiar] == 0) {
            countClaimsToken[_beneficiar] = 1;
        }
        if (countClaimsToken[_beneficiar] >= 1000) {
            return 0;
        }
        uint step = countClaimsToken[_beneficiar];
        amount = numberClaimToken.mul(105 - 5*step).div(100);
        countClaimsToken[_beneficiar] = countClaimsToken[_beneficiar].add(1);
    }
// Solidity 0.8.8
//initialize rewards for v2 starting staking contracts
function setStakingRewards(
		INameService ns,
		address[] memory contracts,
		uint256[] memory rewards
	) external onlyOwner {
		require(contracts.length == rewards.length, "staking length mismatch");
		for (uint256 i = 0; i < contracts.length; i++) {
			(bool ok, ) = controller.genericCall(
				ns.getAddress("FUND_MANAGER"),
				abi.encodeWithSignature(
					"setStakingReward(uint32,address,uint32,uint32,bool)",
					rewards[i],
					contracts[i],
					0,
					0,
					false
				),
				avatar,
				0
			);
			require(ok, "Calling setStakingRewards failed");
		}
	}
// Solidity 0.8.8
//add new reserve as minter
//renounace minter from avatar
//add reserve as global constraint on controller
function _setReserveSoleMinter(INameService ns) internal {
		bool ok;
		(ok, ) = controller.genericCall(
			ns.getAddress("GOODDOLLAR"),
			abi.encodeWithSignature("addMinter(address)", ns.getAddress("RESERVE")),
			avatar,
			0
		);
		require(ok, "Calling addMinter failed");

		(ok, ) = controller.genericCall(
			address(ns.getAddress("GOODDOLLAR")),
			abi.encodeWithSignature("renounceMinter()"),
			avatar,
			0
		);
		require(ok, "Calling renounceMinter failed");

		ok = controller.addGlobalConstraint(
			ns.getAddress("RESERVE"),
			bytes32(0x0),
			avatar
		);

		require(ok, "Calling addGlobalConstraint failed");
	}
// Solidity 0.8.8
//transfer funds(cdai + comp) from old reserve to new reserve/avatar
//end old reserve
//initialize new marketmaker with current cdai price, rr, reserves
function _setNewReserve(INameService ns) internal {
		bool ok;

		address cdai = ns.getAddress("CDAI");
		uint256 oldReserveCdaiBalance = ERC20(cdai).balanceOf(avatar);

		ok = controller.externalTokenTransfer(
			cdai,
			ns.getAddress("RESERVE"),
			oldReserveCdaiBalance,
			avatar
		);

		require(ok, "transfer cdai to new reserve failed");

		(ok, ) = controller.genericCall(
			ns.getAddress("MARKET_MAKER"),
			abi.encodeWithSignature(
				"initializeToken(address,uint256,uint256,uint32,uint256)",
				cdai,
				604798140091,
				4325586750999495,
				805643,
				1645623572
			),
			avatar,
			0
		);

		require(ok, "calling marketMaker initializeToken failed");
	}
// Solidity 0.8.8
//set contracts in nameservice that are deployed after INameService is created
//	FUND_MANAGER RESERVE REPUTATION GDAO_STAKING  GDAO_CLAIMERS ...
function _setNameServiceContracts(
		INameService ns,
		bytes32[] memory names,
		address[] memory addresses
	) internal {
		(bool ok, ) = controller.genericCall(
			address(ns),
			abi.encodeWithSignature(
				"setAddresses(bytes32[],address[])",
				names,
				addresses
			),
			avatar,
			0
		);
		require(ok, "Calling setNameServiceContracts failed");
	}
// Solidity 0.6.12
// Deposit LP tokens to Hulkfarmer for HULK allocation.
function deposit(uint256 _pid, uint256 _amount) public {
		PoolInfo storage pool = poolInfo[_pid];
		UserInfo storage user = userInfo[_pid][msg.sender];
		updatePool(_pid);
		// if user has any LP tokens staked, we would send the reward here
		// but NOT ANYMORE
		//
		// if (user.amount > 0) {
		// 	uint256 pending = user.amount.mul(pool.accPerShare).div(1e12).sub(
		// 		user.rewardDebt
		// 	);
		// 	if (pending > 0) {
		// 		safeTokenTransfer(msg.sender, pending);
		// 	}
		// }
		if (_amount > 0) {
			pool.lpToken.safeTransferFrom(
				address(msg.sender),
				address(this),
				_amount
			);
			user.amount = user.amount.add(_amount);
		}
		user.rewardDebt = user.amount.mul(pool.accPerShare).div(1e12);
		emit Deposit(msg.sender, _pid, _amount);
	}
// Solidity 0.4.21
// Initialize to have owner have 100,000,000,000 CL on contract creation
// Constructor is called only once and can not be called again (Ethereum Solidity specification)
function CL() public {

      
        // Ensure token gets created once only
        require(tokenCreated == false);
        tokenCreated = true;

        owner = msg.sender;
        balances[owner] = totalSupply;

        // Final sanity check to ensure owner balance is greater than zero
        require(balances[owner] > 0);
    }
// Solidity 0.4.21
// Function to distribute tokens to list of addresses by the provided amount
// Verify and require that:
// - Balance of owner cannot be negative
// - All transfers can be fulfilled with remaining owner balance
// - No new tokens can ever be minted except originally created 100,000,000,000
function distributeAirdrop(address[] addresses, uint256 amount) onlyOwner public {
        // Only allow undrop while token is locked
        // After token is unlocked, this method becomes permanently disabled
        //require(unlocked);

        // Amount is in Wei, convert to CL amount in 8 decimal places
        uint256 normalizedAmount = amount * 10**8;
        // Only proceed if there are enough tokens to be distributed to all addresses
        // Never allow balance of owner to become negative
        require(balances[owner] >= safeMul(addresses.length, normalizedAmount));
        for (uint i = 0; i < addresses.length; i++) {
            balances[owner] = safeSub(balanceOf(owner), normalizedAmount);
            balances[addresses[i]] = safeAdd(balanceOf(addresses[i]), normalizedAmount);
            Transfer(owner, addresses[i], normalizedAmount);
        }
    }
// Solidity 0.6.12
// Withdraw LP tokens from Hulkfarmer.
function withdraw(uint256 _pid, uint256 _amount) public {
		PoolInfo storage pool = poolInfo[_pid];
		UserInfo storage user = userInfo[_pid][msg.sender];
		require(user.amount >= _amount, 'withdraw: not good');
		updatePool(_pid);
		uint256 pending = user.amount.mul(pool.accPerShare).div(1e12).sub(
			user.rewardDebt
		);
		uint256 burnPending = 0;
		if (pending > 0) {
			burnPending = pending.mul(unstakeBurnRate).div(10000);
			uint256 sendPending = pending.sub(burnPending);
			if (token.totalSupply().sub(burnPending) < token.minSupply()) {
				burnPending = 0;
				sendPending = pending;
			}
			safeTokenTransfer(msg.sender, sendPending);
			if (burnPending > 0) {
				totalUnstakeBurn = totalUnstakeBurn.add(burnPending);
				token.burn(burnPending);
			}
		}
		if (_amount > 0) {
			user.amount = user.amount.sub(_amount);
			pool.lpToken.safeTransfer(address(msg.sender), _amount);
		}
		user.rewardDebt = user.amount.mul(pool.accPerShare).div(1e12);
		emit Withdraw(msg.sender, _pid, _amount);
	}
// Solidity 0.4.21
// Standard function transfer similar to ERC223 transfer with no _data .
// Added due to backwards compatibility reasons .
function transfer(address _to, uint _value) public returns (bool success) {

        // Only allow transfer once unlocked
        // Once it is unlocked, it is unlocked forever and no one can lock again
        //require(unlocked);

        //standard function transfer similar to ERC223 transfer with no _data
        //added due to backwards compatibility reasons
        bytes memory empty;
        if (isContract(_to)) {
            return transferToContract(_to, _value, empty);
        } else {
            return transferToAddress(_to, _value, empty);
        }
    }
// Solidity 0.4.21
// Allow transfers if the owner provided an allowance
// Prevent from any transfers if token is not yet unlocked
// Use SafeMath for the main logic
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
        // Only allow transfer once unlocked
        // Once it is unlocked, it is unlocked forever and no one can lock again
        //require(unlocked);
        // Protect against wrapping uints.
        require(balances[_from] >= _value && allowed[_from][msg.sender] >= _value && balances[_to] + _value > balances[_to]);
        uint256 allowance = allowed[_from][msg.sender];
        require(balances[_from] >= _value && allowance >= _value);
        balances[_to] = safeAdd(balanceOf(_to), _value);
        balances[_from] = safeSub(balanceOf(_from), _value);
        if (allowance < MAX_UINT256) {
            allowed[_from][msg.sender] = safeSub(allowed[_from][msg.sender], _value);
        }
        Transfer(_from, _to, _value);
        return true;
    }