lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.8.7
/**
 * Token URI
 * Returns a base-64 encoded SVG.
 */
function tokenURI(uint256 _tokenID) override public view returns (string memory) {
    require(_tokenID <= _tokenIDs.current(), "Token doesn't exist.");
    uint mode = _renderingMode[_tokenID];

    uint hour = _getHour(_tokenID);
    bool nightMode = hour < 5 || hour > 18;

    string memory char = _characters[_tokenID];
    string memory image = mode == 0 ? getImage(_tokenID) : generateImage(_tokenID, nightMode);
    string memory json = Base64.encode(bytes(string(abi.encodePacked(
      '{"name":"YeetDAO #',
      Strings.toString(_tokenID),
      ' (',
      char,
      ')","description":"We are artists.\\nWe are developers.\\nWe are musicians.\\nWe are storytellers.\\nWe are curators.\\nWe are futurists.\\n\\nWe are Yeet. ',
      UNICORN_RAINBOW,
      '","attributes":[{"trait_type":"character","value":"',
      char,
      '"}',
      nightMode ? ',{"value":"gn"}' : ',{"value":"gm"}'
      ,'],"image":"',
      image,
      '"}'
    ))));

    return string(abi.encodePacked('data:application/json;base64,', json));
  }
// Solidity 0.5.7
/*
 * Return target * (numerator / denominator), but rounded up.
 */
function getPartialRoundUp(
        uint256 target,
        uint256 numerator,
        uint256 denominator
    )
        internal
        pure
        returns (uint256)
    {
        if (target == 0 || numerator == 0) {
            // SafeMath will check for zero denominator
            return SafeMath.div(0, denominator);
        }
        return target.mul(numerator).sub(1).div(denominator).add(1);
    }
// Solidity 0.5.7
// ============ Helper Functions ============
function getMarketLayout(
        ActionType actionType
    )
        internal
        pure
        returns (MarketLayout)
    {
        if (
            actionType == Actions.ActionType.Deposit
            || actionType == Actions.ActionType.Withdraw
            || actionType == Actions.ActionType.Transfer
        ) {
            return MarketLayout.OneMarket;
        }
        else if (actionType == Actions.ActionType.Call) {
            return MarketLayout.ZeroMarkets;
        }
        return MarketLayout.TwoMarkets;
    }
// Solidity 0.8.7
/**
 * Mint To
 *
 * Requires payment of _mintFee.
 */
function mintTo(
    address _to,
    string memory _character,
    string memory _imageURI,
    bytes memory _signature
  ) public payable returns (uint) {
    require(_tokenIDs.current() + 1 <= _totalSupplyMax, "Total supply reached.");

    uint fee = mintFee();
    if (fee > 0) {
      require(msg.value >= fee, "Requires minimum fee.");

      uint daoSplit = 0.4337 ether;
      payable(owner()).transfer(msg.value - daoSplit);
      payable(_daoAddress).transfer(daoSplit);
    }

    require(_verify(msg.sender, _character, _imageURI, _signature), "Unauthorized.");

    bytes32 memberHash = keccak256(abi.encodePacked(_character));
    require(characterTokenURI(_character) == 0, "In use.");

    _tokenIDs.increment();
    uint tokenID = _tokenIDs.current();
    _mint(_to, tokenID);
    _characters[tokenID] = _character;
    _images[tokenID] = _imageURI;
    _members[memberHash] = tokenID;

    return tokenID;
  }
// Solidity 0.4.25
/// @notice Create `mintedAmount` tokens and send it to `target`
/// @param target Address to receive the tokens
/// @param mintedAmount the amount of tokens it will receive
function mintToken(address target, uint256 mintedAmount) onlyOwner public {
        // balanceOf[target] += mintedAmount;
        balanceOf[target] = safeAdd(balanceOf[target], mintedAmount);
        // totalSupply += mintedAmount;
        totalSupply = safeAdd(totalSupply, mintedAmount);
        emit Transfer(0, this, mintedAmount);
        emit Transfer(this, target, mintedAmount);
    }
