lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.8.7
/// @notice Changes the guardian address
/// @param _newGuardian New guardian address
/// @dev Guardian is able to change by itself the address corresponding to its role
/// @dev There can only be one guardian address in the protocol
/// @dev The guardian address cannot be a governor address
function setGuardian(address _newGuardian) external override onlyGuardian zeroCheck(_newGuardian) {
        require(!governorMap[_newGuardian], "39");
        require(guardian != _newGuardian, "49");
        address oldGuardian = guardian;
        guardian = _newGuardian;
        for (uint256 i = 0; i < _stablecoinList.length; i++) {
            IStableMaster(_stablecoinList[i]).setGuardian(_newGuardian, oldGuardian);
        }
        emit GuardianRoleChanged(oldGuardian, _newGuardian);
    }
// Solidity 0.8.7
// pre-sale
function presaleMint(address _to, uint256 _mintAmount, bytes memory sig) public payable mintConditionsMet(_to, _mintAmount) {
        uint256 supply = totalSupply();
        require(presaleEnabled, "pre-sale is not enabled");
        require(isValidSignedData(sig), "wallet was not signed by the official whitelisting signer");
        for (uint256 i = 1; i <= _mintAmount; i++) {
            _safeMint(_to, supply + i);
            addressMintCount[_to] = (addressMintCount[_to] + _mintAmount);
        }
    }
// Solidity 0.8.9
// purchase presale works
// Purchase multiple NFTs at once
function purchasePresaleTokens(uint256 _howMany)
        external
        payable
        tokensAvailable(_howMany)
    {
        require(
            isSaleActive == false ,
            "presale limit ended"
        );
        require(
            allowListClaimedBy[msg.sender] + _howMany <= allowListMaxMint,
            "Purchase exceeds max allowed"
        );
        require(
            msg.value >= _howMany * itemPricePresale,
            "Try to send more ETH"
        );

        allowListClaimedBy[msg.sender] += _howMany;

        for (uint256 i = 0; i < _howMany; i++)
            _mint(msg.sender, ++circulatingSupply);
    }
// Solidity 0.8.9
// Purchase multiple NFTs at once
function purchaseTokens(uint256 _howMany)
        external
        payable
        tokensAvailable(_howMany)
    {
        require(
            isSaleActive && circulatingSupply <= 10000,
            "Sale is not active"
        );
        require(_howMany > 0 && _howMany <= 20, "Mint min 1, max 20");
        require(msg.value >= _howMany * itemPrice, "Try to send more ETH");

        for (uint256 i = 0; i < _howMany; i++)
            _mint(msg.sender, ++circulatingSupply);
    }
// Solidity 0.8.4
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
 * the total supply from array
 *
 * Emits a `Transfer` event with `from` set to the zero address.
 *
 * Requirements
 *
 * - sender has `MINTER_ROLE`
 * - _receivers array length is from 1 to 100
 * - _amounts array length is equals _receivers array length
 */
function mintTokens(address[] calldata _receivers, uint256[] calldata _amounts) public virtual canMint {
        require(hasRole(MINTER_ROLE, _msgSender()), "ERC20PresetMinter: must have minter role to mint");
        require(_receivers.length > 0 && _receivers.length <= 100, "Token: array must be 1-100 length");
        require(_receivers.length == _amounts.length, "Token: length of receivers and amounts arrays must match");
        for (uint256 i = 0; i < _receivers.length; i++) {
            address to = _receivers[i];
            uint256 amount = _amounts[i];

            _mint(to, amount);
        }
    }
// Solidity 0.6.12
/**
 * @dev Migrate a users' entire balance
 *
 * One way function. Fag tokens are BURNED. Poor tokens are minted.
 */
