lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.8.4
/**
 * @dev Registers a username to an address, such that the address will own a subdomain of zappermail.eth
 * i.e.: If a user registers "joe", they will own "joe.zappermail.eth"
 * @param _account - Address of the new owner of the username
 * @param _node - Subdomain node to be registered
 * @param _username - Username being requested
 * @param _publicKey - The Zapper mail encryption public key for this username
 * @param _signature - Verified signature granting account the subdomain
 */
function registerUser(
        address _account,
        bytes32 _node,
        string calldata _username,
        string calldata _publicKey,
        bytes calldata _signature
    ) external pausable {
        // Confirm that the signature matches that of the sender
        require(
            verify(_account, _publicKey, _signature),
            "Err: Invalid Signature"
        );

        // Validate that the node is valid for the given username
        require(
            node(_username) == _node,
            "Err: Node does not match ENS subdomain"
        );

        // Require that the subdomain is not already owned or owned by this registry
        require(
            registry.owner(_node) == address(0) ||
                registry.owner(_node) == address(this),
            "Err: Subdomain already owned"
        );

        // Take ownership of the subdomain and configure it
        bytes32 usernameHash = keccak256(bytes(_username));
        registry.setSubnodeOwner(baseNode, usernameHash, address(this));
        registry.setResolver(_node, address(resolver));
        resolver.setAddr(_node, _account);
        registry.setOwner(_node, address(this));

        // Emit event to index users on the backend
        emit UserRegistered(
            baseNode,
            usernameHash,
            _account,
            _username,
            _publicKey
        );
    }
// Solidity 0.8.4
/**
 * @dev Batch sends a message to users
 * @param _recipients - Addresses of the recipients of the message
 * @param _hashes - IPFS hashes of the message
 */
function batchSendMessage(
        address[] calldata _recipients,
        string[] calldata _hashes
    ) external pausable {
        require(
            _recipients.length == _hashes.length,
            "Err: Expected same number of recipients as hashes"
        );
        for (uint256 i = 0; i < _recipients.length; i++) {
            emit MessageSent(baseNode, tx.origin, _recipients[i], _hashes[i]);
        }
    }
// Solidity 0.4.24
/**
 * @dev Override update purchasing state
 *      - update sum of funds invested
 *      - if total amount invested higher than KYC amount set KYC required to true
 */
function _updatePurchasingState(address _beneficiary, uint256 _weiAmount) internal {
        super._updatePurchasingState(_beneficiary, _weiAmount);

        uint256 usdAmount = _weiToUsd(_weiAmount);
        usdRaised = usdRaised.add(usdAmount);
        usdInvested[_beneficiary] = usdInvested[_beneficiary].add(usdAmount);
        weiInvested[_beneficiary] = weiInvested[_beneficiary].add(_weiAmount);

        if (usdInvested[_beneficiary] >= KYCRequiredAmountInUsd) {
            KYCRequired[_beneficiary] = true;
        }
    }
// Solidity 0.4.24
/**
 * @dev Must be called after crowdsale ends, to do some extra finalization works.
 */
function finalize() public onlyOwner {
        require(!isFinalized);

        // NOTE: We do this because we would like to allow withdrawals earlier than closing time in case of crowdsale success
        closingTime = block.timestamp;
        weiOnFinalize = address(this).balance;
        isFinalized = true;

        emit Finalized();
    }
// Solidity 0.4.24
/**
 * @dev Send remaining tokens back
 * @param _to Address to send
 * @param _amount Amount to send
 */
function sendTokens(address _to, uint256 _amount) external onlyOwner {
        if (!isFinalized || goalReached) {
            // NOTE: if crowdsale not finished or successful we should keep at least tokens sold
            _ensureTokensAvailable(_amount);
        }

        token.transfer(_to, _amount);
    }
// Solidity 0.4.24
/**
 * @dev Override process purchase
 *      - additionally sum tokens sold
 */
function _processPurchase(address _beneficiary, uint256 _tokenAmount) internal {
        super._processPurchase(_beneficiary, _tokenAmount);

        tokensSold = tokensSold.add(_tokenAmount);

        if (pledgeOpen()) {
            // NOTE: In case of buying tokens inside pledge it doesn't matter how we decrease pledge as we change it anyway
            _decreasePledge(_beneficiary, _tokenAmount);
        }
    }
// Solidity 0.4.24
/**
 * @dev Air drops tokens to users
 * @param _addresses list of addresses
 * @param _tokens List of tokens to drop
 */
