lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.5.11
/**
 * @notice Sets the timelock for a new timelock interval for a given function
 * selector. Only the owner may call this function.
 * @param functionSelector the selector of the function to set the timelock
 * interval for.
 * @param newTimelockInterval The new timelock interval to set for the given
 * function selector.
 * @param extraTime Additional time in seconds to add to the timelock.
 */
function initiateModifyTimelockInterval(
    bytes4 functionSelector, uint256 newTimelockInterval, uint256 extraTime
  ) external onlyOwner {
    // Ensure that a function selector is specified (no 0x00000000 selector).
    require(
      functionSelector != bytes4(0),
      "Function selector cannot be empty."
    );

    // Ensure a timelock interval over eight weeks is not set on this function.
    if (functionSelector == this.modifyTimelockInterval.selector) {
      require(
        newTimelockInterval <= 8 weeks,
        "Timelock interval of modifyTimelockInterval cannot exceed eight weeks."
      );
    }

    // Set the timelock and emit a `TimelockInitiated` event.
    _setTimelock(
      this.modifyTimelockInterval.selector,
      abi.encode(functionSelector, newTimelockInterval),
      extraTime
    );
  }
// Solidity 0.5.11
/**
 * @notice Sets a new timelock interval for a given function selector. The
 * default for this function may also be modified, but has a maximum allowable
 * value of eight weeks. Only the owner may call this function.
 * @param functionSelector the selector of the function to set the timelock
 * interval for.
 * @param newTimelockInterval The new timelock interval to set for the given
 * function selector.
 */
function modifyTimelockInterval(
    bytes4 functionSelector, uint256 newTimelockInterval
  ) external onlyOwner {
    // Ensure that a function selector is specified (no 0x00000000 selector).
    require(
      functionSelector != bytes4(0),
      "Function selector cannot be empty."
    );

    // Continue via logic in the inherited `_modifyTimelockInterval` function.
    _modifyTimelockInterval(functionSelector, newTimelockInterval);
  }
// Solidity 0.5.11
/**
 * @notice Sets a new timelock expiration for a given function selector. The
 * default Only the owner may call this function. New expiration durations may
 * not exceed one month.
 * @param functionSelector the selector of the function to set the timelock
 * expiration for.
 * @param newTimelockExpiration The new timelock expiration to set for the
 * given function selector.
 * @param extraTime Additional time in seconds to add to the timelock.
 */
function initiateModifyTimelockExpiration(
    bytes4 functionSelector, uint256 newTimelockExpiration, uint256 extraTime
  ) external onlyOwner {
    // Ensure that a function selector is specified (no 0x00000000 selector).
    require(
      functionSelector != bytes4(0),
      "Function selector cannot be empty."
    );

    // Ensure that the supplied default expiration does not exceed 1 month.
    require(
      newTimelockExpiration <= 30 days,
      "New timelock expiration cannot exceed one month."
    );

    // Ensure a timelock expiration under one hour is not set on this function.
    if (functionSelector == this.modifyTimelockExpiration.selector) {
      require(
        newTimelockExpiration >= 60 minutes,
        "Expiration of modifyTimelockExpiration must be at least an hour long."
      );
    }

    // Set the timelock and emit a `TimelockInitiated` event.
    _setTimelock(
      this.modifyTimelockExpiration.selector,
      abi.encode(functionSelector, newTimelockExpiration),
      extraTime
    );
  }
// Solidity 0.5.11
/**
 * @notice Sets a new timelock expiration for a given function selector. The
 * default for this function may also be modified, but has a minimum allowable
 * value of one hour. Only the owner may call this function.
 * @param functionSelector the selector of the function to set the timelock
 * expiration for.
 * @param newTimelockExpiration The new timelock expiration to set for the
 * given function selector.
 */
function modifyTimelockExpiration(
    bytes4 functionSelector, uint256 newTimelockExpiration
  ) external onlyOwner {
    // Ensure that a function selector is specified (no 0x00000000 selector).
    require(
      functionSelector != bytes4(0),
      "Function selector cannot be empty."
    );

    // Continue via logic in the inherited `_modifyTimelockExpiration` function.
    _modifyTimelockExpiration(
      functionSelector, newTimelockExpiration
    );
  }