function migrate() public virtual {

        // gets the Fag for a user.
        uint256 rugBalance = PoorFag(poorFagAddress).balanceOf(_msgSender());

        PoorFag(poorFagAddress).transferFrom(_msgSender(), address(0), rugBalance);

        // mint new PoorRug, using fagValue (1e18 decimal token, to match internalDecimals)
        PoorRug(poorRugAddress).mint(_msgSender(), rugBalance);
    }
// Solidity 0.7.6
/// @notice Function to get amount need to fill up minimum amount keep in vault
/// @param _tokenIndex Type of stablecoin requested
/// @return Amount to reimburse (USDT, USDC 6 decimals, DAI 18 decimals)
function getReimburseTokenAmount(uint256 _tokenIndex) public view returns (uint256) {
        Token memory _token = Tokens[_tokenIndex];
        uint256 _toKeepAmt = getAllPoolInUSD().mul(_token.percKeepInVault).div(DENOMINATOR);
        if (_token.decimals == 18) {
            _toKeepAmt = _toKeepAmt.mul(1e12);
        }
        uint256 _balanceOfToken = _token.token.balanceOf(address(this));
        if (_balanceOfToken < _toKeepAmt) {
            return _toKeepAmt.sub(_balanceOfToken);
        }
        return 0; // amount keep in vault is full
    }
// Solidity 0.8.10
/// @dev withdraw the token in the vault, no limit
/// @param token_ address of the token, use address(0) to withdraw gas token
/// @param destination_ recipient address to receive the fund
/// @param amount_ amount of fund to withdaw
function withdraw(address token_, address destination_, uint256 amount_) public onlyAdmin {
    require(destination_ != address(0), "C98Vault: Destination is zero address");

    uint256 availableAmount;
    if(token_ == address(0)) {
      availableAmount = address(this).balance;
    } else {
      availableAmount = IERC20(token_).balanceOf(address(this));
    }

    require(amount_ <= availableAmount, "C98Vault: Not enough balance");

    uint256 gasLimit = IVaultConfig(_factory).gasLimit();
    if(token_ == address(0)) {
      destination_.call{value:amount_, gas:gasLimit}("");
    } else {
      IERC20(token_).transfer(destination_, amount_);
    }

    emit Withdrawn(_msgSender(), destination_, token_, amount_);
  }
// Solidity 0.8.10
/// @dev create an event to specify how user can claim their token
/// @param eventId_ event ID
/// @param timestamp_ when the token will be available for redemption
/// @param receivingToken_ token user will be receiving, mandatory
/// @param sendingToken_ token user need to send in order to receive *receivingToken_*
function createEvent(uint256 eventId_, uint256 timestamp_, bytes32 merkleRoot_, address receivingToken_, address sendingToken_) public onlyAdmin {
    require(_eventDatas[eventId_].timestamp == 0, "C98Vault: Event existed");
    require(timestamp_ != 0, "C98Vault: Invalid timestamp");
    _eventDatas[eventId_].timestamp = timestamp_;
    _eventDatas[eventId_].merkleRoot = merkleRoot_;
    _eventDatas[eventId_].receivingToken = receivingToken_;
    _eventDatas[eventId_].sendingToken = sendingToken_;
    _eventDatas[eventId_].isActive = 1;

    emit EventCreated(eventId_, _eventDatas[eventId_]);
  }
// Solidity 0.8.10
/// @dev add/remove admin of the vault.
/// @param nAdmins_ list to address to update
/// @param nStatuses_ address with same index will be added if true, or remove if false
/// admins will have access to all tokens in the vault, and can define vesting schedule
function setAdmins(address[] memory nAdmins_, bool[] memory nStatuses_) public onlyOwner {
    require(nAdmins_.length != 0, "C98Vault: Empty arguments");
    require(nStatuses_.length != 0, "C98Vault: Empty arguments");
    require(nAdmins_.length == nStatuses_.length, "C98Vault: Invalid arguments");

    uint256 i;
    for(i = 0; i < nAdmins_.length; i++) {
      address nAdmin = nAdmins_[i];
      if(nStatuses_[i]) {
        if(!_adminStatuses[nAdmin]) {
          _admins.push(nAdmin);
          _adminStatuses[nAdmin] = nStatuses_[i];
          emit AdminAdded(nAdmin);
        }
      } else {
        uint256 j;
        for(j = 0; j < _admins.length; j++) {
          if(_admins[j] == nAdmin) {
            _admins[j] = _admins[_admins.length - 1];
            _admins.pop();
            delete _adminStatuses[nAdmin];
            emit AdminRemoved(nAdmin);
            break;
          }
        }
      }
    }
  }