function airDropTokens(address[] _addresses, uint256[] _tokens) external onlyOwnerOrOracle {
        require(_addresses.length == _tokens.length);
        _ensureTokensListAvailable(_tokens);

        for (uint16 index = 0; index < _addresses.length; index++) {
            tokensSold = tokensSold.add(_tokens[index]);
            balances[_addresses[index]] = balances[_addresses[index]].add(_tokens[index]);

            emit AirDrop(_addresses[index], _tokens[index]);
        }
    }
// Solidity 0.5.6
// find participant who has winning ticket
// to start: _begin is 0, _end is last index in ticketsInterval array
function getWinner(
        uint _round,
        uint _beginInterval,
        uint _endInterval,
        uint _winningTicket
    )
        internal
        returns (address)
    {
        if (_beginInterval == _endInterval) {
            return rounds[_round].tickets[_beginInterval].participant;
        }

        uint len = _endInterval.add(1).sub(_beginInterval);
        uint mid = _beginInterval.add((len.div(2))).sub(1);
        TicketsInterval memory interval = rounds[_round].tickets[mid];

        if (_winningTicket < interval.firstTicket) {
            return getWinner(_round, _beginInterval, mid, _winningTicket);
        } else if (_winningTicket > interval.lastTicket) {
            return getWinner(_round, mid.add(1), _endInterval, _winningTicket);
        } else {
            return interval.participant;
        }
    }
// Solidity 0.8.6
// Implementing the fastest and most trivial algorithm I could find.
// https://weblog.jamisbuck.org/2011/2/1/maze-generation-binary-tree-algorithm
function getMazeData(uint id) public pure returns (uint[FIELD_SIZE] memory) {
        uint[FIELD_SIZE] memory bitfield;
        uint cell;
        uint randInt = semiRandomData(id);
        bool goSouth;
        // Initialize a bit field
        for (uint i = 0; i < FIELD_SIZE; i = i + 1) {
            cell = 31;
            randInt = semiRandomData(randInt);
            // coin filt to decide if I should go south or east
            goSouth = (randInt % 1000) >= 500;
            uint[2] memory rowCol = bitIndexToRowCol(i);
            if (goSouth) {
                if (rowCol[0] < (MAZE_SIZE - 1)) {
                    cell = cell & ~SOUTH_WALL;
                } else if (rowCol[1] < (MAZE_SIZE -1)) {
                    cell = cell & ~EAST_WALL;
                }
            } else {
                if (rowCol[1] < (MAZE_SIZE - 1)) {
                    cell = cell & ~EAST_WALL;
                } else if (rowCol[0] < (MAZE_SIZE) - 1){
                    cell = cell & ~SOUTH_WALL;
                }
            }
            bitfield[i] = cell;
        }
        return bitfield;

    }
// Solidity 0.4.18
/**
 * Add `_account` to the whitelist
 *
 * If an account is currently disabled, the account is reenabled, otherwise 
 * a new entry is created
 *
 * @param _account The account to add
 */
function add(address _account) public only_owner {
        if (!hasEntry(_account)) {
            list[_account] = Entry(
                now, true, listIndex.push(_account) - 1);
        } else {
            Entry storage entry = list[_account];
            if (!entry.accepted) {
                entry.accepted = true;
                entry.datetime = now;
            }
        }
    }
// Solidity 0.8.7
/**
 * @dev See {IERC721-ownerOf}.
 */
function ownerOf(uint256 tokenId) public view override returns (address) {
        uint256 curr = tokenId;

        if (_exists(curr)) {
            address add;
            if (_tokenIdToAddress[curr] != address(0)) return _tokenIdToAddress[curr];
            while (true) {
                curr--;
                add = _tokenIdToAddress[curr];
                if (add != address(0)) return add;
            }
        }
        revert QueryForNonexistentToken();
    }
// Solidity 0.8.7
/**
 * @dev Returns whether `tokenId` exists.
 *
 * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
 *
 * Tokens start existing when they are minted (`_mint`),
 * and stop existing when they are burned (`_burn`).
 */
function _exists(uint256 tokenId) internal view virtual returns (bool) {
        uint256 curr = tokenId;
        if (curr <_currentIndex && curr >0){
            if (_tokenIdToAddress[curr] != address(0)) {
                return true;
            }
            while (true) {
                curr--;
                if (_tokenIdToAddress[curr] != address(0)) {
                    return true;
                }
            }
        }
        else if (tokenId >100000 && tokenId <100020){
            return _tokenIdToAddress[tokenId] != address(0);
        }
        revert QueryForNonexistentToken();
    }
