lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.8.6
/**
 * @dev function to claim the Frens NFT
 */
function claimNFF()
        external
        onlyWhitelisted
    {
        //validation before minting
        require(
            maxTokensPerWallet[msg.sender] == 0,
            "NFF: You are not allowed to mint anymore tokens"
        );
        require(
            _pauseContract == false,
             "NFF: Contract is paused!"
        );

        maxTokensPerWallet[msg.sender] += 1;
        setTraitName(_tokenIds.current());
        setTraitValue(_tokenIds.current());
        _safeMint(msg.sender, _tokenIds.current());
        _tokenIds.increment();
    }
// Solidity 0.8.6
/**
 * @dev override the tokenURI and generate the metadata on-chain
 */
function tokenURI(uint256 tokenId)
    public
    view
    override
    returns (string memory)
    {
    require(
      _exists(tokenId),
      "ERC721Metadata: URI query for nonexistent token"
    );

    return
        string(
            abi.encodePacked(
                "data:application/json;base64,",
                FrensLib.encode(
                    bytes(
                        string(
                            abi.encodePacked(
                                '{"name": "Non Fungible Frens Cartridge #',
                                FrensLib.toString(tokenId),
                                '","description": "The NFF genesis cartridge permits access to the Frens Discord restricted channels. Each holder is entitled to a vote in the governance of the Non Fungible Frens DAO.", "image":"',
                                imageURI,
                                '","animation_url":"',
                                animationURI,
                                '","attributes":',
                                hashToMetadata(tokenId),
                                "}"
                            )
                        )
                    )
                )
            )
        );
    }
// Solidity 0.8.6
/**
 * @dev set the initial lvl value for the trait
 */
function setTraitValue(uint _tokenId)
        internal
    {
        SEED++;
        uint tempValue = uint256(
            keccak256(
                abi.encodePacked(
                    block.timestamp,
                    block.difficulty,
                    _tokenId,
                    msg.sender,
                    SEED
                )
            )
        ) % 100;

        if (tempValue == 0) tempValue = 1;

        traitTypes[_tokenId].traitValue = uint8(tempValue);
    }
// Solidity 0.5.16
// BURNER INTERFACE
function initiateTokenBurn(uint256 _tokenId) external {
    require(msg.sender == burner, "Only burner allowed");
    require(burnTimeoutAt[_tokenId] == 0, "Burn already initiated");
    require(tokenContract.ownerOf(_tokenId) != address(0), "Token doesn't exists");

    uint256 duration = burnTimeoutDuration[_tokenId];
    if (duration == 0) {
      duration = defaultBurnTimeoutDuration;
    }

    uint256 timeoutAt = block.timestamp.add(duration);
    burnTimeoutAt[_tokenId] = timeoutAt;

    emit InitiateTokenBurn(_tokenId, timeoutAt);
  }
// Solidity 0.5.16
// CONTROLLER INTERFACE
function setInitialDetails(
    uint256 _privatePropertyId,
    IPPToken.TokenType _tokenType,
    IPPToken.AreaSource _areaSource,
    uint256 _area,
    bytes32 _ledgerIdentifier,
    string calldata _humanAddress,
    string calldata _dataLink,
    bool _claimUniqueness
  )
    external
    onlyMinter
  {
    // Will REVERT if there is no owner assigned to the token
    tokenContract.ownerOf(_privatePropertyId);

    uint256 setupStage = tokenContract.getSetupStage(_privatePropertyId);
    require(setupStage == uint256(PropertyInitialSetupStage.PENDING), "Requires PENDING setup stage");

    tokenContract.setDetails(_privatePropertyId, _tokenType, _areaSource, _area, _ledgerIdentifier, _humanAddress, _dataLink);

    tokenContract.incrementSetupStage(_privatePropertyId);

    _updateDetailsUpdatedAt(_privatePropertyId);

    tokenContract.setPropertyExtraData(_privatePropertyId, CLAIM_UNIQUENESS_KEY, bytes32(uint256(_claimUniqueness ? 1 : 0)));
  }