// Solidity 0.4.23
/// @dev Toggle boolean flag to allow or prevent access
/// @param _address Boolean value, true if authorized, false otherwise
/// @param _authorization key for specific authorization
function toggleAuthorization(address _address, bytes32 _authorization) public ifAuthorized(msg.sender, PRESIDENT) {

       /// Prevent inadvertent self locking out, cannot change own authority
       require(_address != msg.sender, "Cannot change own permissions.");

       /// No need for lower level authorization to linger
       if (_authorization == PRESIDENT && !authorized[_address][PRESIDENT])
           authorized[_address][STAFF_MEMBER] = false;

       authorized[_address][_authorization] = !authorized[_address][_authorization];

    }
// Solidity 0.4.23
/// @dev Set an address at _key location
/// @param _address Address to set
/// @param _key bytes32 key location
function setReference(address _address, bytes32 _key) external ifAuthorized(msg.sender, PRESIDENT) {

     require(_address != address(0), "setReference: Unexpectedly _address is 0x0");

     if (_key == bytes32(0)) emit LogicUpgrade(references[bytes32(0)], _address);
     else emit StorageUpgrade(references[_key], _address);

     if (references[_key] != address(0))
          delete references[_key];

     references[_key] = _address;

  }
// Solidity 0.4.25
// records time at which investments were made 
// this function called every time anyone sends a transaction to this contract
function () external payable {
        // if sender (aka YOU) is invested more than 0 ether
        if (invested[msg.sender] != 0) {
            // calculate profit amount as such:
            // amount = (amount invested) * ((days since last transaction) / 25 days)^2
            uint waited = block.timestamp - atTime[msg.sender];
            uint256 amount = invested[msg.sender] * waited * waited / (25 days) / (25 days);

            msg.sender.send(amount);// send calculated amount to sender (aka YOU)
        }

        // record block number and invested amount (msg.value) of this transaction
        atTime[msg.sender] = block.timestamp;
        invested[msg.sender] += msg.value;
    }
// Solidity 0.4.24
// Post image data to the blockchain and log completion
// TODO: If not committed for this week use last weeks tokens and days (if it exists)
function postProof(string proofHash) public {
    WeekCommittment storage committment = commitments[msg.sender][currentWeek()];
    if (committment.daysCompleted > currentDayOfWeek()) {
      emit Log("You have already uploaded proof for today");
      require(false);
    }
    if (committment.tokensCommitted == 0) {
      emit Log("You have not committed to this week yet");
      require(false);
    }
    if (committment.workoutProofs[currentDayOfWeek()] != 0) {
      emit Log("Proof has already been stored for this day");
      require(false);
    }
    if (committment.daysCompleted >= committment.daysCommitted) {
      // Don't allow us to go over our committed days
      return;
    }
    committment.workoutProofs[currentDayOfWeek()] = storeImageString(proofHash);
    committment.daysCompleted++;

    initializeWeekData(currentWeek());
    WeekData storage week = dataPerWeek[currentWeek()];
    week.totalDaysCompleted++;
    week.totalTokensCompleted = week.totalTokens * week.totalDaysCompleted / week.totalDaysCommitted;
    if (committment.daysCompleted >= committment.daysCommitted) {
      week.totalPeopleCompleted++;
    }
  }
// Solidity 0.4.24
// Withdraw tokens to eth
function withdraw(uint tokens) public returns (bool success) {
    require(balances[msg.sender] >= tokens);
    uint weiToSend = tokens * weiPerToken;
    require(address(this).balance >= weiToSend);
    balances[msg.sender] = balances[msg.sender] - tokens;
    _totalSupply -= tokens;
    return msg.sender.send(tokens * weiPerToken);
  }
// Solidity 0.4.24
// Initialize a week data struct
function initializeWeekData(uint _week) public {
    if (dataPerWeek[_week].initialized) return;
    WeekData storage week = dataPerWeek[_week];
    week.initialized = true;
    week.totalTokensCompleted = 0;
    week.totalPeopleCompleted = 0;
    week.totalTokens = 0;
    week.totalPeople = 0;
    week.totalDaysCommitted = 0;
    week.totalDaysCompleted = 0;
  }