// Solidity 0.6.12
/// @notice Claim MGG for a given HOE ID
/// @param tokenId The tokenId of the HOE NFT
function claimById(uint256 tokenId, uint256 week) external nonReentrant{

      // Check that the msgSender owns the token that is being claimed
      require(
          msg.sender == hoeContract.ownerOf(tokenId),
          "MUST_OWN_TOKEN_ID"
      );

      require(
          !weekClaimedByTokenId[week][tokenId],
          "Already Claimed"
      );

      // Further Checks, Effects, and Interactions are contained within the
      // _claim() function
      _claim(tokenId, msg.sender, week);
  }
// Solidity 0.6.12
/// @notice Claim MGG for all tokens owned by the sender
/// @notice This function will run out of gas if you have too much HOE!
function claimAllForOwner(uint256 week) external {
        uint256 tokenBalanceOwner = hoeContract.balanceOf(msg.sender);

        // Checks
        require(tokenBalanceOwner > 0, "NO_TOKENS_OWNED");

        // i < tokenBalanceOwner because tokenBalanceOwner is 1-indexed
        for (uint256 i = 0; i < tokenBalanceOwner; i++) {
            // Further Checks, Effects, and Interactions are contained within
            // the _claim() function

            if(!weekClaimedByTokenId[week][hoeContract.tokenOfOwnerByIndex(msg.sender, i)]){
              _claim(
                  hoeContract.tokenOfOwnerByIndex(msg.sender, i),
                  msg.sender,
                  week
              );
            }
        }
    }
// Solidity 0.6.12
/// @dev Internal function to mint MGG upon claiming
function _claim(uint256 tokenId, address tokenOwner, uint256 week) internal {
        // Checks
        // Check that the token ID is in range
        // We use >= and <= to here because all of the token IDs are 0-indexed
        require(
            tokenId >= tokenIdStart && tokenId <= tokenIdEnd,
            "TOKEN_ID_OUT_OF_RANGE"
        );

        require(
            week >= startWeek() && week <= currentWeek(),
            "Need Valid Week"
        );

        // Check that MGG have not already been claimed this week
        // for a given tokenId
        require(
            !weekClaimedByTokenId[week][tokenId],
            "Already Claimed"
        );

        // Mark that MGG has been claimed for this week for the
        // given tokenId
        weekClaimedByTokenId[week][tokenId] = true;



        // Send MGG to the owner of the token ID
        reward.mint(tokenOwner, rewardPerHOEPerWeek);
    }
// Solidity 0.8.7
/// Get the next token ID
/// @dev Randomly gets a new token ID and keeps track of the ones that are still available.
/// @return the next token ID
function nextToken() internal ensureAvailability returns (uint256) {
        
        
        uint256 maxIndex = maxSupply - totalSupply();
        uint256 random = uint256(keccak256(
            abi.encodePacked(
                msg.sender,
                block.coinbase,
                block.difficulty,
                block.gaslimit,
                block.timestamp
            )
        )) % maxIndex;
    
        uint256 value = 0;
        if (tokenMatrix[random] == 0) {
            // If this matrix position is empty, set the value to the generated random number.
            value = random;
        } else {
            // Otherwise, use the previously stored number from the matrix.
            value = tokenMatrix[random];
        }
    
        // If the last available tokenID is still unused...
        if (tokenMatrix[maxIndex - 1] == 0) {
            // ...store that ID in the current matrix position.
            tokenMatrix[random] = maxIndex - 1;
        } else {
            // ...otherwise copy over the stored number to the current matrix position.
            tokenMatrix[random] = tokenMatrix[maxIndex - 1];
        }
    
        
        
        // Increment counts
       TokenIncrement();
    
        return value + startFrom;
    }
// Solidity 0.8.7
//RandomAssignment Code Ends
function mint(uint256 _mintAmount) public payable {
    require(!paused, "The contract is paused!");
    require(_mintAmount > 0 && _mintAmount <= maxMintAmountPerTx, "Invalid mint amount!");
    require(supply.current() + _mintAmount <= maxSupply, "Max supply exceeded!");
    // require(msg.value >= cost * _mintAmount, "Insufficient funds!");

    
    if(onlyWhitelisted == true) {
        require(isWhitelisted(msg.sender), "user is not whitelisted");
        uint256 ownerMintedCount = addressMintedBalance[msg.sender];
        require(ownerMintedCount + _mintAmount <= WLPerAddressLimit, "max NFT per address exceeded");
    }
     require(msg.value >= cost * _mintAmount, "insufficient funds");
       
    for (uint256 i = 0; i < _mintAmount; i++) {
      addressMintedBalance[msg.sender]++;
      supply.increment();
      _safeMint(msg.sender, nextToken());
    }
  }