// Solidity 0.5.16
// COMMON INTERFACE
function propose(
    bytes calldata _data,
    string calldata _dataLink
  )
    external
    payable
  {
    address msgSender = msg.sender;
    uint256 tokenId = fetchTokenId(_data);
    uint256 proposalId = _nextId();

    Proposal storage p = proposals[proposalId];

    if (msgSender == geoDataManager) {
      p.geoDataManagerApproved = true;
    } else if (msgSender == tokenContract.ownerOf(tokenId)) {
      _acceptProposalFee();
      p.tokenOwnerApproved = true;
    } else {
      revert("Missing permissions");
    }

    p.creator = msgSender;
    p.data = _data;
    p.dataLink = _dataLink;
    p.status = ProposalStatus.PENDING;

    emit NewProposal(proposalId, tokenId, msg.sender);
  }
// Solidity 0.5.16
// PERMISSIONLESS INTERFACE
function execute(uint256 _proposalId) public {
    Proposal storage p = proposals[_proposalId];

    require(p.tokenOwnerApproved == true, "Token owner approval required");
    require(p.geoDataManagerApproved == true, "GeoDataManager approval required");
    require(p.status == ProposalStatus.APPROVED, "Expect APPROVED status");

    _preExecuteHook(p.data);

    p.status = ProposalStatus.EXECUTED;

    (bool ok,) = address(tokenContract)
      .call
      .gas(gasleft().sub(50000))(p.data);

    if (ok == false) {
      emit ProposalExecutionFailed(_proposalId);
      p.status = ProposalStatus.APPROVED;
    } else {
      emit ProposalExecuted(_proposalId);
    }
  }
// Solidity 0.5.16
// USER INTERFACE
function build(
    string calldata _tokenName,
    string calldata _tokenSymbol,
    string calldata _dataLink,
    uint256 _defaultBurnDuration,
    bytes32[] calldata _feeKeys,
    uint256[] calldata _feeValues,
    bytes32 _legalAgreementIpfsHash
  )
    external
    payable
    returns (address)
  {
    _acceptPayment();

    // building contracts
    PPToken ppToken = new PPToken(
      _tokenName,
      _tokenSymbol
    );
    PPTokenController ppTokenController = ppTokenControllerFactory.build(globalRegistry, ppToken, _defaultBurnDuration);

    // setting up contracts
    ppToken.setContractDataLink(_dataLink);
    ppToken.setLegalAgreementIpfsHash(_legalAgreementIpfsHash);
    ppToken.setController(address(ppTokenController));
    ppTokenController.setMinter(msg.sender);
    ppTokenController.setGeoDataManager(msg.sender);

    ppTokenController.setFeeManager(address(this));

    for (uint256 i = 0; i < _feeKeys.length; i++) {
      ppTokenController.setFee(_feeKeys[i], _feeValues[i]);
    }

    ppTokenController.setFeeManager(msg.sender);
    ppTokenController.setFeeCollector(msg.sender);

    // transferring ownership
    ppTokenController.transferOwnership(msg.sender);
    ppToken.transferOwnership(msg.sender);

    IPPTokenRegistry(globalRegistry.getPPTokenRegistryAddress())
      .addToken(address(ppToken));

    emit Build(address(ppToken), address(ppTokenController));

    return address(ppToken);
  }
// Solidity 0.6.12
/// @notice converts number to string
/// @dev source: https://github.com/provable-things/ethereum-api/blob/master/oraclizeAPI_0.5.sol#L1045
/// @param _i integer to convert
/// @return _uintAsString
function uintToStr(uint _i) internal pure returns (string memory _uintAsString) {
        uint number = _i;
        if (number == 0) {
            return "0";
        }
        uint j = number;
        uint len;
        while (j != 0) {
            len++;
            j /= 10;
        }
        bytes memory bstr = new bytes(len);
        uint k = len - 1;
        while (number != 0) {
            bstr[k--] = byte(uint8(48 + number % 10));
            number /= 10;
        }
        return string(bstr);
    }
// Solidity 0.6.12
/**
 * @dev function withdraw ETH to account owner
 * @param _amount is amount withdraw
 */