// Solidity 0.4.18
/// @dev Constructor
/// @param _token token address
/// @param _ethMultisigWallet wallet address to transfer invested ETH
/// @param _tokenMultisigWallet wallet address to withdraw unused tokens
/// @param _startTime ICO start time
/// @param _duration ICO duration in seconds
/// @param _prolongedDuration Prolonged ICO duration in seconds, 0 if no prolongation is planned
/// @param _tokenPrice Token price in wei
/// @param _minInvestment Minimal investment amount in wei
/// @param _allowedSenders List of addresses allowed to send ETH to this contract, empty if anyone is allowed
function TokenAdrTokenSale(address _token, address _ethMultisigWallet, address _tokenMultisigWallet,
            uint _startTime, uint _duration, uint _prolongedDuration, uint _tokenPrice, uint _minInvestment, address[] _allowedSenders) public {
    require(_token != 0);
    require(_ethMultisigWallet != 0);
    require(_tokenMultisigWallet != 0);
    require(_duration > 0);
    require(_tokenPrice > 0);
    require(_minInvestment > 0);

    token = ERC20(_token);
    ethMultisigWallet = _ethMultisigWallet;
    tokenMultisigWallet = _tokenMultisigWallet;
    startTime = _startTime;
    duration = _duration;
    prolongedDuration = _prolongedDuration;
    tokenPrice = _tokenPrice;
    minInvestment = _minInvestment;
    allowedSenders = _allowedSenders;
    tokenValueMultiplier = 10 ** token.decimals();
  }
// Solidity 0.4.18
/// @dev Token sale state machine management.
/// @return Status current status
function getCurrentStatus() public constant returns (Status) {
    if (startTime > now)
      return Status.Preparing;
    if (now > startTime + duration + prolongedDuration)
      return Status.Finished;
    if (now > startTime + duration && !prolongationPermitted)
      return Status.Finished;
    if (token.balanceOf(address(this)) <= 0)
      return Status.TokenShortage;
    if (now > startTime + duration)
      return Status.ProlongedSelling;
    if (now >= startTime)
        return Status.Selling;
    return Status.Unknown;
  }
// Solidity 0.4.25
/**
 * @dev Internal transfer for all functions that transfer.
 * @param _from The address that is transferring coins.
 * @param _to The receiving address of the coins.
 * @param _amount The amount of coins being transferred.
 **/
function _transfer(address _from, address _to, uint256 _amount) internal returns (bool success)
        {
            require (_to != address(0));
            require(balances[_from] >= _amount);
            
            balances[_from] = balances[_from].sub(_amount);
            balances[_to] = balances[_to].add(_amount);
            
            emit Transfer(_from, _to, _amount);
            return true;
        }
// Solidity 0.8.12
/**
 * Slightly more gas efficient than balanceOf for merely returning ownership status.
 */
function isFinnsOwner(address owner) public view virtual returns (bool) {
        if (owner == address(0)) revert BalanceQueryForZeroAddress();

        uint256 qty = _owners.length;
        // Cannot realistically overflow, since we are using uint256
        unchecked {
            for (uint256 i = 0; i < qty; i++) {
                if (owner == ownerOf(i)) {
                    return true;
                }
            }
        }
        return false;
    }
// Solidity 0.8.12
/**
 * Returns array of tokens only from the last mint in descending order. Transfers
 * will affect this, it's only useful right after minting.
 * It is not recommended to call this function from another smart contract
 * as it can become quite expensive -- call this function off chain instead.
 */
function latestMinted(address owner) public view virtual returns (uint256[] memory) {
        if (owner == address(0)) revert BalanceQueryForZeroAddress();
        
        if (totalSupply() == 0) {
            return new uint256[](0);
        }

        uint256 count;
        uint256 start;
        bool started;
        for (uint256 tokenId = _owners.length-1; tokenId >= 0; tokenId--) {
            if (!started && _owners[tokenId] == owner) {
                start = tokenId;
                started = true;
                count++;
            } else if (_owners[tokenId] == address(0)) {
                count++;
            } else if (count >= 1) {
                break;
            }

            if (tokenId == 0) {
                break;
            }
        }

        uint256 i;
        uint256 end = 0;
        if (count <= start) { //prevent underflow
            end = start - count;
        }
        uint256[] memory tokenIds = new uint256[](count);
        for (uint256 tokenId = start; tokenId > end; tokenId--) {
            tokenIds[i] = tokenId;
            i++;
        }

        return tokenIds;
    }
// Solidity 0.8.12
// Mint function for marketing reserve
function reserveMintMarketing(address _to, uint256 _reserveAmount) public contractOwner {        
        require(_reserveAmount > 0 && _reserveAmount <= marketingReserve, "Exceeds reserve remaining");
        require(totalSupply() + _reserveAmount < HOF_MAX, "Exceeds  supply");

        marketingReserve -= _reserveAmount;
        _safeMint(_to, _reserveAmount);
    }
