Best Way to, let other people mint more NFTs if they have another collection

Hello, I'm new here, I'm new with solidity, need some help from the pros

Right now I'm trying to write a smart contract for an NFT collection, the thing is that i limited the mint to 1 per wallet, but i want to add a function that if you have another NFT from a specific collection, you can mint more than one, like a Perk for other people that sported on the last collection.

I really don't know if it's possible.

Thank you :slight_smile:

All you have to do is import the nft interface then call the balanceOf function of the external nft contract with the user address.

β€˜IERC721(nft address).balanceOf(msg.sender)’

And check the return value, however remember that you are making an external call, so beware and protect yourself from reentracy issues.

1 Like

Oh ok, so its just a call inside the contract.

pragma solidity >=0.7.0 <0.9.0;

contract TheNFTCol is ERC721Enumerable, Ownable {
  using Strings for uint256;

  string baseURI;
  string public baseExtension = ".json";
  uint256 public cost = 0.00 ether;
  uint256 public maxSupply = 6187;
  uint256 public maxMintAmount = 1;
  bool public paused = true;
  bool public revealed = false;
  string public notRevealedUri;

    string memory _name,
    string memory _symbol,
    string memory _initBaseURI,
    string memory _initNotRevealedUri
  ) ERC721(_name, _symbol) {

  // internal
  function _baseURI() internal view virtual override returns (string memory) {
    return baseURI;

  // public
  function mint(uint256 _mintAmount) public payable {
    uint256 supply = totalSupply();
    require(_mintAmount > 0);
    require(_mintAmount <= maxMintAmount);
    require(supply + _mintAmount <= maxSupply);
    require(balanceOf(msg.sender) == 0, "Max Mint per wallet reached");

    if (msg.sender != owner()) {
      require(msg.value >= cost * _mintAmount);

    for (uint256 i = 1; i <= _mintAmount; i++) {
      _safeMint(msg.sender, supply + i);

  function walletOfOwner(address _owner)
    returns (uint256[] memory)
    uint256 ownerTokenCount = balanceOf(_owner);
    uint256[] memory tokenIds = new uint256[](ownerTokenCount);
    for (uint256 i; i < ownerTokenCount; i++) {
      tokenIds[i] = tokenOfOwnerByIndex(_owner, i);
    return tokenIds;

  function tokenURI(uint256 tokenId)
    returns (string memory)
      "ERC721Metadata: URI query for nonexistent token"
    if(revealed == false) {
        return notRevealedUri;

    string memory currentBaseURI = _baseURI();
    return bytes(currentBaseURI).length > 0
        ? string(abi.encodePacked(currentBaseURI, tokenId.toString(), baseExtension))
        : "";

  //only owner
  function reveal() public onlyOwner {
      revealed = true;
  function setCost(uint256 _newCost) public onlyOwner {
    cost = _newCost;

  function setmaxMintAmount(uint256 _newmaxMintAmount) public onlyOwner {
    maxMintAmount = _newmaxMintAmount;
  function setNotRevealedURI(string memory _notRevealedURI) public onlyOwner {
    notRevealedUri = _notRevealedURI;

  function setBaseURI(string memory _newBaseURI) public onlyOwner {
    baseURI = _newBaseURI;

  function setBaseExtension(string memory _newBaseExtension) public onlyOwner {
    baseExtension = _newBaseExtension;

  function pause(bool _state) public onlyOwner {
    paused = _state;
  function withdraw() public payable onlyOwner {

    (bool os, ) = payable(owner()).call{value: address(this).balance}("");

where in the contract do you insert that call