// Solidity 0.8.10
/// @dev withdraw fee collected for protocol
/// @param token_ address of the token, use address(0) to withdraw gas token
/// @param destination_ recipient address to receive the fund
/// @param amount_ amount of fund to withdaw
function withdraw(address token_, address destination_, uint256 amount_) public onlyOwner {
    require(destination_ != address(0), "C98Vault: Destination is zero address");

    uint256 availableAmount;
    if(token_ == address(0)) {
      availableAmount = address(this).balance;
    } else {
      availableAmount = IERC20(token_).balanceOf(address(this));
    }

    require(amount_ <= availableAmount, "C98Vault: Not enough balance");

    if(token_ == address(0)) {
      destination_.call{value:amount_, gas:_gasLimit}("");
    } else {
      IERC20(token_).transfer(destination_, amount_);
    }

    emit Withdrawn(_msgSender(), destination_, token_, amount_);
  }
// Solidity 0.8.9
// for every penguin 1 sardine can be claimed
function claimSardine(uint256 penguinTokenId) private {
        require(isClaimingActive, "Claim is not active.");
        require(
            !radeem[penguinTokenId],
            "Sardine already claimed for this Penguin token."
        );
        require(
            msg.sender == bastardPenguins.ownerOf(penguinTokenId),
            "You are not the owner of this Penguin token."
        );

        radeem[penguinTokenId] = true;
        _mint(msg.sender, ++circulatingSupply);
    }
// Solidity 0.6.2
/**
 * @dev This one-time operation permanently establishes a vesting schedule in the given account.
 *
 * For standard grants, this establishes the vesting schedule in the beneficiary's account.
 * For uniform grants, this establishes the vesting schedule in the linked grantor's account.
 *
 * @param vestingLocation = Account into which to store the vesting schedule. Can be the account
 *   of the beneficiary (for one-off grants) or the account of the grantor (for uniform grants
 *   made from grant pools).
 * @param cliffDuration = Duration of the cliff, with respect to the grant start day, in days.
 * @param duration = Duration of the vesting schedule, with respect to the grant start day, in days.
 * @param interval = Number of days between vesting increases.
 * @param isRevocable = True if the grant can be revoked (i.e. was a gift) or false if it cannot
 *   be revoked (i.e. tokens were purchased).
 */
function _setVestingSchedule(
        address vestingLocation,
        uint32 cliffDuration, 
		uint32 duration, 
		uint32 interval,
        bool isRevocable) 
		internal returns (bool ok) {

        // Check for a valid vesting schedule given (disallow absurd values to reject likely bad input).
        require(
            duration > 0 && duration <= TEN_YEARS_DAYS
            && cliffDuration < duration
            && interval >= 1,
            "invalid vesting schedule"
        );

        // Make sure the duration values are in harmony with interval (both should be an exact multiple of interval).
        require(
            duration % interval == 0 && cliffDuration % interval == 0,
            "invalid cliff/duration for interval"
        );

        // Create and populate a vesting schedule.
        _vestingSchedules[vestingLocation] = vestingSchedule(
            true/*isValid*/,
            isRevocable,
            cliffDuration, duration, interval
        );

        // Emit the event and return success.
        emit VestingScheduleCreated(
            vestingLocation,
            cliffDuration, duration, interval,
            isRevocable);
        return true;
    }