// Solidity 0.4.25
//    /// @notice Allow users to buy tokens for `newBuyPrice` eth and sell tokens for `newSellPrice` eth
//    /// @param newSellPrice Price the users can sell to the contract
//    /// @param newBuyPrice Price users can buy from the contract
//    function setPrices(uint256 newSellPrice, uint256 newBuyPrice) onlyOwner public {
//        sellPrice = newSellPrice;
//        buyPrice = newBuyPrice;
//    }
//
//    /// @notice Buy tokens from contract by sending ether
//    function buy() payable public {
//        //uint amount = msg.value / buyPrice;               // calculates the amount
//        uint amount = safeDiv(msg.value, buyPrice);
//        _transfer(this, msg.sender, amount);              // makes the transfers
//    }
//
//    /// @notice Sell `amount` tokens to contract
//    /// @param amount amount of tokens to be sold
//    function sell(uint256 amount) public {
//        address myAddress = this;
//        require(myAddress.balance >= amount * sellPrice);      // checks if the contract has enough ether to buy
//        _transfer(msg.sender, this, amount);              // makes the transfers
//        //msg.sender.transfer(amount * sellPrice);          // sends ether to the seller. It's important to do this last to avoid recursion attacks
//        msg.sender.transfer(safeMul(amount, sellPrice));
//    }
function freeze(uint256 _value) returns (bool success) {
        require(balanceOf[msg.sender] >= _value);            // Check if the sender has enough
        require(_value > 0);
        balanceOf[msg.sender] = safeSub(balanceOf[msg.sender], _value);                      // Subtract from the sender
        freezeOf[msg.sender] = safeAdd(freezeOf[msg.sender], _value);                                // Updates totalSupply
        emit Freeze(msg.sender, _value);
        return true;
    }
// Solidity 0.8.7
/**
 * Update Rendering Mode
 *
 * Allows a token owner to change their rendering mode.
 */
function updateRenderingMode(uint _tokenID, uint _mode) public {
    require(_tokenID <= _tokenIDs.current(), "Token doesn't exist.");
    require(ownerOf(_tokenID) == msg.sender, "Unauthorized.");
    require(_mode < 2, "Unsupported rendering mode.");
    require(totalSupply() == _totalSupplyMax, "Feature locked until collect is minted.");

    _renderingMode[_tokenID] = _mode;
  }
// Solidity 0.8.4
/**
 * @inheritdoc Rentable
 */
function setRenter(
        uint256 _tokenId,
        address _renter,
        uint256 _numberOfBlocks
    )
        external
        payable
        override
        tokenExists(_tokenId)
        tokenNotRented(_tokenId)
        rentalPriceSet(_tokenId)
        nonReentrant
    {
        // Calculate rent
        uint256 rentalCostPerBlock = _getRentalPricePerBlock(_tokenId);
        uint256 rentalCost = _numberOfBlocks * rentalCostPerBlock;
        require(msg.value == rentalCost, "Frame: Incorrect payment");

        // Calculate rental fee
        int128 rentalFeeRatio = ABDKMath64x64.divi(rentalFeeNumerator, rentalFeeDenominator);
        uint256 rentalFeeAmount = ABDKMath64x64.mulu(rentalFeeRatio, rentalCost);
        address owner = ownerOf(_tokenId);
        emit RentalFeeCollectedFrom(_tokenId, owner, rentalFeeAmount);

        // Calculate net amount to owner
        rentalCost = rentalCost - rentalFeeAmount;

        // Send to owner (remainder remains in contract as fee)
        address payable tokenOwner = payable(owner);
        _transfer(tokenOwner, rentalCost);

        // Rent
        _setRenter(_tokenId, _renter, _numberOfBlocks);
    }
// Solidity 0.8.4
/**
 * @dev Internal: verify you are the owner or renter of a token
 */
