lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.5.17
/** @dev Make a request to add a new entry to the list. Paying the full deposit right away is not required as it can be crowdfunded later.
 *  @param _evidence A link to evidence using its URI.
 *  @param _name The name of the submitter. This parameter is for Subgraph only and it won't be used in this function.
 */
function addSubmission(string calldata _evidence, string calldata _name) external payable {
        Submission storage submission = submissions[msg.sender];
        require(!submission.registered && submission.status == Status.None, "Wrong status");
        if (submission.requests.length == 0) {
            submission.index = uint64(submissionCounter);
            submissionCounter++;
        }
        submission.status = Status.Vouching;
        emit AddSubmission(msg.sender, submission.requests.length);
        requestRegistration(msg.sender, _evidence);
    }
// Solidity 0.5.17
/** @dev Make a request to refresh a submissionDuration. Paying the full deposit right away is not required as it can be crowdfunded later.
 *  Note that the user can reapply even when current submissionDuration has not expired, but only after the start of renewal period.
 *  @param _evidence A link to evidence using its URI.
 *  @param _name The name of the submitter. This parameter is for Subgraph only and it won't be used in this function.
 */
function reapplySubmission(string calldata _evidence, string calldata _name) external payable {
        Submission storage submission = submissions[msg.sender];
        require(submission.registered && submission.status == Status.None, "Wrong status");
        uint renewalAvailableAt = submission.submissionTime.addCap64(submissionDuration.subCap64(renewalPeriodDuration));
        require(now >= renewalAvailableAt, "Can't reapply yet");
        submission.status = Status.Vouching;
        emit ReapplySubmission(msg.sender, submission.requests.length);
        requestRegistration(msg.sender, _evidence);
    }
// Solidity 0.5.17
/** @dev Make a request to remove a submission from the list. Requires full deposit. Accepts enough ETH to cover the deposit, reimburses the rest.
 *  Note that this request can't be made during the renewal period to avoid spam leading to submission's expiration.
 *  @param _submissionID The address of the submission to remove.
 *  @param _evidence A link to evidence using its URI.
 */
function removeSubmission(address _submissionID, string calldata _evidence) external payable {
        Submission storage submission = submissions[_submissionID];
        require(submission.registered && submission.status == Status.None, "Wrong status");
        uint renewalAvailableAt = submission.submissionTime.addCap64(submissionDuration.subCap64(renewalPeriodDuration));
        require(now < renewalAvailableAt, "Can't remove after renewal");
        submission.status = Status.PendingRemoval;

        Request storage request = submission.requests[submission.requests.length++];
        request.requester = msg.sender;
        request.challengePeriodStart = uint64(now);

        uint arbitratorDataID = arbitratorDataList.length - 1;
        request.arbitratorDataID = uint16(arbitratorDataID);

        Round storage round = request.challenges[0].rounds[0];

        IArbitrator requestArbitrator = arbitratorDataList[arbitratorDataID].arbitrator;
        uint arbitrationCost = requestArbitrator.arbitrationCost(arbitratorDataList[arbitratorDataID].arbitratorExtraData);
        uint totalCost = arbitrationCost.addCap(submissionBaseDeposit);
        contribute(round, Party.Requester, msg.sender, msg.value, totalCost);

        require(round.paidFees[uint(Party.Requester)] >= totalCost, "You must fully fund your side");
        round.sideFunded = Party.Requester;

        emit RemoveSubmission(msg.sender, _submissionID, submission.requests.length - 1);

        if (bytes(_evidence).length > 0)
            emit Evidence(requestArbitrator, submission.requests.length - 1 + uint(_submissionID), msg.sender, _evidence);
    }
// Solidity 0.5.17
/** @dev Fund the requester's deposit. Accepts enough ETH to cover the deposit, reimburses the rest.
 *  @param _submissionID The address of the submission which ongoing request to fund.
 */
function fundSubmission(address _submissionID) external payable {
        Submission storage submission = submissions[_submissionID];
        require(submission.status == Status.Vouching, "Wrong status");
        Request storage request = submission.requests[submission.requests.length - 1];
        Challenge storage challenge = request.challenges[0];
        Round storage round = challenge.rounds[0];

        ArbitratorData storage arbitratorData = arbitratorDataList[request.arbitratorDataID];
        uint arbitrationCost = arbitratorData.arbitrator.arbitrationCost(arbitratorData.arbitratorExtraData);
        uint totalCost = arbitrationCost.addCap(submissionBaseDeposit);
        contribute(round, Party.Requester, msg.sender, msg.value, totalCost);

        if (round.paidFees[uint(Party.Requester)] >= totalCost)
            round.sideFunded = Party.Requester;
    }