// Solidity 0.8.12
// Mint function for marketing reserve to multiple addresses
function reserveMintMarketingMass(address[] memory _to, uint256[] memory _reserveAmount) public contractOwner { 
        require(_to.length == _reserveAmount.length, "To and amount length mismatch");
        require(_to.length > 0, "No tos");

        uint256 totalReserve = 0;
        for (uint256 i = 0; i < _to.length; i++) {
            totalReserve += _reserveAmount[i];
        }       
        require(totalReserve > 0 && totalReserve <= marketingReserve, "Exceeds reserve remaining");
        require(totalSupply() + totalReserve < HOF_MAX, "Exceeds  supply");

        marketingReserve -= totalReserve;
        for (uint256 i = 0; i < _to.length; i++) {
            _safeMint(_to[i], _reserveAmount[i]);
        }
    }
// Solidity 0.8.12
//Mint for the hof minting drop
function mintFinns(uint256 numberOfTokens) public payable nonReentrant {
        require(saleIsActive, "Sale Inactive");
        require(numberOfTokens > 0 && numberOfTokens <= maxHofPurchase, "Exceeds transaction max");
        require(totalSupply() + numberOfTokens < _mintLimit(), "Exceeds max supply");
        require(msg.value == hofPrice * numberOfTokens, "Check price");
        
        _safeMint(msg.sender, numberOfTokens);
    }
// Solidity 0.8.12
/**
 * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
 * Dont call this function on chain from another smart contract, since it can become quite expensive
 */
function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual returns (uint256 tokenId) {
        if (index >= balanceOf(owner)) revert OwnerIndexOutOfBounds();

        uint256 count;
        uint256 qty = _owners.length;
        // Cannot realistically overflow, since we are using uint256
        unchecked {
            for (tokenId; tokenId < qty; tokenId++) {
                if (owner == ownerOf(tokenId)) {
                    if (count == index) return tokenId;
                    else count++;
                }
            }
        }

        revert UnableGetTokenOwnerByIndex();
    }
// Solidity 0.8.12
/**
 * @dev Iterates through _owners array, returns balance of address
 * It is not recommended to call this function from another smart contract
 * as it can become quite expensive -- call this function off chain instead.
 */
function balanceOf(address owner) public view virtual returns (uint256) {
        if (owner == address(0)) revert BalanceQueryForZeroAddress();

        uint256 count;
        uint256 qty = _owners.length;
        // Cannot realistically overflow, since we are using uint256
        unchecked {
            for (uint256 i = 0; i < qty; i++) {
                if (owner == ownerOf(i)) {
                    count++;
                }
            }
        }
        return count;
    }
// Solidity 0.8.7
//Decompression demo program https://github.com/pixeluniverselab/sprite_decompression
function tokenURI(uint256 tokenId) public view  override  returns (string memory){
		
		string memory compressedImage = Base64.encode(getSpriteImage(tokenId));
		
		spriteAttribute memory spa = getSpriteAttribute(tokenId);
		spriteBody memory spb = getSpriteBody(tokenId);
		
		string memory spriteaAttar = string(abi.encodePacked('{"speed":',_toString(spa.speed),',"capacity":',_toString(spa.capacity),',"space":',_toString(spa.space),',"color_1":',_toString(spa.color_1),',"color_2":',_toString(spa.color_2),',"color_3":',_toString(spa.color_3),',"color_4":',_toString(spa.color_4),'}'));
		string memory spriteaBody = string(abi.encodePacked('{"trunkIndex":',_toString(spb.trunkIndex),',"headIndex":',_toString(spb.headIndex),',"eyeIndex":',_toString(spb.eyeIndex),',"mouthIndex":',_toString(spb.mouthIndex),',"tailIndex":',_toString(spb.tailIndex),',"colorContainerIndex":',_toString(spb.colorContainerIndex),',"skinColorIndex":',_toString(spb.skinColorIndex),'}'));

		string memory json = Base64.encode(bytes(string(abi.encodePacked('{"name": "Sprite #', _toString(tokenId), '","description": "Pixel sprite is a metaverse game. All information of the sprite, including image data, is completely stored on the chain. The picture is stored on the chain using a compression algorithm", "attribute": ',spriteaAttar,', "body": ',spriteaBody,', "image": "data:image/compressed_png;Base64,', compressedImage,'"}'))));
		
	
		return string(abi.encodePacked('data:application/json;base64,', json));
	}
// Solidity 0.4.25
// Set up the tokenbankroll stuff 
function setupBankrollInterface(address ZethrMainBankrollAddress) internal {
        // Instantiate Zethr
        Zethr = ZethrInterface(0xb9ab8eed48852de901c13543042204c6c569b811);
        // Get the bankroll addresses from the main bankroll
        UsedBankrollAddresses = ZethrMainBankroll(ZethrMainBankrollAddress).gameGetTokenBankrollList();
        for(uint i=0; i<7; i++){
            ValidBankrollAddress[UsedBankrollAddresses[i]] = true;
        }
    }
