lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.6.12
//create new escrow
function createNewEscrow(address escrowpayee, uint escrowamount) external 
    {
        
        require(factorycontractactive, "Factory Contract should be Active");
        require(escrowid < maxuint, "Maximum escrowid reached");
        require(msg.sender != escrowpayee,"The Payer, payee should be different");
        require(escrowpayee != address(0),"The Escrow Payee can not be address(0)");
        require(escrowamount > 0,"Escrow amount has to be greater than 0");
        
        require(daiToken.allowance(msg.sender,address(this)) >= mathlib.add(escrowamount, escrowfee), "daiToken allowance exceeded");
        
        bytes32 esid = keccak256(abi.encodePacked(escrowid));
        
        Escrows[esid] = Escrow({escrowpayer:msg.sender, escrowpayee:escrowpayee, escrowamount:escrowamount,
            escrowsettlementamount:escrowamount, estatus:escrowstatus.ACTIVATED,escrowmoderator:address(0),escrowmoderatorfee:0});
        
        escrowid = mathlib.add(escrowid,1);
        
        //The Esrow Amount gets transferred to factory contract
        daiToken.transferFrom(msg.sender, address(this), escrowamount);
        
        //Transfer the escrow fee to factory manager
        daiToken.transferFrom(msg.sender, manager, escrowfee);
        
        emit NewEscrowEvent(esid, msg.sender, escrowpayee, escrowamount, now);
        
        emit NewEscrowEventById(esid, msg.sender, escrowpayee, escrowamount, now);
        
    }
// Solidity 0.6.12
//create new escrow overload
function createNewEscrow(address escrowpayee, uint escrowamount, address escrowmoderator, uint escrowmoderatorfee) external 
    {
        
        require(factorycontractactive, "Factory Contract should be Active");
        require(escrowid < maxuint, "Maximum escrowid reached");
        require(msg.sender != escrowpayee && msg.sender != escrowmoderator && escrowpayee != escrowmoderator,"The Payer, payee & moderator should be different");
        require(escrowpayee != address(0) && escrowmoderator!=address(0),"Escrow Payee or moderator can not be address(0)");
        require(escrowamount > 0,"Escrow amount has to be greater than 0");
    
        uint dailockedinnewescrow = mathlib.add(escrowamount,escrowmoderatorfee);
  
        require(daiToken.allowance(msg.sender,address(this)) >= mathlib.add(dailockedinnewescrow, escrowfee), "daiToken allowance exceeded");
        
        bytes32 esid = keccak256(abi.encodePacked(escrowid));
        
        Escrows[esid] = Escrows[esid] = Escrow({escrowpayer:msg.sender, escrowpayee:escrowpayee, escrowamount:escrowamount,
            escrowsettlementamount:escrowamount, estatus:escrowstatus.ACTIVATED,escrowmoderator:escrowmoderator,escrowmoderatorfee:escrowmoderatorfee});
        
        escrowid = mathlib.add(escrowid,1);
        
        //The Esrow Amount and Moderator fee gets transferred to factory contract
        daiToken.transferFrom(msg.sender, address(this), dailockedinnewescrow);
        
        //Transfer the escrow fee to factory manager
        daiToken.transferFrom(msg.sender, manager, escrowfee);
        
        emit NewEscrowEvent(esid, msg.sender, escrowpayee, escrowamount, escrowmoderator, escrowmoderatorfee ,now);
        
        emit NewEscrowEventById(esid, msg.sender, escrowpayee, escrowamount, escrowmoderator, escrowmoderatorfee, now);
        
    }
// Solidity 0.4.21
/**
 * @dev Claim your share of the balance.
 */
function claim() public {
    address payee = msg.sender;

    require(shares[payee] > 0);

    uint256 totalReceived = this.balance.add(totalReleased);
    uint256 payment = totalReceived.mul(shares[payee]).div(totalShares).sub(released[payee]);

    require(payment != 0);
    require(this.balance >= payment);

    released[payee] = released[payee].add(payment);
    totalReleased = totalReleased.add(payment);

    payee.transfer(payment);
  }