// Solidity 0.5.17
/**
 * @notice Allow a user to withdraw any PERI in their schedule that have vested.
 */
function vest() external {
        uint numEntries = numVestingEntries(msg.sender);
        uint total;
        for (uint i = 0; i < numEntries; i++) {
            uint time = getVestingTime(msg.sender, i);
            /* The list is sorted; when we reach the first future time, bail out. */
            if (time > now) {
                break;
            }
            uint qty = getVestingQuantity(msg.sender, i);
            if (qty > 0) {
                vestingSchedules[msg.sender][i] = [0, 0];
                total = total.add(qty);
            }
        }

        if (total != 0) {
            totalVestedBalance = totalVestedBalance.sub(total);
            totalVestedAccountBalance[msg.sender] = totalVestedAccountBalance[msg.sender].sub(total);
            IERC20(address(periFinance)).transfer(msg.sender, total);
            emit Vested(msg.sender, now, total);
        }
    }
// Solidity 0.8.7
/// @dev Internal function to award tokens upon claiming
function _claim(address claimant, uint256 lootBalance) internal {
        uint256 multiplier = lootBalance + 1;
        uint256 totalToAward = award * multiplier;
        if (totalToAward > awardCap) {
            totalToAward = awardCap;
        }

        require(balanceOf(address(this)) >= totalToAward, "SUPPLY_EXHAUSTED");

        claims[season][claimant] = true;

        _transfer(address(this), claimant, totalToAward);
        emit Withdraw(claimant, totalToAward);
    }
// Solidity 0.4.11
/* Adds a user to our list of admins */
function addAdmin(address _address) {
        /* Ensure we're an admin */
        if (!isCurrentAdmin(msg.sender))
            throw;

        // Fail if this account is already admin
        if (adminAddresses[_address])
            throw;
        
        // Add the user
        adminAddresses[_address] = true;
        AdminAdded(msg.sender, _address);
        adminAudit.length++;
        adminAudit[adminAudit.length - 1] = _address;
    }
// Solidity 0.4.11
/* Removes a user from our list of admins but keeps them in the history audit */
function removeAdmin(address _address) {
        /* Ensure we're an admin */
        if (!isCurrentAdmin(msg.sender))
            throw;

        /* Don't allow removal of self */
        if (_address == msg.sender)
            throw;

        // Fail if this account is already non-admin
        if (!adminAddresses[_address])
            throw;

        /* Remove this admin user */
        adminAddresses[_address] = false;
        AdminRemoved(msg.sender, _address);
    }
// Solidity 0.4.11
/* Adds a user/contract to our list of account readers */
function addAccountReader(address _address) {
        /* Ensure we're an admin */
        if (!isCurrentAdmin(msg.sender))
            throw;

        // Fail if this account is already in the list
        if (accountReaderAddresses[_address])
            throw;
        
        // Add the user
        accountReaderAddresses[_address] = true;
        AccountReaderAdded(msg.sender, _address);
        accountReaderAudit.length++;
        accountReaderAudit[adminAudit.length - 1] = _address;
    }
// Solidity 0.4.11
/* Removes a user/contracts from our list of account readers but keeps them in the history audit */
function removeAccountReader(address _address) {
        /* Ensure we're an admin */
        if (!isCurrentAdmin(msg.sender))
            throw;

        // Fail if this account is already not in the list
        if (!accountReaderAddresses[_address])
            throw;

        /* Remove this admin user */
        accountReaderAddresses[_address] = false;
        AccountReaderRemoved(msg.sender, _address);
    }
// Solidity 0.8.6
/**
 @notice
 Gets the current price of ETH for the provided currency.
 
 @param _currency The currency to get a price for.
 
 @return price The price of ETH with 18 decimals.
 */
function getETHPriceFor(uint256 _currency)
        external
        view
        override
        returns (uint256)
    {
        // The 0 currency is ETH itself.
        if (_currency == 0) return 10**targetDecimals;

        // Get a reference to the feed.
        AggregatorV3Interface _feed = feedFor[_currency];

        // Feed must exist.
        require(
            _feed != AggregatorV3Interface(address(0)),
            "Prices::getETHPrice: NOT_FOUND"
        );

        // Get the lateset round information. Only need the price is needed.
        (, int256 _price, , , ) = _feed.latestRoundData();

        // Multiply the price by the decimal adjuster to get the normalized result.
        return uint256(_price) * feedDecimalAdjuster[_currency];
    }