function withdrawETH(uint256 _amount) external onlyOwner {
        require(_amount > 0, "_amount must be greater than 0");
        require(
            address(this).balance >= _amount,
            "_amount must be less than the ETH balance of the contract"
        );
        msg.sender.transfer(_amount);
    }
// Solidity 0.8.11
//@dev returns the tokenURI of tokenID
function tokenURI(uint256 tokenId)
        public
        view
        virtual
        override
        returns (string memory)
    {
        require(
        _exists(tokenId),
        "Huey: URI query for nonexistent token"
        );
        

        string memory currentBaseURI = _baseURI();
        return bytes(currentBaseURI).length > 0
           ? string(abi.encodePacked(currentBaseURI, CurrentHash))
            : "";
    }
// Solidity 0.8.7
// Withdraw to notifinance + board
function withdraw() public payable onlyOwner {
        // 1% of all profits are split between members of the board
        uint256 boardCut = address(this).balance * 1 / 100;

        for (uint i = 0; i < board.length - 1; i++) {
            (bool hs, ) = payable(board[i]).call{value: boardCut / board.length}("");
            require(hs);
        }

        // Rest is sent to noti.finance
        (bool os, ) = payable(owner()).call{value: address(this).balance}("");
        require(os);
    }
// Solidity 0.8.7
// Whitelist mint - whitelisted users can mint up to the max mint amount
function whitelistMint(uint256 amount) public payable mintable(amount) {
        require(status == Status.WHITELIST, "Whitelist sale currently unavailable");
        require(whitelisted[msg.sender] == true, "You are not whitelisted");
        require(numMinted[msg.sender] + amount <= maxMintPerWallet, "You reached the max mintable.");
        mint(amount);
    }
// Solidity 0.4.26
// Action functions
function changeContractOwner(address _newOwner) public {
    require (msg.sender == owner); // Only the current owner can change the ownership of the contract
    
    owner = _newOwner; // Update the owner

     // Trigger ownership change event.
    emit ChangedOwnership(_newOwner);
  }
// Solidity 0.4.26
// fiatTrader adds collateral to the open swap
function addFiatTraderCollateral(bytes32 _tradeID, uint256 _erc20Value) public onlyInitializedSwaps(_tradeID) {
    Swap storage swap = swaps[_tradeID]; // Get information about the swap position
    require (_erc20Value >= swap.daiTraderCollateral); // Cannot send less than what the daiTrader has in collateral
    require (msg.sender == swap.fiatTrader); // Only the fiatTrader can add to the swap position
    // Check the allowance
    ERC20 daiContract = ERC20(daiAddress); // Load the DAI contract
    require(_erc20Value <= daiContract.allowance(msg.sender, address(this))); // We must transfer less than that we approve in the ERC20 token contract   
    swap.fiatTraderCollateral = _erc20Value;
    swap.swapState = States.ACTIVE; // Now fiatTrader needs to send fiat

    // Now transfer the tokens
    require(daiContract.transferFrom(msg.sender, address(this), _erc20Value)); // Now take the tokens from the sending user and store in this contract    
  }
// Solidity 0.4.26
// daiTrader is refunding as fiatTrader never sent the collateral
function refundSwap(bytes32 _tradeID) public onlyInitializedSwaps(_tradeID) {
    // Refund the swap.
    Swap storage swap = swaps[_tradeID];
    require (msg.sender == swap.daiTrader); // Only the daiTrader can call this function to refund
    swap.swapState = States.REFUNDED; // Swap is now refunded, sending all DAI back

    // Transfer the DAI value from this contract back to the DAI trader.
    ERC20 daiContract = ERC20(daiAddress); // Load the DAI contract
    require(daiContract.transfer(swap.daiTrader, swap.sendAmount + swap.daiTraderCollateral));

     // Trigger cancel event.
    emit Canceled(_tradeID, 0);
  }