// Solidity 0.5.17
/** @dev Allows to withdraw a mistakenly added submission while it's still in a vouching state.
 */
function withdrawSubmission() external {
        Submission storage submission = submissions[msg.sender];
        require(submission.status == Status.Vouching, "Wrong status");
        Request storage request = submission.requests[submission.requests.length - 1];

        submission.status = Status.None;
        request.resolved = true;

        withdrawFeesAndRewards(msg.sender, msg.sender, submission.requests.length - 1, 0, 0); // Automatically withdraw for the requester.
    }
// Solidity 0.5.17
/** @dev Execute a request if the challenge period passed and no one challenged the request.
 *  @param _submissionID The address of the submission with the request to execute.
 */
function executeRequest(address _submissionID) external {
        Submission storage submission = submissions[_submissionID];
        uint requestID = submission.requests.length - 1;
        Request storage request = submission.requests[requestID];
        require(now - request.challengePeriodStart > challengePeriodDuration, "Can't execute yet");
        require(!request.disputed, "The request is disputed");
        address payable requester;
        if (submission.status == Status.PendingRegistration) {
            // It is possible for the requester to lose without a dispute if he was penalized for bad vouching while reapplying.
            if (!request.requesterLost) {
                submission.registered = true;
                submission.submissionTime = uint64(now);
            }
            requester = address(uint160(_submissionID));
        } else if (submission.status == Status.PendingRemoval) {
            submission.registered = false;
            requester = request.requester;
        } else
            revert("Incorrect status.");

        submission.status = Status.None;
        request.resolved = true;

        if (request.vouches.length != 0)
            processVouches(_submissionID, requestID, AUTO_PROCESSED_VOUCH);

        withdrawFeesAndRewards(requester, _submissionID, requestID, 0, 0); // Automatically withdraw for the requester.
    }
// Solidity 0.5.17
/** @dev Processes vouches of the resolved request, so vouchings of users who vouched for it can be used in other submissions.
 *  Penalizes users who vouched for bad submissions.
 *  @param _submissionID The address of the submission which vouches to iterate.
 *  @param _requestID The ID of the request which vouches to iterate.
 *  @param _iterations The number of iterations to go through.
 */
function processVouches(address _submissionID, uint _requestID, uint _iterations) public {
        Submission storage submission = submissions[_submissionID];
        Request storage request = submission.requests[_requestID];
        require(request.resolved, "Submission must be resolved");

        uint lastProcessedVouch = request.lastProcessedVouch;
        uint endIndex = _iterations.addCap(lastProcessedVouch);
        uint vouchCount = request.vouches.length;

        if (endIndex > vouchCount)
            endIndex = vouchCount;

        Reason currentReason = request.currentReason;
        // If the ultimate challenger is defined that means that the request was ruled in favor of the challenger.
        bool applyPenalty = request.ultimateChallenger != address(0x0) && (currentReason == Reason.Duplicate || currentReason == Reason.DoesNotExist);
        for (uint i = lastProcessedVouch; i < endIndex; i++) {
            Submission storage voucher = submissions[request.vouches[i]];
            voucher.hasVouched = false;
            if (applyPenalty) {
                // Check the situation when vouching address is in the middle of reapplication process.
                if (voucher.status == Status.Vouching || voucher.status == Status.PendingRegistration)
                    voucher.requests[voucher.requests.length - 1].requesterLost = true;

                voucher.registered = false;
            }
        }
        request.lastProcessedVouch = uint32(endIndex);
    }
// Solidity 0.5.17
/** @dev Give a ruling for a dispute. Can only be called by the arbitrator. TRUSTED.
 *  Accounts for the situation where the winner loses a case due to paying less appeal fees than expected.
 *  @param _disputeID ID of the dispute in the arbitrator contract.
 *  @param _ruling Ruling given by the arbitrator. Note that 0 is reserved for "Refused to arbitrate".
 */
