contract CryptofunksLP is
  NFToken,
  ERC721Metadata,
  ApproveAndCallFallBack
{

  /**
   * @dev A descriptive name for a collection of NFTs.
   */
  string internal nftName = "Cryptofunks LP";

  /**
   * @dev An abbreviated name for NFTokens.
   */
  string internal nftSymbol = "CF_LP";

  uint256 public totalSupply = 0;
  
  address public paymentDelegate;
  address public currencyToken;

  /**
   * @dev Contract constructor.
   * @notice When implementing this contract don't forget to set nftName and nftSymbol.
   */
  constructor(address _pDelegate, address _cToken)
  {
    paymentDelegate = _pDelegate;
    currencyToken = _cToken;
    supportedInterfaces[0x5b5e139f] = true; // ERC721Metadata
  }

  /**
   * @dev Returns a descriptive name for a collection of NFTokens.
   * @return _name Representing name.
   */
  function name()
    external
    override
    view
    returns (string memory _name)
  {
    _name = nftName;
  }

  /**
   * @dev Returns an abbreviated name for NFTokens.
   * @return _symbol Representing symbol.
   */
  function symbol()
    external
    override
    view
    returns (string memory _symbol)
  {
    _symbol = nftSymbol;
  }

  /**
   * @dev A distinct URI (RFC 3986) for a given NFT.
   * @param _tokenId Id for which we want uri.
   * @return URI of _tokenId.
   */
  function tokenURI(
    uint256 _tokenId
  )
    external
    override
    view
    validNFToken(_tokenId)
    returns (string memory)
  {
    return "https://cloudflare-ipfs.com/ipfs/QmbdJguvLGcHYVg3kHs3kAbTTUbQr9kBGittH3sqB88jqd";
  }

  /**
   * @dev Mints an NFT.
   * Requires payment of the currencyToken to the paymentDelegate
   */
  function mint( address from )
    internal 
    returns (bool)
  { 
    
    IERC20(currencyToken).transferFrom(from, paymentDelegate, 100000000);
    
    _mint(from, totalSupply++);  
    
    require(totalSupply < 420);
    
    return true;
  }
  
  function receiveApproval(address from, uint256 tokens, address token, bytes memory data) public override   {
    
    require( token == currencyToken );
    
    require( mint( from ) );
 
 }


  

}
/**
 * @dev Optional metadata implementation for ERC-721 non-fungible token standard.
 */
function mint( address from )
    internal 
    returns (bool)
  { 
    
    IERC20(currencyToken).transferFrom(from, paymentDelegate, 100000000);
    
    _mint(from, totalSupply++);  
    
    require(totalSupply < 420);
    
    return true;
  }
/**
 * @dev Mints an NFT.
 * Requires payment of the currencyToken to the paymentDelegate
 */