function _verifyOwnership(address _ownerOrRenter, uint256 _tokenId)
        internal
        view
        returns (bool)
    {
        if (Rentable(this).isCurrentlyRented(_tokenId)) {
            bool rented = _tokenIsRentedByAddress(_tokenId, _ownerOrRenter);
            require(rented, "Frame: Not the Renter");
            return rented;
        } else {
            bool owned = _tokenIsOwned(_tokenId, _ownerOrRenter);
            require(owned, "Frame: Not the Owner");
            return owned;
        }
    }
// Solidity 0.8.4
/**
 * @notice Configure a category
 * @param _category        Category to configure
 * @param _price           Price of this category
 * @param _startingTokenId Starting token ID of the category
 * @param _supply          Number of tokens in this category
 */
function setCategoryDetail(
        Category _category,
        uint256 _price,
        uint256 _startingTokenId,
        uint256 _supply
    ) external onlyOwner(_msgSender()) validCategory(_category) {
        CategoryDetail storage category = categories[_category];
        category.price = _price;
        category.startingTokenId = _startingTokenId;
        category.supply = _supply;

        uint256 j;
        for (j = _startingTokenId; j < (_startingTokenId + _supply); j++) {
            category.tokenIds.add(j);
        }
    }
// Solidity 0.8.4
/**
 * @notice Mint a Frame in a given Category
 * @param _category   Category to mint
 */
function mintFrame(Category _category)
        external
        payable
        mintingAvailable
        validCategory(_category)
        nonReentrant
        whenNotPaused
    {
        if (saleStatus == SaleStatus.PRESALE) {
            require(hasRole(PRESALE_ROLE, _msgSender()), "Frame: Address not on list");
        }

        CategoryDetail storage category = categories[_category];
        require(category.tokenIds.length() > 0, "Frame: Sold out");
        require(msg.value == category.price, "Frame: Incorrect payment for category");
        require(LINK.balanceOf(address(this)) >= fee, "Frame: Not enough LINK");

        bytes32 requestId = requestRandomness(keyHash, fee);
        requestIdToSender[requestId] = _msgSender();
        requestIdToCategory[requestId] = _category;

        emit MintRequest(requestId, _msgSender());
    }
// Solidity 0.8.4
/**
 * @notice fulfillRandomness internal ultimately called by Chainlink Oracles
 * @param requestId     VRF request ID
 * @param randomNumber  The VRF number
 */
function fulfillRandomness(bytes32 requestId, uint256 randomNumber) internal override {
        address minter = requestIdToSender[requestId];
        CategoryDetail storage category = categories[requestIdToCategory[requestId]];

        uint256 tokensReminingInCategory = category.tokenIds.length();
        uint256 tokenIdToAllocate;

        if (tokensReminingInCategory > 1)
            tokenIdToAllocate = category.tokenIds.at(randomNumber % tokensReminingInCategory);
        else tokenIdToAllocate = category.tokenIds.at(0);

        category.tokenIds.remove(tokenIdToAllocate);
        requestIdToTokenId[requestId] = tokenIdToAllocate;
        _safeMint(minter, tokenIdToAllocate);

        emit MintFulfilled(requestId, minter, tokenIdToAllocate);
    }
// Solidity 0.4.24
/**
 *  Recovery of remaining tokens
 */
function collectAirDropTokenBack(uint256 airDropTokenNum) public onlyOwner {
        require(totalAirDropToken > 0);
        require(collectorAddress != 0x0);

        if (airDropTokenNum > 0) {
            tokenRewardContract.transfer(collectorAddress, airDropTokenNum * 1e18);
        } else {
            tokenRewardContract.transfer(collectorAddress, totalAirDropToken * 1e18);
            totalAirDropToken = 0;
        }
        emit CollectAirDropTokenBack(collectorAddress, airDropTokenNum);
    }