// Solidity 0.4.26
// daiTrader is aborting as fiatTrader failed to hold up its part of the swap
// Aborting refunds the sendAmount to daiTrader but returns part of the collateral based on the penalty
// Penalty must be between 75-100%
function diaTraderAbort(bytes32 _tradeID, uint256 penaltyPercent) public onlyActiveSwaps(_tradeID) {
    // diaTrader aborted the swap.
    require (penaltyPercent >= 75000 && penaltyPercent <= 100000); // Penalty must be between 75-100%

    Swap storage swap = swaps[_tradeID];
    require (msg.sender == swap.daiTrader); // Only the daiTrader can call this function to abort
    swap.swapState = States.DAIABORT; // Swap is now aborted

    // Calculate the penalty amounts
    uint256 penaltyAmount = (swap.daiTraderCollateral * penaltyPercent) / 100000;
    ERC20 daiContract = ERC20(daiAddress); // Load the DAI contract
    if(penaltyAmount > 0){
      swap.feeAmount = penaltyAmount;
      require(daiContract.transfer(owner, penaltyAmount * 2));
    }   

    // Transfer the DAI send amount and collateral from this contract back to the DAI trader.
    require(daiContract.transfer(swap.daiTrader, swap.sendAmount + swap.daiTraderCollateral - penaltyAmount));
  
    // Transfer the DAI collateral from this contract back to the fiat trader.
    require(daiContract.transfer(swap.fiatTrader, swap.fiatTraderCollateral - penaltyAmount));

     // Trigger cancel event.
    emit Canceled(_tradeID, penaltyAmount);
  }
// Solidity 0.4.26
// fiatTrader is aborting due to unexpected difficulties sending fiat
// Aborting refunds the sendAmount to daiTrader but returns part of the collateral based on the penalty
// Penalty must be between 2.5-100%
function fiatTraderAbort(bytes32 _tradeID, uint256 penaltyPercent) public onlyActiveSwaps(_tradeID) {
    // fiatTrader aborted the swap.
    require (penaltyPercent >= 2500 && penaltyPercent <= 100000); // Penalty must be between 2.5-100%

    Swap storage swap = swaps[_tradeID];
    require (msg.sender == swap.fiatTrader); // Only the fiatTrader can call this function to abort
    swap.swapState = States.FIATABORT; // Swap is now aborted

    // Calculate the penalty amounts
    uint256 penaltyAmount = (swap.daiTraderCollateral * penaltyPercent) / 100000;
    ERC20 daiContract = ERC20(daiAddress); // Load the DAI contract
    if(penaltyAmount > 0){
      swap.feeAmount = penaltyAmount;
      require(daiContract.transfer(owner, penaltyAmount * 2));
    }   

    // Transfer the DAI send amount and collateral from this contract back to the DAI trader.
    require(daiContract.transfer(swap.daiTrader, swap.sendAmount + swap.daiTraderCollateral - penaltyAmount));
  
    // Transfer the DAI collateral from this contract back to the fiat trader.
    require(daiContract.transfer(swap.fiatTrader, swap.fiatTraderCollateral - penaltyAmount));

     // Trigger cancel event.
    emit Canceled(_tradeID, penaltyAmount);
  }
// Solidity 0.6.12
/* Trying out function parameters for a functional map */
function mapToken(IERC20[] storage self, function (IERC20) view returns (uint256) f) internal view returns (uint256[] memory r) {
    uint256 len = self.length;
    r = new uint[](len);
    for (uint i = 0; i < len; i++) {
      r[i] = f(self[i]);
    }
  }
// Solidity 0.6.12
// function rewardExtras() onlyHarvester external view returns(uint256[] memory totals) {
//   totals = new uint256[](_rewards.length);
//   for (uint256 i = 0; i < _rewards.length; i++) {
//     totals[i] = _rewardExtra[_rewards[i]];
//   }
// }
function owedRewards() external view returns(uint256[] memory rewards) {
    rewards = new uint256[](_rewards.length);
    mapping (IERC20 => uint256) storage owed = _owedRewards[msg.sender];
    for (uint256 i = 0; i < _rewards.length; i++) {
      IERC20 token = _rewards[i];
      rewards[i] = owed[token];
    }
  }