// Solidity 0.4.21
/*function _transfer(address _from, address _to, uint256 _tokenId) internal {
 
 ownershipTokenCount[_to]++;
 // transfer ownership
 cardIndexToOwner[_tokenId] = _to;
 
 // Emit the transfer event.
 Transfer(_from, _to, _tokenId);
 
 }*/
function _createCard(uint256 _prototypeId, address _owner) internal returns (uint) {

        // This will assign ownership, and also emit the Transfer event as
        // per ERC721 draft
        require(uint256(1000000) > lastPrintedCard);
        lastPrintedCard++;
        tokenToCardIndex[lastPrintedCard] = _prototypeId;
        _setTokenOwner(lastPrintedCard, _owner);
        //_addTokenToOwnersList(_owner, lastPrintedCard);
        Transfer(0, _owner, lastPrintedCard);
        //tokenCountIndex[_prototypeId]++;
        
        //_transfer(0, _owner, lastPrintedCard); //<-- asd
        

        return lastPrintedCard;
    }
// Solidity 0.4.21
/// @notice Transfers the ownership of an NFT from one address to another address
/// @dev This works identically to the other function with an extra data parameter,
///  except this function just sets data to ""
/// @param _from The current owner of the NFT
/// @param _to The new owner
/// @param _tokenId The NFT to transfer
function safeTransferFrom(address _from, address _to, uint256 _tokenId) external payable {
        require(_getApproved(_tokenId) == msg.sender);
        require(_ownerOf(_tokenId) == _from);
        require(_to != address(0));

        _clearApprovalAndTransfer(_from, _to, _tokenId);

        Approval(_from, 0, _tokenId);
        Transfer(_from, _to, _tokenId);

        if (isContract(_to)) {
            bytes4 value = ERC721TokenReceiver(_to).onERC721Received(_from, _tokenId, "");

            if (value != bytes4(keccak256("onERC721Received(address,uint256,bytes)"))) {
                revert();
            }
        }
    }
// Solidity 0.8.6
/// @inheritdoc IPeripheryPayments
function sweepToken(
        address token,
        uint256 amountMinimum,
        address recipient
    ) external payable override {
        uint256 balanceToken = IERC20(token).balanceOf(address(this));
        require(balanceToken >= amountMinimum, 'Insufficient token');

        if (balanceToken > 0) {
            TransferHelper.safeTransfer(token, recipient, balanceToken);
        }
    }
// Solidity 0.8.6
/// @param token The token to pay
/// @param payer The entity that must pay
/// @param recipient The entity that will receive payment
/// @param value The amount to pay
function pay(
        address token,
        address payer,
        address recipient,
        uint256 value
    ) internal {
        if (token == WETH9 && address(this).balance >= value) {
            // pay with WETH9
            IWETH9(WETH9).deposit{value: value}(); // wrap only what is needed to pay
            IWETH9(WETH9).transfer(recipient, value);
        } else if (payer == address(this)) {
            // pay with tokens already in the contract (for the exact input multihop case)
            TransferHelper.safeTransfer(token, recipient, value);
        } else {
            // pull payment
            TransferHelper.safeTransferFrom(token, payer, recipient, value);
        }
    }
// Solidity 0.6.12
/**
 * Returns whether the target address is a contract
 * @dev This function will return false if invoked during the constructor of a contract,
 * as the code is not actually created until after the constructor finishes.
 * @param _addr address to check
 * @return whether the target address is a contract
 */
function isContract(address _addr) internal view returns (bool) {
    uint256 size;
    // XXX Currently there is no better way to check if there is a contract in an address
    // than to check the size of the code at that address.
    // See https://ethereum.stackexchange.com/a/14016/36603
    // for more details about how this works.
    // TODO Check this again before the Serenity release, because all addresses will be
    // contracts then.
    // solium-disable-next-line security/no-inline-assembly
    assembly { size := extcodesize(_addr) }
    return size > 0;
  }