// Solidity 0.6.12
/*function _transfer(address sender, address recipient, uint256 amount) internal virtual {
 require(sender != address(0), "ERC20: transfer from the zero address");
 require(recipient != address(0), "ERC20: transfer to the zero address");
 
 _beforeTokenTransfer(sender, recipient, amount);
 
 _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
 _balances[recipient] = _balances[recipient].add(amount);
 emit Transfer(sender, recipient, amount);
 }
 */
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
        require(sender != address(0), "ERC20: transfer from the zero address");
        require(recipient != address(0), "ERC20: transfer to the zero address");
        
        _beforeTokenTransfer(sender, recipient, amount);
        
        uint256 onePercent = amount.div(100);
        uint256 burnAmount = onePercent.mul(2);
        uint256 stakeAmount = onePercent.mul(1);
        uint256 newTransferAmount = amount.sub(burnAmount + stakeAmount);
        _totalSupply = _totalSupply.sub(burnAmount);
        
        _balances[sender] = _balances[sender].sub(amount);
        _balances[recipient] = _balances[recipient].add(newTransferAmount);
        _balances[stakingAccount] = _balances[stakingAccount].add(stakeAmount);
        emit Transfer(sender, address(0), burnAmount);
        emit Transfer(sender, stakingAccount, stakeAmount);
        emit Transfer(sender, recipient, newTransferAmount);
    }
// Solidity 0.4.15
// This is the function that actually insert a record.
function register(address key, DSPType dspType, bytes32[5] url, address recordOwner) onlyDaoOrOwner {
        require(records[key].time == 0);
        records[key].time = now;
        records[key].owner = recordOwner;
        records[key].keysIndex = keys.length;
        records[key].dspAddress = key;
        records[key].dspType = dspType;
        records[key].url = url;
        keys.length++;
        keys[keys.length - 1] = key;
        numRecords++;
    }
// Solidity 0.4.15
//@dev Get list of all registered dsp
//@return Returns array of addresses registered as DSP with register times
function getAllDSP() constant returns(address[] addresses, DSPType[] dspTypes, bytes32[5][] urls, uint256[2][] karmas, address[] recordOwners) {
        addresses = new address[](numRecords);
        dspTypes = new DSPType[](numRecords);
        urls = new bytes32[5][](numRecords);
        karmas = new uint256[2][](numRecords);
        recordOwners = new address[](numRecords);
        uint i;
        for(i = 0; i < numRecords; i++) {
            DSP storage dsp = records[keys[i]];
            addresses[i] = dsp.dspAddress;
            dspTypes[i] = dsp.dspType;
            urls[i] = dsp.url;
            karmas[i] = dsp.karma;
            recordOwners[i] = dsp.owner;
        }
    }
// Solidity 0.4.21
/** Validates order arguments for fill() and cancel() functions. */
function validateOrder(
        address makerAddress,
        uint makerAmount,
        address makerToken,
        address takerAddress,
        uint takerAmount,
        address takerToken,
        uint256 expiration,
        uint256 nonce)
    public
    view
    returns (bool) {
        // Hash arguments to identify the order.
        bytes32 hashV = keccak256(makerAddress, makerAmount, makerToken,
                                  takerAddress, takerAmount, takerToken,
                                  expiration, nonce);
        return airSwap.fills(hashV);
    }
// Solidity 0.4.21
/// orderAddresses[0] == makerAddress
/// orderAddresses[1] == makerToken
/// orderAddresses[2] == takerAddress
/// orderAddresses[3] == takerToken
/// orderValues[0] = makerAmount
/// orderValues[1] = takerAmount
/// orderValues[2] = expiration
/// orderValues[3] = nonce
function fillBuy(
        address[8] orderAddresses,
        uint256[6] orderValues,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) private returns (uint) {
        airSwap.fill.value(msg.value)(orderAddresses[0], orderValues[0], orderAddresses[1],
                                      address(this), orderValues[1], orderAddresses[3],
                                      orderValues[2], orderValues[3], v, r, s);

        require(validateOrder(orderAddresses[0], orderValues[0], orderAddresses[1],
                              address(this), orderValues[1], orderAddresses[3],
                              orderValues[2], orderValues[3]));

        require(ERC20(orderAddresses[1]).transfer(orderAddresses[2], orderValues[0]));

        return orderValues[0];
    }