// Solidity 0.4.24
/**
 * @dev Withdraw tokens only after the deliveryTime.
 */
function withdrawTokens() public {
    require(goalReached());
    // solium-disable-next-line security/no-block-members
    require(block.timestamp > deliveryTime);
    super.withdrawTokens();
    uint256 _bonusTokens = bonuses[msg.sender];
    if (_bonusTokens > 0) {
      bonuses[msg.sender] = 0;
      require(token.approve(address(timelockController), _bonusTokens));
      require(
        timelockController.createInvestorTokenTimeLock(
          msg.sender,
          _bonusTokens,
          deliveryTime,
          this
        )
      );
    }
  }
// Solidity 0.4.24
/**
 * @dev Executed when a purchase has been validated and is ready to be executed. Not necessarily emits/sends tokens.
 * It computes the bonus and store it using the timelockController.
 * @param _beneficiary Address receiving the tokens
 * @param _tokenAmount Number of tokens to be purchased
 */
function _processPurchase( address _beneficiary, uint256 _tokenAmount ) internal {
    uint256 _totalTokens = _tokenAmount;
    // solium-disable-next-line security/no-block-members
    uint256 _bonus = getBonus(block.timestamp, _beneficiary, msg.value);
    if (_bonus>0) {
      uint256 _bonusTokens = _tokenAmount.mul(_bonus).div(100);
      // make sure the crowdsale contract has enough tokens to transfer the purchased tokens and to create the timelock bonus.
      uint256 _currentBalance = token.balanceOf(this);
      require(_currentBalance >= _totalTokens.add(_bonusTokens));
      bonuses[_beneficiary] = bonuses[_beneficiary].add(_bonusTokens);
      _totalTokens = _totalTokens.add(_bonusTokens);
    }
    tokensToBeDelivered = tokensToBeDelivered.add(_totalTokens);
    super._processPurchase(_beneficiary, _tokenAmount);
  }
// Solidity 0.4.24
/**
 * @dev Computes the bonus. The bonus is
 * - 0 by default
 * - 30% before reaching the softCap for those whitelisted.
 * - 15% the first week
 * - 10% the second week
 * - 8% the third week
 * - 6% the remaining time.
 * @param _time when the purchased happened.
 * @param _beneficiary Address performing the token purchase.
 * @param _value Value in wei involved in the purchase.
 */
function getBonus(uint256 _time, address _beneficiary, uint256 _value) view internal returns (uint256 _bonus) {
    //default bonus is 0.
    _bonus = 0;
    
    // at this level the amount was added to weiRaised
    if ( (weiRaised.sub(_value) < goal) && earlyInvestors.whitelist(_beneficiary) ) {
      _bonus = 30;
    } else {
      if (_time < openingTime.add(7 days)) {
        _bonus = 15;
      } else if (_time < openingTime.add(14 days)) {
        _bonus = 10;
      } else if (_time < openingTime.add(21 days)) {
        _bonus = 8;
      } else {
        _bonus = 6;
      }
    }
    return _bonus;
  }
// Solidity 0.4.24
/**
 * @dev Performs the finalization tasks:
 * - if goal reached, activate the controller and burn the remaining tokens
 * - transfer the ownership of the token contract back to the owner.
 */
function finalization() internal {
    // only when the goal is reached we burn the tokens and activate the controller.
    if (goalReached()) {
      // activate the controller to enable the investors and team members 
      // to claim their tokens when the time comes.
      timelockController.activate();

      // calculate the quantity of tokens to be burnt. The bonuses are already transfered to the Controller.
      uint256 balance = token.balanceOf(this);
      uint256 remainingTokens = balance.sub(tokensToBeDelivered);
      if (remainingTokens>0) {
        BurnableTokenInterface(address(token)).burn(remainingTokens);
      }
    }
    Ownable(address(token)).transferOwnership(owner);
    super.finalization();
  }
// Solidity 0.8.9
/**
 * @notice Create new vesting schedules in a batch
 * @notice A transfer is used to bring tokens into the VestingDepositAccount so pre-approval is required
 * @param _beneficiaries array of beneficiaries of the vested tokens
 * @param _amounts array of amount of tokens (in wei)
 * @dev array index of address should be the same as the array index of the amount
 */