// Solidity 0.6.2
/**
 * @dev Immediately grants tokens to an address, including a portion that will vest over time
 * according to a set vesting schedule. The overall duration and cliff duration of the grant must
 * be an even multiple of the vesting interval.
 *
 * @param beneficiary = Address to which tokens will be granted.
 * @param totalAmount = Total number of tokens to deposit into the account.
 * @param vestingAmount = Out of totalAmount, the number of tokens subject to vesting.
 * @param startDay = Start day of the grant's vesting schedule, in days since the UNIX epoch
 *   (start of day). The startDay may be given as a date in the future or in the past, going as far
 *   back as year 2000.
 * @param duration = Duration of the vesting schedule, with respect to the grant start day, in days.
 * @param cliffDuration = Duration of the cliff, with respect to the grant start day, in days.
 * @param interval = Number of days between vesting increases.
 * @param isRevocable = True if the grant can be revoked (i.e. was a gift) or false if it cannot
 *   be revoked (i.e. tokens were purchased).
 */
function grantVestingTokens(
        address beneficiary,
        uint256 totalAmount,
        uint256 vestingAmount,
        uint32 startDay,
        uint32 duration,
        uint32 cliffDuration,
        uint32 interval,
        bool isRevocable
    ) public /*onlyGrantor*/ returns (bool ok) {
		require(hasRole(GRANTOR_ROLE, _msgSender()), "must have grantor role");
        // Make sure no prior vesting schedule has been set.
        require(!_tokenGrants[beneficiary].isActive, "grant already exists");

        // The vesting schedule is unique to this wallet and so will be stored here,
        _setVestingSchedule(beneficiary, cliffDuration, duration, interval, isRevocable);

        // Issue grantor tokens to the beneficiary, using beneficiary's own vesting schedule.
        _grantVestingTokens(beneficiary, totalAmount, vestingAmount, startDay, beneficiary, _msgSender());

        return true;
    }
// Solidity 0.6.2
/**
 * @dev returns all information about the grant's vesting as of the given day
 * for the given account. Only callable by the account holder or a grantor, so
 * this is mainly intended for administrative use.
 *
 * @param grantHolder = The address to do this for.
 * @param onDayOrToday = The day to check for, in days since the UNIX epoch. Can pass
 *   the special value 0 to indicate today.
 * return vesting = A tuple with the following values:
 *   amountVested = the amount out of vestingAmount that is vested
 *   amountNotVested = the amount that is vested (equal to vestingAmount - vestedAmount)
 *   amountOfGrant = the amount of tokens subject to vesting.
 *   vestStartDay = starting day of the grant (in days since the UNIX epoch).
 *   vestDuration = grant duration in days.
 *   cliffDuration = duration of the cliff.
 *   vestIntervalDays = number of days between vesting periods.
 *   isActive = true if the vesting schedule is currently active.
 *   wasRevoked = true if the vesting schedule was revoked.
 */
function vestingForAccountAsOf(
        address grantHolder,
        uint32 onDayOrToday
    )
    public
    view
    returns (
        uint256 amountVested,
        uint256 amountNotVested,
        uint256 amountOfGrant,
        uint32 vestStartDay,
        uint32 vestDuration,
        uint32 cliffDuration,
        uint32 vestIntervalDays,
        bool isActive,
        bool wasRevoked
    )
    {
		require(hasRole(GRANTOR_ROLE, _msgSender()) || grantHolder==_msgSender(), "must have grantor role");
		
        tokenGrant storage grant = _tokenGrants[grantHolder];
        vestingSchedule storage vesting = _vestingSchedules[grant.vestingLocation];
        uint256 notVestedAmount = _getNotVestedAmount(grantHolder, onDayOrToday);
        uint256 grantAmount = grant.amount;

        return (
        grantAmount.sub(notVestedAmount),
        notVestedAmount,
        grantAmount,
        grant.startDay,
        vesting.duration,
        vesting.cliffDuration,
        vesting.interval,
        grant.isActive,
        grant.wasRevoked
        );
    }