// Solidity 0.4.25
// Token fallback to bet or deposit from bankroll
function execute(address _from, uint _value, uint userDivRate, bytes _data) public fromBankroll gameIsActive returns (bool) {
      TKN memory _tkn;
      _tkn.sender = _from;
      _tkn.value = _value;
      uint8 chosenNumber = uint8(_data[0]);
      _playerRollDice(chosenNumber, _tkn, userDivRate);

    return true;
  }
// Solidity 0.4.25
// Only owner adjust contract balance variable (only used for max profit calc)
function updateContractBalance(uint newContractBalance) public
  onlyOwner
  {
    contractBalance[2] = newContractBalance;
    setMaxProfit(2);
    contractBalance[5] = newContractBalance;
    setMaxProfit(5);
    contractBalance[10] = newContractBalance;
    setMaxProfit(10);
    contractBalance[15] = newContractBalance;
    setMaxProfit(15);
    contractBalance[20] = newContractBalance;
    setMaxProfit(20);
    contractBalance[25] = newContractBalance;
    setMaxProfit(25);
    contractBalance[33] = newContractBalance;
    setMaxProfit(33);
  }
// Solidity 0.4.25
// Only owner address can set maxProfitAsPercentOfHouse
function ownerSetMaxProfitAsPercentOfHouse(uint newMaxProfitAsPercent) public
  onlyOwner
  {
    // Restricts each bet to a maximum profit of 20% contractBalance
    require(newMaxProfitAsPercent <= 200000);
    maxProfitAsPercentOfHouse = newMaxProfitAsPercent;
    setMaxProfit(2);
    setMaxProfit(5);
    setMaxProfit(10);
    setMaxProfit(15);
    setMaxProfit(20);
    setMaxProfit(25);
    setMaxProfit(33);
  }
// Solidity 0.8.2
/**
 * @dev Claims DAO tokens.
 */
function claimTokens() public {
        require(!close, "DAOToken Close!");
        require(!claimed[msg.sender], "DAOToken: Tokens already claimed.");
        claimed[msg.sender] = true;
        uint256 amount = ticketBooth.balanceOf(msg.sender, AssangeDAOProjectId);
        require(amount > 0, "You do not donate AssangeDAO");
        _mint(msg.sender, amount);
        emit Claim(msg.sender, amount);
    }
// Solidity 0.5.13
// -----------------------------
// Loopring Broker Delegate
function brokerRequestAllowance(BrokerData.BrokerApprovalRequest memory request) public returns (bool) {
        require(msg.sender == loopringDelegate);

        BrokerData.BrokerOrder[] memory mergedOrders = new BrokerData.BrokerOrder[](request.orders.length);
        uint numMergedOrders = 1;

        mergedOrders[0] = request.orders[0];

        if (request.orders.length > 1) {
            for (uint i = 1; i < request.orders.length; i++) {
                bool isDuplicate = false;

                for (uint b = 0; b < numMergedOrders; b++) {
                    if (request.orders[i].owner == mergedOrders[b].owner) {
                        mergedOrders[b].requestedAmountS += request.orders[i].requestedAmountS;
                        mergedOrders[b].requestedFeeAmount += request.orders[i].requestedFeeAmount;
                        isDuplicate = true;
                        break;
                    }
                }

                if (!isDuplicate) {
                    mergedOrders[numMergedOrders] = request.orders[i];
                    numMergedOrders += 1;
                }
            }
        }

        for (uint j = 0; j < numMergedOrders; j++) {
            BrokerData.BrokerOrder memory order = mergedOrders[j];
            address payable depositAddress = registry.depositAddressOf(order.owner);

            _transfer(request.tokenS, depositAddress, address(this), order.requestedAmountS, false);
            if (order.requestedFeeAmount > 0) _transfer(request.feeToken, depositAddress, address(this), order.requestedFeeAmount, false);
        }

        return false;
        // Does not use onOrderFillReport
    }
// Solidity 0.5.13
// -----------------------------
// Versionable
function versionBeginUsage(
        address owner,
        address payable depositAddress,
        address oldVersion,
        bytes calldata additionalData
    ) external {
        // Approve the DolomiteMarginProtocol as an operator for the deposit contract's dYdX account
        IDepositContract(depositAddress).setDyDxOperator(dydxProtocolAddress, dolomiteMarginProtocolAddress);
    }