// Solidity 0.6.12
/**
 * @dev Transfers the ownership of a given token ID to another address
 * Usage of this method is discouraged, use `safeTransferFrom` whenever possible
 * Requires the msg sender to be the owner, approved, or operator
 * @param _from current owner of the token
 * @param _to address to receive the ownership of the given token ID
 * @param _tokenId uint256 ID of the token to be transferred
 */
function transferFrom(
    address _from,
    address _to,
    uint256 _tokenId
  )
    public
    override
  {
    require(isApprovedOrOwner(msg.sender, _tokenId));
    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.12
/**
 * @dev Returns whether the given spender can transfer a given token ID
 * @param _spender address of the spender to query
 * @param _tokenId uint256 ID of the token to be transferred
 * @return bool whether the msg.sender is approved for the given token ID,
 *  is an operator of the owner, or is the owner of the token
 */
function isApprovedOrOwner(
    address _spender,
    uint256 _tokenId
  )
    internal
    view
    returns (bool)
  {
    address owner = ownerOf(_tokenId);
    // Disable solium check because of
    // https://github.com/duaraghav8/Solium/issues/175
    // solium-disable-next-line operator-whitespace
    return (
      _spender == owner ||
      getApproved(_tokenId) == _spender ||
      isApprovedForAll(owner, _spender)
    );
  }
// Solidity 0.8.7
// set room message
function setRoomMessage(uint256 tokenId, string memory newRoomMessage) external payable {
    require(_tokenIdCounter.current() >= tokenId && tokenId > 0, tokenIdInvalid);
    require( msg.sender == ownerOf(tokenId), "token owner only");
    require( msg.value >= _price, "incorrect ETH sent" );
    _roomMessage[tokenId] = newRoomMessage;
  }
// Solidity 0.6.12
/**
 * @dev Returns an URI for a given token ID.
 * Throws if the token ID does not exist. May return an empty string.
 * @param tokenId uint256 ID of the token to query
 */
function tokenURI(uint256 tokenId) external view returns (string memory) {
        require(exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
        string memory url = _tokenURIs[tokenId];
        bytes memory urlAsBytes = bytes(url);
        if (urlAsBytes.length == 0) {
            bytes memory baseURIAsBytes = bytes(baseURI);
            bytes memory tokenIdAsBytes = uintToBytes(tokenId);
            bytes memory b = new bytes(baseURIAsBytes.length + tokenIdAsBytes.length);
            uint256 i;
            uint256 j;
            for (i = 0; i < baseURIAsBytes.length; i++) {
                b[j++] = baseURIAsBytes[i];
            }
            for (i = 0; i < tokenIdAsBytes.length; i++) {
                b[j++] = tokenIdAsBytes[i];
            }
            return string(b);
        } else {
            return _tokenURIs[tokenId];
        }
    }
// Solidity 0.6.12
/**
 * @dev Mint token
 *
 * @param _to address of token owner
 */
function mint(address _to,uint256 amount) public returns (uint256) {
        
        require(_tokenIds.current() + amount < _max_supply, "CulturalArtTreasure: maximum quantity reached");
        require(amount > 0, "You must buy at least one .");
        uint256 newTokenId = 1;
        for (uint256 i = 0; i < amount; i++) {
			_tokenIds.increment();
			 newTokenId = _tokenIds.current();
			 
			_mint(_to, newTokenId);

			Attributes.Data storage attributes = attributesByTokenIds[newTokenId];
			attributes.init();
        }
        return newTokenId;
    }
// Solidity 0.8.7
// get room message
function getRoomMessage(uint256 tokenId) public view returns (string memory) {
    require(_tokenIdCounter.current() >= tokenId && tokenId > 0, tokenIdInvalid);
    bytes memory tempEmptyStringTest = bytes(_roomMessage[tokenId]);
    if (tempEmptyStringTest.length == 0) {
      uint256 randMsg = random("nft", tokenId);
      if (randMsg % 17 == 3)
        return "LFG!";
      else if (randMsg % 7 == 3)
        return "WAGMI!";
      else
        return "gm!";
    } else {
      return _roomMessage[tokenId];
    }
  }
// Solidity 0.8.7
// mint num of keycards
function mint(uint256 num) external payable nonReentrant {
    require( _publicSale, "public sale paused" );
    require( num <= 10, "max 10 per TX" );
    require( _tokenIdCounter.current() + num <= _maxSupply, "max supply reached" );
    require( msg.value >= _price * num, "incorrect ETH sent" );

    for( uint i = 0; i < num; i++ ) {
      _safeMint(_msgSender(), _tokenIdCounter.current() + 1);
      _tokenIdCounter.increment();
    }
  }
// Solidity 0.4.18
/**
 * @dev Creates a vesting contract that vests its balance of any ERC20 token to the
 * _beneficiary, gradually in a linear fashion until _start + _duration. By then all
 * of the balance will have vested.
 * @param _beneficiary address of the beneficiary to whom vested tokens are transferred
 * @param _cliff duration in seconds of the cliff in which tokens will begin to vest
 * @param _duration duration in seconds of the period in which the tokens will vest
 * @param _revocable whether the vesting is revocable or not
 */
function TokenVesting(address _beneficiary, uint256 _start, uint256 _cliff, uint256 _duration, bool _revocable) public {
    require(_beneficiary != address(0));
    require(_cliff <= _duration);

    beneficiary = _beneficiary;
    revocable = _revocable;
    duration = _duration;
    cliff = _start.add(_cliff);
    start = _start;
  }
// Solidity 0.4.18
/**
 * @dev Calculates the amount that has already vested.
 * @param token ERC20 token which is being vested
 */
function vestedAmount(ERC20Basic token) public view returns (uint256) {
    uint256 currentBalance = token.balanceOf(this);
    uint256 totalBalance = currentBalance.add(released[token]);

    if (now < cliff) {
      return 0;
    } else if (now >= start.add(duration) || revoked[token]) {
      return totalBalance;
    } else {
      return totalBalance.mul(now.sub(start)).div(duration);
    }
  }
// Solidity 0.4.18
/**
 * @dev Issues FTT to entitled accounts.
 * @param _user address to issue FTT to.
 * @param _fttAmount amount of FTT to issue.
 */
function issueFTT(address _user, uint256 _fttAmount)
        public
        onlyTdeIssuer
        tdeRunning
        returns(bool)
    {
        uint256 newAmountIssued = fttIssued.add(_fttAmount);
        require(_user != address(0));
        require(_fttAmount > 0);
        require(newAmountIssued <= FT_TOKEN_SALE_CAP);

        balances[_user] = balances[_user].add(_fttAmount);
        fttIssued = newAmountIssued;
        FTTIssued(tdeIssuer, _user, _fttAmount, block.timestamp);

        if (fttIssued == FT_TOKEN_SALE_CAP) {
            capReached = true;
        }

        return true;
    }
// Solidity 0.4.18
/**
 * @dev Allows the contract owner to finalize the TDE.
 */
function finalize()
        external
        tdeEnded
        onlyOwner
    {
        require(!isFinalized);

        // Deposit team fund amount into team vesting contract.
        uint256 teamVestingCliff = 15778476;  // 6 months
        uint256 teamVestingDuration = 1 years;
        TokenVesting teamVesting = new TokenVesting(owner, now, teamVestingCliff, teamVestingDuration, true);
        teamVesting.transferOwnership(owner);
        teamVestingAddress = address(teamVesting);
        balances[teamVestingAddress] = FT_TEAM_FUND;

        if (!capReached) {
            // Deposit unsold FTT into unsold vesting contract.
            uint256 unsoldVestingCliff = 3 years;
            uint256 unsoldVestingDuration = 10 years;
            TokenVesting unsoldVesting = new TokenVesting(owner, now, unsoldVestingCliff, unsoldVestingDuration, true);
            unsoldVesting.transferOwnership(owner);
            unsoldVestingAddress = address(unsoldVesting);
            balances[unsoldVestingAddress] = FT_TOKEN_SALE_CAP - fttIssued;
        }

        // Allocate operational reserve of FTT.
        balances[operationalReserveAddress] = FT_OPERATIONAL_FUND - FT_TEAM_FUND;

        isFinalized = true;
        TdeFinalized(block.timestamp);
    }
// Solidity 0.4.18
/**
 * @dev Transfer tokens from one address to another. Trading limited - requires the TDE to have ended.
 * @param _from address The address which you want to send tokens from
 * @param _to address The address which you want to transfer to
 * @param _value uint256 the amount of tokens to be transferred
 */
function transferFrom(address _from, address _to, uint256 _value)
        public
        returns (bool)
    {
        if (!isFinalized) return false;
        require(_to != address(0));
        require(_value <= balances[_from]);
        require(_value <= allowed[_from][msg.sender]);

        balances[_from] = balances[_from].sub(_value);
        balances[_to] = balances[_to].add(_value);
        allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
        Transfer(_from, _to, _value);
        return true;
    }
// Solidity 0.4.18
/**
 * @dev Transfer token for a specified address.  Trading limited - requires the TDE to have ended.
 * @param _to The address to transfer to.
 * @param _value The amount to be transferred.
 */
function transfer(address _to, uint256 _value)
        public
        returns (bool)
    {
        if (!isFinalized) return false;
        require(_to != address(0));
        require(_value <= balances[msg.sender]);

        balances[msg.sender] = balances[msg.sender].sub(_value);
        balances[_to] = balances[_to].add(_value);
        Transfer(msg.sender, _to, _value);
        return true;
    }
// Solidity 0.4.25
/**
 * @notice The Synthetix contract informs us when fees are paid.
 */
function feePaid(bytes4 currencyKey, uint amount)
        external
        onlySynthetix
    {
        uint xdrAmount;

        if (currencyKey != "XDR") {
            xdrAmount = synthetix.effectiveValue(currencyKey, amount, "XDR");
        } else {
            xdrAmount = amount;
        }

        // Keep track of in XDRs in our fee pool.
        recentFeePeriods[0].feesToDistribute = recentFeePeriods[0].feesToDistribute.add(xdrAmount);
    }
// Solidity 0.8.7
// generate metadata for stars
function haveStar(uint256 tokenId) private pure returns (string memory) {
    uint256 starSeed = random("star", tokenId);
    string memory traitTypeJson = ', {"trait_type": "Star", "value": "';
    if (starSeed % 47 == 1)
      return string(abi.encodePacked(traitTypeJson, 'Sirius"}'));
    if (starSeed % 11 == 1)
      return string(abi.encodePacked(traitTypeJson, 'Vega"}'));
    return '';
  }
// Solidity 0.8.7
// render stars in SVG
function renderStar(uint256 tokenId) private pure returns (string memory) {
    string memory starFirstPart = '<defs><linearGradient id="star" x1="100%" y1="100%"><stop offset="0%" stop-color="black" stop-opacity=".5"><animate attributeName="stop-color" values="black;black;black;black;gray;';
    string memory starLastPart = ';gray;black;black;black;black" dur="3s" repeatCount="indefinite" /></stop></linearGradient></defs><g style="transform:translate(130px,244px)"><g style="transform:scale(0.1,0.1)"><path fill="url(#star)" d="M189.413,84c-36.913,0-37.328,38.157-37.328,38.157c0-33.181-36.498-38.157-36.498-38.157  c37.328,0,36.498-38.157,36.498-38.157C152.085,84,189.413,84,189.413,84z" /></g></g>';
    uint256 starSeed = random("star", tokenId);
    if (starSeed % 47 == 1)
      return string(abi.encodePacked(starFirstPart, 'aqua', starLastPart));
    if (starSeed % 11 == 1)
      return string(abi.encodePacked(starFirstPart, 'white', starLastPart));
    return '';
  }
// Solidity 0.8.7
// generate metadata for keys
function haveKey(uint256 tokenId) private pure returns (string memory) {
    uint256 keySeed = random("key", tokenId);
    string memory traitTypeJson = ', {"trait_type": "Key", "value": "';
    if (keySeed % 301 == 1)
      return string(abi.encodePacked(traitTypeJson, 'Rainbow Key"}'));
    if (keySeed % 161 == 1)
      return string(abi.encodePacked(traitTypeJson, 'Crystal Key"}')); //afcfff
    if (keySeed % 59 == 1)
      return string(abi.encodePacked(traitTypeJson, 'Gold Key"}')); //ffff33
    if (keySeed % 31 == 1)
      return string(abi.encodePacked(traitTypeJson, 'Silver Key"}')); //dddddd
    if (keySeed % 11 == 1)
      return string(abi.encodePacked(traitTypeJson, 'Jade Key"}')); // 66ff66
    return string(abi.encodePacked(traitTypeJson, 'Copper Key"}')); // 995500
  }
// Solidity 0.8.7
// generate metadata for description
function getDescription(uint256 tokenId) private view returns (string memory) {
    string memory description0 = string(abi.encodePacked('This is a keycard to launch [#', toString(tokenId), ' ', getRoomTheme(tokenId), ' ', getRoomType(tokenId),'](', string(abi.encodePacked(_roomBaseUrl, toString(tokenId))), ') with one click.'));
    string memory description1 = ' And check the linked ';
    uint256 link1Id = getAssetLink1(tokenId);
      if (link1Id > 0) {
        string memory link1description = string(abi.encodePacked('[#', toString(link1Id), ' ', getRoomTheme(link1Id), ' ', getRoomType(link1Id), '](', string(abi.encodePacked(_roomBaseUrl, toString(link1Id))) ,')'));
        uint256 link2Id = getAssetLink2(tokenId);
        if (link2Id > 0) {
          string memory link2description = string(abi.encodePacked('[#', toString(link2Id), ' ', getRoomTheme(link2Id), ' ', getRoomType(link2Id), '](', string(abi.encodePacked(_roomBaseUrl, toString(link2Id))) ,')'));
          if (link2Id > link1Id)
            return string(abi.encodePacked(description0, description1, link1description,' and ',link2description, '.'));
          else
            return string(abi.encodePacked(description0, description1, link2description,' and ',link1description, '.'));
        } else {
          return string(abi.encodePacked(description0, description1, link1description,'.'));
        }
      } else {
        return description0;
      }
    }
// Solidity 0.8.6
/// @notice Returns PoolKey: the ordered tokens with the matched fee levels
/// @param tokenA The first token of a pool, unsorted
/// @param tokenB The second token of a pool, unsorted
/// @param fee The fee level of the pool
/// @return Poolkey The pool details with ordered token0 and token1 assignments
function getPoolKey(
        address tokenA,
        address tokenB,
        uint24 fee
    ) internal pure returns (PoolKey memory) {
        if (tokenA > tokenB) (tokenA, tokenB) = (tokenB, tokenA);
        return PoolKey({token0: tokenA, token1: tokenB, fee: fee});
    }
// Solidity 0.8.6
/// @notice Deterministically computes the pool address given the factory and PoolKey
/// @param factory The Uniswap V3 factory contract address
/// @param key The PoolKey
/// @return pool The contract address of the V3 pool
function computeAddress(address factory, PoolKey memory key) internal pure returns (address pool) {
        require(key.token0 < key.token1);
        pool = address(
            uint160(uint256(
                keccak256(
                    abi.encodePacked(
                        hex'ff',
                        factory,
                        keccak256(abi.encode(key.token0, key.token1, key.fee)),
                        POOL_INIT_CODE_HASH
                    )
                )
            ))
        );
    }