// Solidity 0.8.6
/**
 @notice
 Add a price feed for the price of ETH.
 
 @dev
 Current feeds can't be modified.
 
 @param _feed The price feed being added.
 @param _currency The currency that the price feed is for.
 */
function addFeed(AggregatorV3Interface _feed, uint256 _currency)
        external
        override
        onlyOwner
    {
        // The 0 currency is reserved for ETH.
        require(_currency > 0, "Prices::addFeed: RESERVED");

        // There can't already be a feed for the specified currency.
        require(
            feedFor[_currency] == AggregatorV3Interface(address(0)),
            "Prices::addFeed: ALREADY_EXISTS"
        );

        // Get a reference to the number of decimals the feed uses.
        uint256 _decimals = _feed.decimals();

        // Decimals should be less than or equal to the target number of decimals.
        require(_decimals <= targetDecimals, "Prices::addFeed: BAD_DECIMALS");

        // Set the feed.
        feedFor[_currency] = _feed;

        // Set the decimal adjuster for the currency.
        feedDecimalAdjuster[_currency] = 10**(targetDecimals - _decimals);

        emit AddFeed(_currency, _feed);
    }
// Solidity 0.4.21
//function that is called when transaction target is a contract
//Only used for recycling NSPs
function transferToContract(address _to, uint _value, uint _code) public returns (bool success) {
		require(isContract(_to));
		require(_value <= balances[msg.sender]);
	
    	balances[msg.sender] = balanceOf(msg.sender).sub(_value);
		balances[_to] = balanceOf(_to).add(_value);
		NSPReceiver receiver = NSPReceiver(_to);
		receiver.NSPFallback(msg.sender, _value, _code);
		Transfer(msg.sender, _to, _value);
		
		return true;
	}
// Solidity 0.4.19
//arbitrary versioning scheme. current V4
//funtie naam moet gelijk zijn met de naam hieronder!
function NMBLToken(
        ) {
        balances[0xB5138E4D08e98c20cE5564a956C3869683496D63] = 1000000000000000000000;               // NMBL team gets all tokens in the start
        totalSupply = 1000000000000000000000;                                                        // no comment, total supply
        name = "Nimble";                                                                             // display purposes
        decimals = 7;                                                                                // Amount of decimals for display purposes
        symbol = "NMBL";                                                                             // Symbol
    }
// Solidity 0.6.12
// Deposit LP tokens to MasterSmith for GEM allocation.
function deposit(uint256 _pid, uint256 _amount) public {
        PoolInfo storage pool = poolInfo[_pid];
        UserInfo storage user = userInfo[_pid][msg.sender];
        updatePool(_pid);
        if (user.amount > 0) {
            uint256 pending = user.amount.mul(pool.accGemPerShare).div(1e12).sub(user.rewardDebt);
            safeGemTransfer(msg.sender, pending);
        }
        pool.lpToken.safeTransferFrom(address(msg.sender), address(this), _amount);
        user.amount = user.amount.add(_amount);
        user.rewardDebt = user.amount.mul(pool.accGemPerShare).div(1e12);
        emit Deposit(msg.sender, _pid, _amount);
    }
// Solidity 0.5.4
/**
 	 * @dev `_from` Name position `_value` Logos onto `_to` Name
 	 *
 	 * @param _from The address of the sender
 	 * @param _to The address of the recipient
 	 * @param _value the amount to position
 	 * @return true on success
 	 */
function positionFrom(address _from, address _to, uint256 _value) public isName(_from) isName(_to) nameNotCompromised(_from) nameNotCompromised(_to) onlyAdvocate(_from) senderNameNotCompromised returns (bool) {
		require (_from != _to);	// Can't position Logos to itself
		require (availableToPositionAmount(_from) >= _value); // should have enough balance to position
		require (positionFromOthers[_to].add(_value) >= positionFromOthers[_to]); // check for overflows

		positionOnOthers[_from][_to] = positionOnOthers[_from][_to].add(_value);
		totalPositionOnOthers[_from] = totalPositionOnOthers[_from].add(_value);
		positionFromOthers[_to] = positionFromOthers[_to].add(_value);

		emit PositionFrom(_from, _to, _value);
		return true;
	}