// Solidity 0.8.9
/**
 * @dev Mints a single token to an address.
 * fee may or may not be required*
 * @param _to address of the future owner of the token
 */
function mintTo(address _to) public payable {
        require(getNextTokenId() <= collectionSize, "Cannot mint over supply cap of 6969");
        require(mintingOpen == true, "Minting is not open right now!");
        
        require(msg.value == PRICE, "Value needs to be exactly the mint fee!");
        
        _safeMint(_to, 1);
        
    }
// Solidity 0.8.9
/**
 * @dev Mints a token to an address with a tokenURI.
 * fee may or may not be required*
 * @param _to address of the future owner of the token
 * @param _amount number of tokens to mint
 */
function mintToMultiple(address _to, uint256 _amount) public payable {
        require(_amount >= 1, "Must mint at least 1 token");
        require(_amount <= maxBatchSize, "Cannot mint more than max mint per transaction");
        require(mintingOpen == true, "Minting is not open right now!");
        
        require(currentTokenId() + _amount <= collectionSize, "Cannot mint over supply cap of 6969");
        require(msg.value == getPrice(_amount), "Value below required mint fee for amount");

        _safeMint(_to, _amount);
        
    }
// Solidity 0.4.20
// valueInTokens : tokens to burn to get dividends
function takeDividends(uint256 valueInTokens) public returns (bool) {

        require(!tokenSaleIsRunning);
        require(this.balance > 0);
        require(totalSupply > 0);

        uint256 sumToPay = (this.balance / totalSupply).mul(valueInTokens);

        totalSupply = totalSupply.sub(valueInTokens);
        balanceOf[msg.sender] = balanceOf[msg.sender].sub(valueInTokens);

        msg.sender.transfer(sumToPay);
        //

        DividendsPaid(msg.sender, valueInTokens, sumToPay);

        return true;
    }
// Solidity 0.4.20
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md#transferfrom
function transferFrom(address _from, address _to, uint256 _value) public returns (bool){

        require(!tokenSaleIsRunning);

        // Transfers of 0 values MUST be treated as normal transfers and fire the Transfer event (ERC-20)
        require(_value >= 0);

        // The function SHOULD throw unless the _from account has deliberately authorized the sender of the message via some mechanism
        require(msg.sender == _from || _value <= allowance[_from][msg.sender]);

        // check if _from account have required amount
        require(_value <= balanceOf[_from]);

        // Subtract from the sender
        // balanceOf[_from] = balanceOf[_from] - _value;
        balanceOf[_from] = balanceOf[_from].sub(_value);
        //
        // Add the same to the recipient
        // balanceOf[_to] = balanceOf[_to] + _value;
        balanceOf[_to] = balanceOf[_to].add(_value);

        // If allowance used, change allowances correspondingly
        if (_from != msg.sender) {
            // allowance[_from][msg.sender] = allowance[_from][msg.sender] - _value;
            allowance[_from][msg.sender] = allowance[_from][msg.sender].sub(_value);
        }

        // event
        Transfer(_from, _to, _value);

        return true;
    }
// Solidity 0.4.20
// value - number of tokens to mint
function mint(address to, uint256 value, uint256 _invested) public returns (bool) {

        require(tokenSaleIsRunning);

        require(msg.sender == owner);

        // tokens for investor
        balanceOf[to] = balanceOf[to].add(value);
        totalSupply = totalSupply.add(value);

        invested = invested.add(_invested);

        if (invested >= hardCap || now.sub(tokenSaleStarted) > salePeriod) {
            tokenSaleIsRunning = false;
        }

        NewTokensMinted(
            to, //...................1
            _invested, //............2
            value, //................3
            msg.sender, //...........4
            !tokenSaleIsRunning, //..5
            invested //..............6
        );
        return true;
    }