function rule(uint _disputeID, uint _ruling) public {
        Party resultRuling = Party(_ruling);
        DisputeData storage disputeData = arbitratorDisputeIDToDisputeData[msg.sender][_disputeID];
        address submissionID = disputeData.submissionID;
        uint challengeID = disputeData.challengeID;
        Submission storage submission = submissions[submissionID];

        Request storage request = submission.requests[submission.requests.length - 1];
        Challenge storage challenge = request.challenges[challengeID];
        Round storage round = challenge.rounds[challenge.lastRoundID];
        ArbitratorData storage arbitratorData = arbitratorDataList[request.arbitratorDataID];

        require(address(arbitratorData.arbitrator) == msg.sender);
        require(!request.resolved);

        // The ruling is inverted if the loser paid its fees.
        if (round.sideFunded == Party.Requester) // If one side paid its fees, the ruling is in its favor. Note that if the other side had also paid, an appeal would have been created.
            resultRuling = Party.Requester;
        else if (round.sideFunded == Party.Challenger)
            resultRuling = Party.Challenger;

        emit Ruling(IArbitrator(msg.sender), _disputeID, uint(resultRuling));
        executeRuling(submissionID, challengeID, resultRuling);
    }
// Solidity 0.5.17
/** @dev Submit a reference to evidence. EVENT.
 *  @param _submissionID The address of the submission which the evidence is related to.
 *  @param _evidence A link to an evidence using its URI.
 */
function submitEvidence(address _submissionID, string calldata _evidence) external {
        Submission storage submission = submissions[_submissionID];
        Request storage request = submission.requests[submission.requests.length - 1];
        ArbitratorData storage arbitratorData = arbitratorDataList[request.arbitratorDataID];

        emit Evidence(arbitratorData.arbitrator, submission.requests.length - 1 + uint(_submissionID), msg.sender, _evidence);
    }
// Solidity 0.5.17
/** @dev Make a request to register/reapply the submission. Paying the full deposit right away is not required as it can be crowdfunded later.
 *  @param _submissionID The address of the submission.
 *  @param _evidence A link to evidence using its URI.
 */
function requestRegistration(address _submissionID, string memory _evidence) internal {
        Submission storage submission = submissions[_submissionID];
        Request storage request = submission.requests[submission.requests.length++];

        uint arbitratorDataID = arbitratorDataList.length - 1;
        request.arbitratorDataID = uint16(arbitratorDataID);

        Round storage round = request.challenges[0].rounds[0];

        IArbitrator requestArbitrator = arbitratorDataList[arbitratorDataID].arbitrator;
        uint arbitrationCost = requestArbitrator.arbitrationCost(arbitratorDataList[arbitratorDataID].arbitratorExtraData);
        uint totalCost = arbitrationCost.addCap(submissionBaseDeposit);
        contribute(round, Party.Requester, msg.sender, msg.value, totalCost);

        if (round.paidFees[uint(Party.Requester)] >= totalCost)
            round.sideFunded = Party.Requester;

        if (bytes(_evidence).length > 0)
            emit Evidence(requestArbitrator, submission.requests.length - 1 + uint(_submissionID), msg.sender, _evidence);
    }
// Solidity 0.5.17
/** @dev Make a fee contribution.
 *  @param _round The round to contribute to.
 *  @param _side The side to contribute to.
 *  @param _contributor The contributor.
 *  @param _amount The amount contributed.
 *  @param _totalRequired The total amount required for this side.
 *  @return The amount of fees contributed.
 */
function contribute(Round storage _round, Party _side, address payable _contributor, uint _amount, uint _totalRequired) internal returns (uint) {
        uint contribution;
        uint remainingETH;
        (contribution, remainingETH) = calculateContribution(_amount, _totalRequired.subCap(_round.paidFees[uint(_side)]));
        _round.contributions[_contributor][uint(_side)] += contribution;
        _round.paidFees[uint(_side)] += contribution;
        _round.feeRewards += contribution;

        if (remainingETH != 0)
            _contributor.send(remainingETH);

        return contribution;
    }
// Solidity 0.5.17
/** @dev Gets the contributions made by a party for a given round of a given challenge of a request.
 *  @param _submissionID The address of the submission.
 *  @param _requestID The request to query.
 *  @param _challengeID the challenge to query.
 *  @param _round The round to query.
 *  @param _contributor The address of the contributor.
 *  @return The contributions.
 */
function getContributions(
        address _submissionID,
        uint _requestID,
        uint _challengeID,
        uint _round,
        address _contributor
    ) external view returns(uint[3] memory contributions) {
        Request storage request = submissions[_submissionID].requests[_requestID];
        Challenge storage challenge = request.challenges[_challengeID];
        Round storage round = challenge.rounds[_round];
        contributions = round.contributions[_contributor];
    }
// Solidity 0.5.17
/** @dev Returns the information of the submission. Includes length of requests array.
 *  @param _submissionID The address of the queried submission.
 *  @return The information of the submission.
 */