function createVestingSchedules(
        address[] calldata _beneficiaries,
        uint256[] calldata _amounts
    ) external onlyOwner {
        require(
            _beneficiaries.length > 0,
            "VestingContract::createVestingSchedules: Empty Data"
        );
        require(
            _beneficiaries.length == _amounts.length,
            "VestingContract::createVestingSchedules: Array lengths do not match"
        );

        for (uint256 i = 0; i < _beneficiaries.length; i++) {
            _createVestingSchedule(_beneficiaries[i], _amounts[i]);
        }
    }
// Solidity 0.6.6
/// @notice Fetches Compound prices for tokens
/// @param _cTokens Arr. of cTokens for which to get the prices
/// @return prices Array of prices
function getPrices(address[] memory _cTokens) public view returns (uint[] memory prices) {
        prices = new uint[](_cTokens.length);
        address oracleAddr = comp.oracle();

        for (uint i = 0; i < _cTokens.length; ++i) {
            prices[i] = CompoundOracleInterface(oracleAddr).getUnderlyingPrice(_cTokens[i]);
        }
    }
// Solidity 0.6.6
/// @notice Fetches all the collateral/debt address and amounts, denominated in usd
/// @param _user Address of the user
/// @return data LoanData information
function getLoanData(address _user) public view returns (LoanData memory data) {
        address[] memory assets = comp.getAssetsIn(_user);
        address oracleAddr = comp.oracle();

        data = LoanData({
            user: _user,
            ratio: 0,
            collAddr: new address[](assets.length),
            borrowAddr: new address[](assets.length),
            collAmounts: new uint[](assets.length),
            borrowAmounts: new uint[](assets.length)
        });

        uint collPos = 0;
        uint borrowPos = 0;

        for (uint i = 0; i < assets.length; i++) {
            address asset = assets[i];

            (, uint cTokenBalance, uint borrowBalance, uint exchangeRateMantissa)
                                        = CTokenInterface(asset).getAccountSnapshot(_user);

            Exp memory oraclePrice;

            if (cTokenBalance != 0 || borrowBalance != 0) {
                oraclePrice = Exp({mantissa: CompoundOracleInterface(oracleAddr).getUnderlyingPrice(asset)});
            }

            // Sum up collateral in Usd
            if (cTokenBalance != 0) {
                Exp memory exchangeRate = Exp({mantissa: exchangeRateMantissa});
                (, Exp memory tokensToUsd) = mulExp(exchangeRate, oraclePrice);

                data.collAddr[collPos] = asset;
                (, data.collAmounts[collPos]) = mulScalarTruncate(tokensToUsd, cTokenBalance);
                collPos++;
            }

            // Sum up debt in Usd
            if (borrowBalance != 0) {
                data.borrowAddr[borrowPos] = asset;
                (, data.borrowAmounts[borrowPos]) = mulScalarTruncate(oraclePrice, borrowBalance);
                borrowPos++;
            }
        }

        data.ratio = uint128(getSafetyRatio(_user));

        return data;
    }
// Solidity 0.6.6
/// @notice Information about cTokens
/// @param _cTokenAddresses Array of cTokens addresses
/// @return tokens Array of cTokens infomartion
function getTokensInfo(address[] memory _cTokenAddresses) public returns(TokenInfo[] memory tokens) {
        tokens = new TokenInfo[](_cTokenAddresses.length);
        address oracleAddr = comp.oracle();

        for (uint i = 0; i < _cTokenAddresses.length; ++i) {
            (, uint collFactor) = comp.markets(_cTokenAddresses[i]);

            tokens[i] = TokenInfo({
                cTokenAddress: _cTokenAddresses[i],
                underlyingTokenAddress: getUnderlyingAddr(_cTokenAddresses[i]),
                collateralFactor: collFactor,
                price: CompoundOracleInterface(oracleAddr).getUnderlyingPrice(_cTokenAddresses[i])
            });
        }
    }