// Solidity 0.4.24
//ERC20 code
//See https://github.com/ethereum/EIPs/blob/e451b058521ba6ccd5d3205456f755b1d2d52bb8/EIPS/eip-20.md
function transfer(address destination, uint amount) public returns (bool success) {
        if (balanceOf[msg.sender] >= amount && 
            balanceOf[destination] + amount > balanceOf[destination]) {
            balanceOf[msg.sender] -= amount;
            balanceOf[destination] += amount;
            emit Transfer(msg.sender, destination, amount);
            return true;
        } else {
            return false;
        }
    }
// Solidity 0.4.18
/*
 * @dev Update the key of a node in the list
 * @param _id Node's id
 * @param _newKey Node's new key
 * @param _prevId Id of previous node for the new insert position
 * @param _nextId Id of next node for the new insert position
 */
function updateKey(Data storage self, address _id, uint256 _newKey, address _prevId, address _nextId) public {
        // List must contain the node
        require(contains(self, _id));

        // Remove node from the list
        remove(self, _id);

        if (_newKey > 0) {
            // Insert node if it has a non-zero key
            insert(self, _id, _newKey, _prevId, _nextId);
        }
    }
// Solidity 0.4.18
/*
 * @dev Check if a pair of nodes is a valid insertion point for a new node with the given key
 * @param _key Node's key
 * @param _prevId Id of previous node for the insert position
 * @param _nextId Id of next node for the insert position
 */
function validInsertPosition(Data storage self, uint256 _key, address _prevId, address _nextId) public view returns (bool) {
        if (_prevId == address(0) && _nextId == address(0)) {
            // `(null, null)` is a valid insert position if the list is empty
            return isEmpty(self);
        } else if (_prevId == address(0)) {
            // `(null, _nextId)` is a valid insert position if `_nextId` is the head of the list
            return self.head == _nextId && _key >= self.nodes[_nextId].key;
        } else if (_nextId == address(0)) {
            // `(_prevId, null)` is a valid insert position if `_prevId` is the tail of the list
            return self.tail == _prevId && _key <= self.nodes[_prevId].key;
        } else {
            // `(_prevId, _nextId)` is a valid insert position if they are adjacent nodes and `_key` falls between the two nodes' keys
            return self.nodes[_prevId].nextId == _nextId && self.nodes[_prevId].key >= _key && _key >= self.nodes[_nextId].key;
        }
    }
// Solidity 0.4.18
/*
 * @dev Descend the list (larger keys to smaller keys) to find a valid insert position
 * @param _key Node's key
 * @param _startId Id of node to start ascending the list from
 */
function descendList(Data storage self, uint256 _key, address _startId) private view returns (address, address) {
        // If `_startId` is the head, check if the insert position is before the head
        if (self.head == _startId && _key >= self.nodes[_startId].key) {
            return (address(0), _startId);
        }

        address prevId = _startId;
        address nextId = self.nodes[prevId].nextId;

        // Descend the list until we reach the end or until we find a valid insert position
        while (prevId != address(0) && !validInsertPosition(self, _key, prevId, nextId)) {
            prevId = self.nodes[prevId].nextId;
            nextId = self.nodes[prevId].nextId;
        }

        return (prevId, nextId);
    }
// Solidity 0.4.18
/**
 * @dev Withdraws bonded stake to the caller after unbonding period.
 */
function withdrawStake()
        external
        whenSystemNotPaused
        currentRoundInitialized
    {
        // Delegator must be in the unbonded state
        require(delegatorStatus(msg.sender) == DelegatorStatus.Unbonded);

        uint256 amount = delegators[msg.sender].bondedAmount;
        delegators[msg.sender].bondedAmount = 0;
        delegators[msg.sender].withdrawRound = 0;

        // Tell Minter to transfer stake (LPT) to the delegator
        minter().trustedTransferTokens(msg.sender, amount);

        WithdrawStake(msg.sender);
    }