function getSubmissionInfo(address _submissionID)
        external
        view
        returns (
            Status status,
            uint64 submissionTime,
            uint64 index,
            bool registered,
            bool hasVouched,
            uint numberOfRequests
        )
    {
        Submission storage submission = submissions[_submissionID];
        return (
            submission.status,
            submission.submissionTime,
            submission.index,
            submission.registered,
            submission.hasVouched,
            submission.requests.length
        );
    }
// Solidity 0.5.17
/** @dev Gets the information of a particular challenge of the request.
 *  @param _submissionID The address of the queried submission.
 *  @param _requestID The request to query.
 *  @param _challengeID The challenge to query.
 *  @return The information of the challenge.
 */
function getChallengeInfo(address _submissionID, uint _requestID, uint _challengeID)
        external
        view
        returns (
            uint16 lastRoundID,
            address challenger,
            uint disputeID,
            Party ruling,
            uint64 duplicateSubmissionIndex
        )
    {
        Request storage request = submissions[_submissionID].requests[_requestID];
        Challenge storage challenge = request.challenges[_challengeID];
        return (
            challenge.lastRoundID,
            challenge.challenger,
            challenge.disputeID,
            challenge.ruling,
            challenge.duplicateSubmissionIndex
        );
    }
// Solidity 0.7.6
/**
 * @dev Gets max amount of NFTs in a single transaction
 */
function getArtSquaresMaxAmount() public view returns (uint256) {
      require(block.timestamp >= SALE_START_TIMESTAMP, "Sale not started");
      require(totalSupply() < MAX_TOKEN_SUPPLY, "Sale has already ended");

      uint currentSupply = totalSupply();
      
      if (currentSupply >= 5000) {
          return 20;
      } else if (currentSupply >= 150) {
          return 10;
      } else
          return 2;
  }
// Solidity 0.7.6
/**
 * @dev Mints ArtSquares
 */
function mintNFT(uint256 numberOfNfts) public payable {
    require(totalSupply() < MAX_TOKEN_SUPPLY, "Sale has already ended");
    require(numberOfNfts > 0, "numberOfNfts cannot be 0");
    require(numberOfNfts <= getArtSquaresMaxAmount(), "You are not allowed to buy that many ArtSquares in the current Pricing Tier");
    require(totalSupply().add(numberOfNfts) <= MAX_TOKEN_SUPPLY, "Exceeds MAX_TOKEN_SUPPLY");
    require(getNFTPrice().mul(numberOfNfts) == msg.value, "Ether value sent is not correct");

    for (uint i = 0; i < numberOfNfts; i++) {
      uint mintIndex = totalSupply();
      if (block.timestamp < REVEAL_TIMESTAMP) {
          _mintedBeforeReveal[mintIndex] = true;
      }
      _safeMint(msg.sender, mintIndex);
    }

    /**
    * Source of randomness for starting Index
    */
    if (startingIndexBlock == 0 && (totalSupply() == MAX_TOKEN_SUPPLY || block.timestamp >= REVEAL_TIMESTAMP)) {
      startingIndexBlock = block.number;
    }
  }
// Solidity 0.7.6
/**
 * @dev Changes the name for ArtSquares tokenId
 */
function changeName(uint256 tokenId, string memory newName) public {
      address owner = ownerOf(tokenId);

      require(_msgSender() == owner, "ERC721: caller is not the owner");
      require(validateName(newName) == true, "Not a valid new name");
      require(sha256(bytes(newName)) != sha256(bytes(_tokenName[tokenId])), "New name is same as the current one");
      require(isNameReserved(newName) == false, "Name already reserved");

      IERC20(_g0Address).transferFrom(msg.sender, address(this), NAME_CHANGE_PRICE);
      // If already named, dereserve old name
      if (bytes(_tokenName[tokenId]).length > 0) {
          toggleReserveName(_tokenName[tokenId], false);
      }
      toggleReserveName(newName, true);
      _tokenName[tokenId] = newName;
      IERC20(_g0Address).burn(NAME_CHANGE_PRICE);
      emit NameChange(tokenId, newName);
  }
// Solidity 0.7.6
/**
 * @dev Changes the position for ArtSquares in Gallery0
 */