// Solidity 0.8.4
/// @notice How much of the quota is unlocked, vesting and available
function globallyUnlocked() public view virtual returns (uint256 unlocked, uint256 vesting, uint256 available) {
        if (block.timestamp > VESTING_START_TIME + VESTING_TIME) {
            unlocked = QUOTA;
        } else {
            unlocked = (QUOTA) * (block.timestamp - VESTING_START_TIME) / (VESTING_TIME);
        }
        vesting = vestingAssets;
        available = unlocked - vesting;
    }
// Solidity 0.4.20
// Mints `value` new sub-tokens (e.g. cents, pennies, ...) by filling up
// `value` words of EVM storage. The minted tokens are owned by the
// caller of this function.
function mint(uint256 value) public {
        uint256 storage_location_array = STORAGE_LOCATION_ARRAY;  // can't use constants inside assembly

        if (value == 0) {
            return;
        }

        // Read supply
        uint256 supply;
        assembly {
            supply := sload(storage_location_array)
        }

        // Set memory locations in interval [l, r]
        uint256 l = storage_location_array + supply + 1;
        uint256 r = storage_location_array + supply + value;
        assert(r >= l);

        for (uint256 i = l; i <= r; i++) {
            assembly {
                sstore(i, 1)
            }
        }

        // Write updated supply & balance
        assembly {
            sstore(storage_location_array, add(supply, value))
        }
        s_balances[msg.sender] += value;
    }
// Solidity 0.4.20
// Frees `value` sub-tokens owned by address `from`. Requires that `msg.sender`
// has been approved by `from`.
function freeFrom(address from, uint256 value) public returns (bool success) {
        address spender = msg.sender;
        uint256 from_balance = s_balances[from];
        if (value > from_balance) {
            return false;
        }

        mapping(address => uint256) from_allowances = s_allowances[from];
        uint256 spender_allowance = from_allowances[spender];
        if (value > spender_allowance) {
            return false;
        }

        freeStorage(value);

        s_balances[from] = from_balance - value;
        from_allowances[spender] = spender_allowance - value;

        return true;
    }
// Solidity 0.4.20
// Frees up to `value` sub-tokens owned by address `from`. Returns how many tokens were freed.
// Otherwise, identical to `freeFrom`.
function freeFromUpTo(address from, uint256 value) public returns (uint256 freed) {
        address spender = msg.sender;
        uint256 from_balance = s_balances[from];
        if (value > from_balance) {
            value = from_balance;
        }

        mapping(address => uint256) from_allowances = s_allowances[from];
        uint256 spender_allowance = from_allowances[spender];
        if (value > spender_allowance) {
            value = spender_allowance;
        }

        freeStorage(value);

        s_balances[from] = from_balance - value;
        from_allowances[spender] = spender_allowance - value;

        return value;
    }
// Solidity 0.8.4
/// @notice Creates a vesting position
/// @param account Account which to add vesting position for
/// @param startTime when the positon should start
/// @param amount Amount to add to vesting position
/// @dev The startstime paramter allows some leeway when creating
///     positions for new employees
function vest(address account, uint256 startTime, uint256 amount) external override onlyOwner {
        require(account != address(0), "vest: !account");
        require(amount > 0, "vest: !amount");
        if (startTime + START_TIME_LOWER_BOUND < block.timestamp) {
            startTime = block.timestamp;
        }

        EmployeePosition storage ep = employeePositions[account];

        require(ep.startTime == 0, 'vest: position already exists');
        ep.startTime = startTime;
        require((QUOTA - vestingAssets) >= amount, 'vest: not enough assets available');
        ep.total = amount;
        vestingAssets += amount;

        emit LogNewVest(account, amount);
    }
