getNFTs does not return NFT tokens for a ERC721 token

Hello,

I have deployed a ERC721 token on ganache, and this is not returned by Moralis.
Metamask however, shows me the correct balance of NFT tokens.

const testnetNFTs = await Moralis.Web3.getNFTs({ chain: "0x539" });
console.log("geri testnetNFTs", testnetNFTs);

Output is:

geri testnetNFTs []

The strange thing is that I get the correct list of transactions: const transactions = await Moralis.Web3.getTransactions(options);

Am I missing something?
Is there something additional that I need to set up?

Thanks,
Gerald

Hi what is the server URL?

It is: https://elu9bwzc8ou7.moralis.io:2053/server

thanks forwarded to the team, we will check if its a bug or something in your config

Thank Ivan.

Also, this is probably related, I am not able to query for ERC721 token transfer either. It works only for ERC20:

      const EthTokenTransfers = Moralis.Object.extend("EthTokenTransfers");
      const queryReceiver = new Moralis.Query(EthTokenTransfers)
        .equalTo("token_address", tokenAddress)
        .equalTo("to_address", currentAddressLower);

ERC721 Token address: 0xAd8bA91D78E80B569a19cE3d0fcdC7135D498Af0

Thanks,
Gerald

Hi nutrina,

Glad to see you active on the forums! I tested this just now but am not able to replicate the error. It seems to work fine for me. I created an ERC721 token called “High Roller” for the Coin Flip casino demo.

// SPDX-License-Identifier: MIT
pragma solidity ^0.7.5;

import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

contract HighRoller is ERC721, Ownable {
    constructor() public ERC721("High Roller", "HIRL") {
      _setBaseURI("https://ipfs.moralis.io:2053/ipfs/");
    }

    function mint(address to, uint256 tokenId) public onlyOwner {
      _mint(to, tokenId);
    }
}

migration file

const HighRoller = artifacts.require("HighRoller");

module.exports = async function(deployer, network, accounts) {
  await deployer.deploy(HighRoller);
  const instance = await HighRoller.deployed();
  await instance.mint(accounts[0], 1);
  await instance.mint(accounts[0], 2);
};

I’m used ganache-cli with the deterministic flag and a seed phrase. When I attempted to upgrade my ganache Moralis server instance to the latest version it got stuck spinning, so I created a fresh new server and tested with that.

  • Perhaps try updating the the latest version of Moralis
  • Does your ERC721 contract implement the metadata interface? That shouldn’t cause the function to fail though.

Hello,

Thanks for your reply.
I got it working now.
I have updated the moralis and react-moralis lib in the UI, fired up a new server (new version) on Moralis, and now it works.
Apparently the getNFTs method was not available on my old server, I saw the error message only with the new moralis lib I have installed.

Thanks,
Gerald