[SOLVED] Rarity Ranking NFT on Polygon

I’m working on the Rarity Ranking tutorial, and I noticed the default chain is eth, but my collection is on Polygon.

Ran cloud function getAllTokenIds for user undefined with:
Input: {“address”:“0x51790d397e3cC5F418635796e75C8B58EA113f3D”,“chain”:“eth”}
Result: {“total”:0,“page”:0,“page_size”:500,“cursor”:"",“result”:[]}

I’ve searched the repo in VSCode and couldn’t figure out where I might be able to set the chain to Polygon.

I’m not a programmer, so I am struggling with basic concepts. I have no idea how to work with Cloud Functions, which was a suggested solution.

I think the Rarity Generator would work as intended for me, if I could understand how to make this modification.

TYVM

Sure,

Let me help you out.

You can find all the API end points here:

You can see the chains here -

1 Like

I don’t understand how this will change the Input being sent when I use “node main.js”. If you could help me understand I would be very grateful . . .

Can u share the Github path where u are referring to the code?

Shockingly, I managed to make it work on Polygon. It was purely guesswork, feel free to correct me, as I am not a coder by any stretch. I changed 3 things in main.js, adding the chain ID part.

const collectionAddress = "0x51790d397e3cC5F418635796e75C8B58EA113f3D"; //Collection Address Here
const collectionName = "FOMOsapiens"; //CollectioonName Here
const chainId = "polygon"
async function generateRarity() {
  const NFTs = await Moralis.Web3API.token.getAllTokenIds({
    address: collectionAddress,
    chain: chainId
  });
  for (let i = pageSize; i < totalNum; i = i + pageSize) {
    const NFTs = await Moralis.Web3API.token.getAllTokenIds({
      address: collectionAddress,
      chain: chainId,
      offset: i,
    });

This stopped it from defaulting to eth, and directed it to polygon. Bingo.

Thanks for the help, Malik. :slight_smile:

2 Likes