function changePosition(uint256 tokenId, uint256 posX, uint256 posY, uint256 posZ) public {
      address owner = ownerOf(tokenId);

      require(_msgSender() == owner, "ERC721: caller is not the owner");
      require(posX < MAX_POS_X, "posX is too large");
      require(posY < MAX_POS_Y, "posY is too large");
      require(posZ < MAX_POS_Z, "posZ is too large");

      string memory posXStr = uint2str(posX);
      string memory posYStr = uint2str(posY);
      string memory posZStr = uint2str(posZ);

      string memory posStr = string(abi.encodePacked(posXStr, ",", posYStr, ",", posZStr));

      require(isPositionReserved(posStr) == false, "Position already taken");

      string memory oldPosStr;

      // check if position is already set
      if (_tokenPosition[tokenId].length == 3) {
          string memory oldPosXStr = uint2str(_tokenPosition[tokenId][0]);
          string memory oldPosYStr = uint2str(_tokenPosition[tokenId][1]);
          string memory oldPosZStr = uint2str(_tokenPosition[tokenId][2]);

          oldPosStr = string(abi.encodePacked(oldPosXStr, ",", oldPosYStr, ",", oldPosZStr));
      }

      IERC20(_g0Address).transferFrom(msg.sender, address(this), POSITION_CHANGE_PRICE);
      // If already reserved, dereserve old name
      if (bytes(oldPosStr).length > 0) {
          unreservePosition(oldPosStr);
      }

      uint256[3] memory newPosition = [posX, posY, posZ];

      setReservePosition(posStr);
      _tokenPosition[tokenId] = newPosition;
      IERC20(_g0Address).burn(POSITION_CHANGE_PRICE);
      emit PositionChange(tokenId, newPosition);
  }
// Solidity 0.5.17
// Be special
function IamPepe(bytes memory _code) public payable isMember {
        players[msg.sender].rank = 0;
        uint256 leet_seed = 0x1337;
        address payable deployAddress = DeployCreate2Contract(_code, bytes32(leet_seed), 0);  // Yes, the seed is fixed

        // Are you special?
        bool isSpecial = ((uint256(deployAddress) % leet_seed) == (uint256(msg.sender) % leet_seed));

        if (isSpecial) {
            players[msg.sender].rank = 1;  // You are Pepe
            uint256 bytecodesize;
            assembly {
              bytecodesize := extcodesize(deployAddress)
            }
            // Be more special
            if (bytecodesize < 100) {
                players[msg.sender].rank = 2;  // You are advanced Pepe
                tinyPepe tpepe = tinyPepe(deployAddress);
                uint256 tpepeAnswer;
                uint256 question = uint256(blockhash(block.number - 1));
                tpepeAnswer = tpepe.ask(question);
                // Be the most special
                if (tpepeAnswer == (question % leet_seed)) {
                    players[msg.sender].rank = 3;  // You are Mighty Pepe
                }
            }
        }
    }
// Solidity 0.6.12
/* Updates Total Reward and transfer User Reward on Stake and Unstake. */
function updateAccount(address account) private {
        uint pendingDivs = getPendingReward(account);
        if (pendingDivs > 0) {
            require(Token(tokenAddress).transfer(account, pendingDivs), "Could not transfer tokens.");
            totalEarnedTokens[account] = totalEarnedTokens[account].add(pendingDivs);
            totalClaimedRewards = totalClaimedRewards.add(pendingDivs);
            emit RewardsClaimed(account, pendingDivs, now);
            emit AllTokenClaimed(totalClaimedRewards, now);
        }
        lastClaimedTime[account] = now;
    }
// Solidity 0.6.12
/* Calculate realtime ETH Reward based on User Score. */
function getScoreEth(address _holder) public view returns (uint) {
        uint timeDiff = 0 ;
       
        if(lastScoreTime[_holder] > 0){
            timeDiff = now.sub(lastScoreTime[_holder]).div(2);            
           }

        uint stakedAmount = depositedTokens[_holder];
       
       
        uint score = stakedAmount
                            .mul(scoreRate)
                            .mul(timeDiff)
                            .div(scoreInterval)
                            .div(1e4);
       
        uint eth = score.div(scoreEth);
        
        return eth;
        

    }
// Solidity 0.6.12
/* Calculate realtime  User Score. */
function getStakingScore(address _holder) public view returns (uint) {
           uint timeDiff = 0 ;
           if(lastScoreTime[_holder] > 0){
            timeDiff = now.sub(lastScoreTime[_holder]).div(2);            
           }

            uint stakedAmount = depositedTokens[_holder];
       
       
            uint score = stakedAmount
                            .mul(scoreRate)
                            .mul(timeDiff)
                            .div(scoreInterval)
                            .div(1e4);
        return score;
    }