getAllTokenIds() returning empty array

Hello!

Iā€™m currently following the ā€˜Ultimate NFT Programming Tutorialā€™ and am expecting to see an array with two tokens being returned after following the same steps as Filip in the screen below.

However, I instead keep receiving an empty array.

Below shows my js code so far.

//moralis server url and app id
serverUrl = "https://uwoe5mpexkhs.usemoralis.com:2053/server";
appId =  "t7Z50PTGvKoAajkdGxM6zaITb8sLOja7upbqQ1G6";
Moralis.start({ serverUrl, appId});

//check if the user is currently signed in
async function initializeApp() {
    let currentUser = Moralis.User.current();
    if(!currentUser) {
        //Sign in
        //authenticating using metamask
        currentUser = await Moralis.Web3.authenticate();
    }
    //insert contract address below
    const options = { address: "0x5064e8b7db2feca5d340f307e0bd169dd934bea9", chain: "rinkeby" };
    const NFTs = await Moralis.Web3API.token.getAllTokenIds(options);

    
    console.log(NFTs);
}

initializeApp();

I canā€™t figure out what I am doing wrong, any help would be appreciated!

Thanks.

1 Like

what are the transaction hashes on etherscan that added those NFTs for that address?

Hi, hereā€™s the transaction hash: 0xa81defb2409a0874d04162ced7fa106e7e6487638863c2be76d7c8947b1e9693 .

it looks like Moralis has some delay in indexing new smart contracts,
I used now:

x = await Moralis.Web3API.token.getTokenIdMetadata({address:ā€œ0x5064e8b7db2feca5d340f307e0bd169dd934bea9ā€, token_id: ā€œ1ā€, chain: ā€œrinkebyā€})

and it looks that it is not yet indexed.

usually this indexing should not take more than few minutes after calling Moralis.Web3API.token.getTokenIdMetadata, but now it looks like Moralis has a bigger delay on indexing new smart contracts.

you can check again in few hours or tomorrow.
it doesnā€™t look like it is a problem on your side now

Yeah unfortunately Iā€™ve been waiting and trying to solve this issue for 3 days now.

Would you happen to have any idea how long I might have to continue waiting ?

Iā€™d really like to progress with the tutorial but canā€™t really do much further at this point.

Hopefully today it will be fixed.

Hello friend! I am having the same problem. 99% of the time will return empty or I get another userā€™s nftā€™s returned at random, never the same set of nftā€™s returned twice.

// main.js
// appId, serverUrl stored in env

Moralis.start({ serverUrl, appId })

function fetchNFTMetadata(NFTs) {
    for (let i = 0; i < NFTs.length; i++) {
        let nft = NFTs[i]
        let id = nft.token_id
        // Call Moralis Cloud function -> Static JSON file
        fetch("https://rzpubn0vaohn.usemoralis.com:2053/functions/getNFT?_ApplicationId=WZrCeQWqZevFk1grxGzkrgB8t0kF9nzoUSFQZH8y&nftId=" + id )
        .then(res => console.log(res))
    }
}

async function initializeApp()  {
    let currentUser = Moralis.User.current();
    if (!currentUser)  {
        currentUser = await Moralis.Web3.authenticate();
    }

    const options = { address: "0x623dff8099013e9a8e4624874ac374faa3ea400f" , chain: "rinkeby", };

    const NFTs = await Moralis.Web3API.token.getAllTokenIds(options);
    console.log('NFTS', NFTs);

    fetchNFTMetadata(NFTs);
}

initializeApp();
// index.html
<!DOCTYPE html>
<html>
  <head>
    <title>Vanilla Boilerplate</title>
    <script src="https://cdn.jsdelivr.net/npm/web3@latest/dist/web3.min.js"></script>
    <script src="https://unpkg.com/moralis/dist/moralis.js"></script>
  </head>

  <body>
    <h1>Moralis Hello World!</h1>

    <button id="btn-login">Moralis Metamask Login</button>
    <button id="btn-logout">Logout</button>

    <script type="text/javascript" src="./main.js"></script>
  </body>
</html>
3 Likes

I was able to replicate this issue with random nfts, we are going to investigate it

1 Like

that problem with random nfts should be fixed now

1 Like

Yesterday I was seeing the same issuesā€¦ empty array or returning seemingly random NFTs from other projects.

Glad to hear the ā€œrandomā€ results issue is fixed. Is there an estimated date for when the long delay will be fixed for the indexing issue? Iā€™m working on a project for the ChainLink hackathon and might have to pivot to a different solution.

We expect to fix it soon, maybe in 1 day if everything works as expected.

4 Likes

Same issue here, the NFT data shows in the server dashboard but getting an empty array from numerous NFT functions when using the Javascript SDK. Deployed the smart contract yesterday but only created the Moralis server today, running on the Rinkeby testnet. Looking forward to a fix, thank you Moralis team :slight_smile:

we hope that the fix will be soon, now it is a backlog of smart contracts that have to be processed

1 Like

I have been experiencing a similar problem. Ropsten testnet seams to be working just fine, however the rinkeby testnet is still returning an empty array. It also looks like the EthNFTOwners table is populated, but the function returns an empty array :slight_smile: