lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.4.24
// function create(address _beneficiary, uint256 _start, uint256 _cliff, uint256 _duration, bool _revocable, uint256 noOfTokens) onlyOwner public returns(StandardTokenVesting) {
function create(address _beneficiary, uint256 _cliff, uint256 _duration, bool _revocable, uint256 noOfTokens) public onlyOwner  returns(StandardTokenVesting) {
        StandardTokenVesting vesting = new StandardTokenVesting(_beneficiary, now , _cliff , _duration, _revocable);

        vesting.transferOwnership(msg.sender);
        vestingContractAddresses[_beneficiary] = vesting;
        emit CreatedStandardVestingContract(vesting);
        assert(token.transferFrom(owner, vesting, noOfTokens));

        return vesting;
    }
// Solidity 0.4.24
// Funds withdrawal to cover costs of fairwin operation.
function withdrawFunds(address beneficiary, uint withdrawAmount) external onlyOwner {
        require (withdrawAmount <= address(this).balance, "Increase amount larger than balance.");
        require (jackpotSize + lockedInBets + withdrawAmount <= address(this).balance, "Not enough funds.");
        sendFunds(beneficiary, withdrawAmount, withdrawAmount);
    }
// Solidity 0.4.24
// This is the method used to settle 99% of bets. To process a bet with a specific
// "commit", settleBet should supply a "reveal" number that would Keccak256-hash to
// "commit". "blockHash" is the block hash of placeBet block as seen by croupier; it
// is additionally asserted to prevent changing the bet outcomes on Ethereum reorgs.
function settleBet(uint reveal, bytes32 blockHash) external onlyCroupier {
        uint commit = uint(keccak256(abi.encodePacked(reveal)));

        Bet storage bet = bets[commit];
        uint placeBlockNumber = bet.placeBlockNumber;

        // Check that bet has not expired yet (see comment to BET_EXPIRATION_BLOCKS).
        require (block.number > placeBlockNumber, "settleBet in the same block as placeBet, or before.");
        require (block.number <= placeBlockNumber + BET_EXPIRATION_BLOCKS, "Blockhash can't be queried by EVM.");
        require (blockhash(placeBlockNumber) == blockHash);

        // Settle bet using reveal and blockHash as entropy sources.
        settleBetCommon(bet, reveal, blockHash);
    }
// Solidity 0.4.24
// This method is used to settle a bet that was mined into an uncle block. At this
// point the player was shown some bet outcome, but the blockhash at placeBet height
// is different because of Ethereum chain reorg. We supply a full merkle proof of the
// placeBet transaction receipt to provide untamperable evidence that uncle block hash
// indeed was present on-chain at some point.
function settleBetUncleMerkleProof(uint reveal, uint40 canonicalBlockNumber) external onlyCroupier {
        // "commit" for bet settlement can only be obtained by hashing a "reveal".
        uint commit = uint(keccak256(abi.encodePacked(reveal)));

        Bet storage bet = bets[commit];

        // Check that canonical block hash can still be verified.
        require (block.number <= canonicalBlockNumber + BET_EXPIRATION_BLOCKS, "Blockhash can't be queried by EVM.");

        // Verify placeBet receipt.
        requireCorrectReceipt(4 + 32 + 32 + 4);

        // Reconstruct canonical & uncle block hashes from a receipt merkle proof, verify them.
        bytes32 canonicalHash;
        bytes32 uncleHash;
        (canonicalHash, uncleHash) = verifyMerkleProof(commit, 4 + 32 + 32);
        require (blockhash(canonicalBlockNumber) == canonicalHash);

        // Settle bet using reveal and uncleHash as entropy sources.
        settleBetCommon(bet, reveal, uncleHash);
    }
// Solidity 0.4.24
// Refund transaction - return the bet amount of a roll that was not processed in a
// due timeframe. Processing such blocks is not possible due to EVM limitations (see
// BET_EXPIRATION_BLOCKS comment above for details). In case you ever find yourself
// in a situation like this, just contact the fairwin support, however nothing
// precludes you from invoking this method yourself.
function refundBet(uint commit) external {
        // Check that bet is in 'active' state.
        Bet storage bet = bets[commit];
        uint amount = bet.amount;

        require (amount != 0, "Bet should be in an 'active' state");

        // Check that bet has already expired.
        require (block.number > bet.placeBlockNumber + BET_EXPIRATION_BLOCKS, "Blockhash can't be queried by EVM.");

        // Move bet into 'processed' state, release funds.
        bet.amount = 0;

        uint diceWinAmount;
        uint jackpotFee;
        (diceWinAmount, jackpotFee) = getDiceWinAmount(amount, bet.modulo, bet.rollUnder);

        lockedInBets -= uint128(diceWinAmount);
        jackpotSize -= uint128(jackpotFee);

        // Send the refund.
        sendFunds(bet.gambler, amount, amount);
    }
// Solidity 0.4.24
// Get the expected win amount after house edge is subtracted.
function getDiceWinAmount(uint amount, uint modulo, uint rollUnder) private pure returns (uint winAmount, uint jackpotFee) {
        require (0 < rollUnder && rollUnder <= modulo, "Win probability out of range.");

        jackpotFee = amount >= MIN_JACKPOT_BET ? JACKPOT_FEE : 0;

        uint houseEdge = amount * HOUSE_EDGE_PERCENT / 100;

        if (houseEdge < HOUSE_EDGE_MINIMUM_AMOUNT) {
            houseEdge = HOUSE_EDGE_MINIMUM_AMOUNT;
        }

        require (houseEdge + jackpotFee <= amount, "Bet doesn't even cover house edge.");
        winAmount = (amount - houseEdge - jackpotFee) * modulo / rollUnder;
    }
// Solidity 0.4.24
// Memory copy.
function memcpy(uint dest, uint src, uint len) pure private {
        // Full 32 byte words
        for(; len >= 32; len -= 32) {
            assembly { mstore(dest, mload(src)) }
            dest += 32; src += 32;
        }

        // Remaining bytes
        uint mask = 256 ** (32 - len) - 1;
        assembly {
            let srcpart := and(mload(src), not(mask))
            let destpart := and(mload(dest), mask)
            mstore(dest, or(destpart, srcpart))
        }
    }
// Solidity 0.4.24
/**
 * @dev Generate new ETH Card Collectible, with isAttached as 2.
 * @notice Helps to generate Collectibles/Tokens/Asset and transfer to ETH Cards,
 * which can be redeemed using our web-app.The generation of an asset if limited via the generationSeasonController
 * @param _teamId           teamId of the asset/token/collectible
 * @param _posId            position of the asset/token/collectible
 * @param _attributes       attributes of asset/token/collectible
 * @param _owner            owner of asset/token/collectible
 * @param _gameId           mlb game Identifier
 * @param _playerOverrideId player override identifier
 * @param _mlbPlayerId      official mlb player identifier
 */
function createETHCardCollectible (
        uint8 _teamId,
        uint8 _posId,
        uint256 _attributes,
        address _owner,
        uint256 _gameId,
        uint256 _playerOverrideId,
        uint256 _mlbPlayerId)
        external
        canCreate
        whenNotPaused
        returns (uint256) {

        address nftOwner = _owner;
        
        if (nftOwner == address(0)) {
             nftOwner = managerPrimary;
        }
        
        rewardsRedeemed++;
        uint32 _sequenceId = getSequenceId(_teamId);
        
        uint256 assetDetails = uint256(uint64(now));
        assetDetails |= uint256(_sequenceId)<<64;
        assetDetails |= uint256(_teamId)<<96;
        assetDetails |= uint256(_posId)<<104;

        uint256[5] memory _nftData = [assetDetails, _attributes, _gameId, _playerOverrideId, _mlbPlayerId];
        
        return _createNFTCollectible(_teamId, _attributes, nftOwner, 2, _nftData);
    }
// Solidity 0.4.24
/**
 * @dev Returns all the relevant information about a specific Collectible.
 * @notice Get details about your collectible
 * @param _tokenId              The token identifier
 * @return isAttached           Is Object attached
 * @return teamId               team identifier of the asset/token/collectible
 * @return positionId           position identifier of the asset/token/collectible
 * @return creationTime         creation timestamp
 * @return attributes           attribute of the asset/token/collectible
 * @return currentGameCardId    current game card of the asset/token/collectible
 * @return mlbGameID            mlb game identifier in which the asset/token/collectible was generated
 * @return playerOverrideId     player override identifier of the asset/token/collectible
 * @return playerStatus         status of the player (Rookie/Veteran/Historical)
 * @return playerHandedness     handedness of the asset
 * @return mlbPlayerId          official MLB Player Identifier
 */
function getCollectibleDetails(uint256 _tokenId)
        external
        view
        returns (
        uint256 isAttached,
        uint32 sequenceId,
        uint8 teamId,
        uint8 positionId,
        uint64 creationTime,
        uint256 attributes,
        uint256 playerOverrideId,
        uint256 mlbGameId,
        uint256 currentGameCardId,
        uint256 mlbPlayerId,
        uint256 earnedBy,
        uint256 generationSeason
        ) {
        NFT memory obj  = _getAttributesOfToken(_tokenId);
        
        attributes = obj.attributes;
        currentGameCardId = obj.currentGameCardId;
        mlbGameId = obj.mlbGameId;
        playerOverrideId = obj.playerOverrideId;
        mlbPlayerId = obj.mlbPlayerId;

        creationTime = uint64(obj.assetDetails);
        sequenceId = uint32(obj.assetDetails>>64);
        teamId = uint8(obj.assetDetails>>96);
        positionId = uint8(obj.assetDetails>>104);
        isAttached = obj.isAttached;
        earnedBy = obj.earnedBy;

        generationSeason = generationSeasonDict[(obj.attributes % 1000000) / 1000];
    }
// Solidity 0.4.24
// External function
function spin(bytes32 hash, uint8 _v, bytes32 _r, bytes32 _s)
        external
        payable
        mustSignWithECDSA(hash, _v, _r, _s)
    {
        // Conditions
        require(msg.value >= minimumWager, "wager must be greater than or equal minimumWager.");
        require(msg.value <= maximumWager, "wager must be lower than or equal maximumWager.");
        require(
            address(this).balance >= msg.value * maximumMultiplier, 
            "contract balance must greater than wager * maximumMultiplier."
        );
        require(msg.sender == tx.origin, 'only EOA can call this contract');

        
        //Interaction
        string memory firstSymbol;
        string memory secondSymbol;
        string memory thirdSymbol;
        uint rewardAmount = 0;
        uint8 multiplier = 0;
        uint8 cherryCount = 0;
        bool isWin = false;

        (firstSymbol, secondSymbol, thirdSymbol) = _findThreeSymbols(_s);
        
        if (_isWin(firstSymbol, secondSymbol, thirdSymbol)) {
            // Normal win
            isWin = true;
            (rewardAmount, multiplier) = _calculateRewardAmount(msg.value, firstSymbol);
            _sendReward(rewardAmount);
        } else {
            cherryCount = _countCherry(firstSymbol, secondSymbol, thirdSymbol);
            if (cherryCount > 0) {
                // Cherry win
                isWin = true;
                (rewardAmount, multiplier) = _calculateRewardAmountForCherry(msg.value, cherryCount);
                _sendCherryReward(rewardAmount);
            }
        }

        emit LogSpinResult(msg.sender, msg.value, isWin, firstSymbol, secondSymbol, thirdSymbol, multiplier, rewardAmount);
    }
// Solidity 0.4.24
/**
 * @dev Only allows trasnctions to go throught if the msg.sender is in the apporved list
 * @notice Updates the gameCardID properrty of the asset
 * @param _gameCardNumber  The game card number
 * @param _playerId        The player identifier
 */
function updateCurrentGameCardId(uint256 _gameCardNumber, uint256 _playerId) public whenNotPaused {
        require (contractsApprovedList[msg.sender]);

        NFT memory obj  = _getAttributesOfToken(_playerId);
        
        obj.currentGameCardId = _gameCardNumber;
        
        if ( _gameCardNumber == 0 ) {
            obj.isAttached = 0;
        } else {
            obj.isAttached = 1;
        }

        allNFTs[_playerId] = obj;
    }
// Solidity 0.8.9
//  redeem(): burn one star token, receive ownership of the most recently deposited star in exchange
//
function redeem() external returns (uint16) {
        // must have sufficient balance
        require(startoken.balanceOf(_msgSender()) >= ONE_STAR, "Treasury: Not enough balance");

        // there must be at least one star in the asset list
        require(assets.length > 0, "Treasury: no star available to redeem");

        // remove the star to be redeemed
        uint16 _star = assets[assets.length-1];
        assets.pop();

        // burn the tokens
        startoken.ownerBurn(_msgSender(), ONE_STAR);

        // transfer ownership
        // note: Treasury should be the owner of the point and able to transfer it. this check happens inside
        // transferPoint().
        IEcliptic ecliptic = IEcliptic(azimuth.owner());
        // note: _star is uint16, ecliptic expects a uint32 point
        ecliptic.transferPoint(_star, _msgSender(), true);

        emit Redeem(azimuth.getPrefix(_star), _star, _msgSender());
        return _star;
    }
// Solidity 0.4.24
// Decrease the amount of tokens that an owner allowed to a spender.
// approve should be called when allowed[spender] == 0.
// To decrement allowed value is better to use this function to avoid 2 calls (and wait until the first transaction is mined)
function decreaseApproval(address spender, uint256 subtractedValue ) public returns (bool){
    uint256 oldValue = allowed[msg.sender][spender];
    if (subtractedValue >= oldValue) {
      allowed[msg.sender][spender] = 0;
    } else {
      allowed[msg.sender][spender] = oldValue.sub(subtractedValue);
    }
    emit Approval(msg.sender, spender, allowed[msg.sender][spender]);
    return true;
  }
// Solidity 0.6.4
//freeze HXY tokens to contract
function Freeze(address token)
        public
    {
        if(isFreezeFinished(msg.sender, token)){
            Unfreeze(token);//unfreezes all currently frozen tokens
        }
        uint amt;
        //update balances
        if(token == hxyAddress){
            amt = mintedHxy[msg.sender];
            require(amt > 0, "Error: insufficient balance available to freeze");//ensure user has enough funds allocated
            mintedHxy[msg.sender] = 0;
            tokenHxyFrozenBalances[msg.sender] += amt;
            totalHxyFrozen += amt;
            frozen[msg.sender].freezeHxyStartTimestamp = now;
        }
        else if(token == hxbAddress){
            amt = mintedHxb[msg.sender];
            require(amt > 0, "Error: insufficient balance available to lock");//ensure user has enough funds allocated
            mintedHxb[msg.sender] = 0;
            tokenHxbLockedBalances[msg.sender] += amt;
            totalHxbLocked += amt;
            frozen[msg.sender].lockHxbStartTimestamp = now;
        }
        else if(token == hxpAddress){
            amt = mintedHxp[msg.sender];
            require(amt > 0, "Error: insufficient balance available to freeze");//ensure user has enough funds allocated
            mintedHxp[msg.sender] = 0;
            tokenHxpFrozenBalances[msg.sender] += amt;
            totalHxpFrozen += amt;
            frozen[msg.sender].freezeHxpStartTimestamp = now;
        }
        else{
            revert();
        }
        emit TokenFreeze(msg.sender, amt, token);
    }
// Solidity 0.6.4
//unfreeze HXY tokens from contract
function Unfreeze(address token)
        public
    {
        uint amt;
        if(token == hxyAddress){
            require(tokenHxyFrozenBalances[msg.sender] > 0,"Error: unsufficient frozen balance");//ensure user has enough frozen funds
            require(isFreezeFinished(msg.sender, token), "tokens cannot be unfrozen yet, min 90 days");
            amt = tokenHxyFrozenBalances[msg.sender];
            tokenHxyFrozenBalances[msg.sender] = 0;
            frozen[msg.sender].freezeHxyStartTimestamp = 0;
            totalHxyFrozen -= amt;
            hxy.transfer(msg.sender, amt);//make transfer
        }
        else if(token == hxbAddress){
            require(tokenHxbLockedBalances[msg.sender] > 0,"Error: unsufficient frozen balance");//ensure user has enough frozen funds
            require(isFreezeFinished(msg.sender, token), "tokens cannot be unlocked yet, max HXB supply much be reached");
            amt = tokenHxbLockedBalances[msg.sender];
            tokenHxbLockedBalances[msg.sender] = 0;
            frozen[msg.sender].lockHxbStartTimestamp = 0;
            totalHxbLocked -= amt;
            hxb.transfer(msg.sender, amt);//make transfer
        }
        else if(token == hxpAddress){
            require(tokenHxpFrozenBalances[msg.sender] > 0,"Error: unsufficient frozen balance");//ensure user has enough frozen funds
            require(isFreezeFinished(msg.sender, token), "tokens cannot be unfrozen yet, can be unfrozen on platform launch");
            amt = tokenHxpFrozenBalances[msg.sender];
            tokenHxpFrozenBalances[msg.sender] = 0;
            frozen[msg.sender].freezeHxpStartTimestamp = 0;
            totalHxpFrozen -= amt;
            hxp.transfer(msg.sender, amt);//make transfer
        }

        else{
            revert();
        }

        emit TokenUnfreeze(msg.sender, amt, token);
    }
// Solidity 0.6.4
//HXY frozen for 365 days , HXB locked till maxSupply , HXP frozen till platform launch
function isFreezeFinished(address _user, address token)
        public
        view
        returns(bool)
    {
        if(token == hxyAddress){
            if(frozen[_user].freezeHxyStartTimestamp == 0){
                return false;
            }
            else{
               return (frozen[_user].freezeHxyStartTimestamp + (365 * daySeconds)) <= now;               
            }
        }
        else if(token == hxbAddress){
            if(frozen[_user].lockHxbStartTimestamp == 0){
                return false;
            }
            else{
                return hxb.mintBlock();   
            }
        }
        else if(token == hxpAddress){
            if(frozen[_user].freezeHxpStartTimestamp == 0){
                return false;
            }
            else{
                return hxpUnlocked;
            }
        }
        else{
            return false;
        }
    }
// Solidity 0.4.24
/**
 * @dev A batch function to facilitate batching of asset creation. canCreate modifier
 * helps in controlling who can call the function
 * @notice Batch Function to Create Assets
 * @param      _teamId            The team identifier
 * @param      _attributes        The attributes
 * @param      _playerOverrideId  The player override identifier
 * @param      _mlbPlayerId       The mlb player identifier
 * @param      _to                To Address
 */
function batchCreateAsset(
        uint8[] _teamId,
        uint256[] _attributes,
        uint256[] _playerOverrideId,
        uint256[] _mlbPlayerId,
        address[] _to)
        external
        canCreate
        whenNotPaused {
            require (isBatchSupported);

            require (_teamId.length > 0 && _attributes.length > 0 && 
                _playerOverrideId.length > 0 && _mlbPlayerId.length > 0 && 
                _to.length > 0);

            uint256 assetDetails;
            uint256[5] memory _nftData;
            
            for(uint ii = 0; ii < _attributes.length; ii++){
                require (_to[ii] != address(0) && _teamId[ii] != 0 && _attributes.length != 0 && 
                    _mlbPlayerId[ii] != 0);
                
                assetDetails = uint256(uint64(now));
                assetDetails |= uint256(getSequenceId(_teamId[ii]))<<64;
                assetDetails |= uint256(_teamId[ii])<<96;
                assetDetails |= uint256((_attributes[ii]/1000000000000000000000000000000000000000)-800)<<104;
        
                _nftData = [assetDetails, _attributes[ii], 0, _playerOverrideId[ii], _mlbPlayerId[ii]];
                
                _createNFTCollectible(_teamId[ii], _attributes[ii], _to[ii], 0, _nftData);
            }
        }
// Solidity 0.6.7
/*
 * @notify Modify an uint256 parameter
 * @param parameter The name of the parameter to change
 * @param val The new value for the parameter
 */
function modifyParameters(bytes32 parameter, uint256 val) external isAuthority {
        if (parameter == "nb") {
          require(both(val > 0, val <= EIGHTEEN_DECIMAL_NUMBER), "PRawPerSecondCalculator/invalid-nb");
          noiseBarrier = val;
        }
        else if (parameter == "ps") {
          require(val > 0, "PRawPerSecondCalculator/null-ps");
          periodSize = val;
        }
        else if (parameter == "foub") {
          require(both(val < subtract(subtract(uint(-1), defaultRedemptionRate), 1), val > 0), "PRawPerSecondCalculator/invalid-foub");
          feedbackOutputUpperBound = val;
        }
        else if (parameter == "allReaderToggle") {
          allReaderToggle = val;
        }
        else revert("PRawPerSecondCalculator/modify-unrecognized-param");
    }
// Solidity 0.4.24
/**
 * @dev        Overriden TransferFrom, with the modifier canTransfer which uses our attachment system
 * @notice     Helps in trasnferring assets
 * @param      _from     the address sending from
 * @param      _to       the address sending to
 * @param      _tokenId  The token identifier
 */
function transferFrom(
        address _from,
        address _to,
        uint256 _tokenId
    )
        public
        canTransfer(_tokenId)
    {
        // Asset should not be in play
        require (checkIsAttached(_tokenId) == 0);
        
        require (_from != address(0));

        require (_to != address(0));

        clearApproval(_from, _tokenId);
        removeTokenFrom(_from, _tokenId);
        addTokenTo(_to, _tokenId);

        emit Transfer(_from, _to, _tokenId);
    }
// Solidity 0.6.7
/*
 * @notice Return a redemption rate bounded by feedbackOutputLowerBound and feedbackOutputUpperBound as well as the
 timeline over which that rate will take effect
 * @param pOutput The raw redemption rate computed from the proportional and integral terms
 */
function getBoundedRedemptionRate(int pOutput) public isReader view returns (uint256, uint256) {
        int  boundedPOutput = pOutput;
        uint newRedemptionRate;

        if (pOutput < feedbackOutputLowerBound) {
          boundedPOutput = feedbackOutputLowerBound;
        } else if (pOutput > int(feedbackOutputUpperBound)) {
          boundedPOutput = int(feedbackOutputUpperBound);
        }

        // newRedemptionRate cannot be lower than 10^0 (1) because of the way rpower is designed
        bool negativeOutputExceedsHundred = (boundedPOutput < 0 && -boundedPOutput >= int(defaultRedemptionRate));

        // If it is smaller than 1, set it to the nagative rate limit
        if (negativeOutputExceedsHundred) {
          newRedemptionRate = NEGATIVE_RATE_LIMIT;
        } else {
          // If boundedPOutput is lower than -int(NEGATIVE_RATE_LIMIT) set newRedemptionRate to 1
          if (boundedPOutput < 0 && boundedPOutput <= -int(NEGATIVE_RATE_LIMIT)) {
            newRedemptionRate = uint(addition(int(defaultRedemptionRate), -int(NEGATIVE_RATE_LIMIT)));
          } else {
            // Otherwise add defaultRedemptionRate and boundedPOutput together
            newRedemptionRate = uint(addition(int(defaultRedemptionRate), boundedPOutput));
          }
        }

        return (newRedemptionRate, defaultGlobalTimeline);
    }