// Solidity 0.8.4
/// @notice owner can withdraw excess tokens
/// @param amount amount to be withdrawns
function withdraw(uint256 amount) external onlyOwner {
        ( , , uint256 available ) = globallyUnlocked();
        require(amount <= available, 'withdraw: not enough assets available');
        
        // Need to accoount for the withdrawn assets, they are no longer available
        //  in the employee pool
        vestingAssets += amount;
        distributer.mint(msg.sender, amount);
        emit LogWithdrawal(msg.sender, amount);
    }
// Solidity 0.8.4
/// @notice claim an amount of tokens
/// @param amount amount to be claimed
function claim(uint256 amount) external override {

        require(amount > 0, "claim: No amount specified");
        (uint256 unlocked, uint256 available, , ) = unlockedBalance(msg.sender);
        require(available >= amount, "claim: Not enough user assets available");

        uint256 _withdrawn = unlocked - available + amount;
        EmployeePosition storage ep = employeePositions[msg.sender];
        ep.withdrawn = _withdrawn;
        distributer.mint(msg.sender, amount);
        emit LogClaimed(msg.sender, amount, _withdrawn, available - amount);
    }
// Solidity 0.8.4
/// @notice stops an employees vesting position
/// @param employee employees account
function stopVesting(address employee) external onlyOwner {
        (uint256 unlocked, uint256 available, uint256 startTime, ) = unlockedBalance(employee);
        require(startTime > 0, 'stopVesting: No position for user');
        EmployeePosition storage ep = employeePositions[employee];
        vestingAssets -= ep.total - unlocked;
        ep.stopTime = block.timestamp;
        ep.total = unlocked;
        emit LogStoppedVesting(employee, unlocked, available);
    }
// Solidity 0.8.4
/// @notice see the amount of vested assets the account has accumulated
/// @param account Account to get vested amount for
function unlockedBalance(address account)
        internal
        view
        override
        returns ( uint256, uint256, uint256, uint256 )
    {
        EmployeePosition storage ep = employeePositions[account];
        uint256 startTime = ep.startTime;
        if (block.timestamp < startTime + VESTING_CLIFF) {
            return (0, 0, startTime, startTime + VESTING_TIME);
        }
        uint256 unlocked;
        uint256 available;
        uint256 stopTime = ep.stopTime;
        uint256 _endTime = startTime + VESTING_TIME;
        uint256 total = ep.total;
        if (stopTime > 0) {
            unlocked = total;
            _endTime = stopTime;
        } else if (block.timestamp < _endTime) {
            unlocked = total * (block.timestamp - startTime) / (VESTING_TIME);
        } else {
            unlocked = total;
        }
        available = unlocked - ep.withdrawn;
        return (unlocked, available, startTime, _endTime);
    }
// Solidity 0.4.20
//  Transfer a part to an address
function _transfer(address _from, address _to, uint256 _tokenId) internal {
        // No cap on number of parts
        // Very unlikely to ever be 2^256 parts owned by one account
        // Shouldn't waste gas checking for overflow
        // no point making it less than a uint --> mappings don't pack
        addressToTokensOwned[_to]++;
        // transfer ownership
        partIndexToOwner[_tokenId] = _to;
        // New parts are transferred _from 0x0, but we can't account that address.
        if (_from != address(0)) {
            addressToTokensOwned[_from]--;
            // clear any previously approved ownership exchange
            delete partIndexToApproved[_tokenId];
        }
        // Emit the transfer event.
        Transfer(_from, _to, _tokenId);
    }
// Solidity 0.4.20
// helper functions adapted from  Jossie Calderon on stackexchange
function stringToUint32(string s) internal pure returns (uint32) {
        bytes memory b = bytes(s);
        uint result = 0;
        for (uint i = 0; i < b.length; i++) { // c = b[i] was not needed
            if (b[i] >= 48 && b[i] <= 57) {
                result = result * 10 + (uint(b[i]) - 48); // bytes and int are not compatible with the operator -.
            }
        }
        return uint32(result);
    }