[SOLVED] NFT API for Polygon Testnet

Hi,
I am using the morlais api for to fetch nft deatils by contract. So I am using that for Mumbai testnet and Polygon mainnet.
Now that Mumbai testnet is going to deprecated, I have switched to the Amoy testnet.
I need a api similarly to fetch nft details by contract for amoy testnet. Is it available on moralis?

Hi @isha289

We have recently released the Amoy chain. You can test it on the below swagger docs.

https://deep-index.moralis.io/api-docs-2.2/

Please test it and let us know if everything is good

Thanks a ton @johnversus.
I’ll sure get back if anything comes up!

Hi @johnversus I am trying to fetch the NFT’s from te amoy network how do I make change sin the code for the same?

Below code is how I am using the moralis api for mumbai testnet.

router.get('/nft/viewNFT', async (req, res) => {
    const tokenId = req.query.token_id;

    try {
        const chain = EvmChain.MUMBAI;
        // const address = '0x4B61FB7b4a09ccED53aE1BAAebBDF4B612b5a97d';
        const address = '0x5807733e211Ee2650D10ED9842808fcf8Aa6835e';

        const response = await Moralis.EvmApi.nft.getNFTTransfers({
            address,
            chain,
            tokenId,
        });


        return req.app.responseHelper.send(res, true, response, [], 200);

    } catch (e) {
        console.error("Error while getting NFT history: ", e);
    }
});

Is there any document you can share for the same?

Hi @isha289

You will only have to update the chain value to use it with Amoy chain. Currently, you update like below with the chainId. We are working on updating the SDK with correct chain name. When it is ready you can use EvmChain.AMOY

const chain = "0x13882"; 

Great thanks @johnversus!

Hi @johnversus,
I am trying to use the api to get NFT by contract address.
But I am not getting any response in details. I also tried for nft by wallet address still no response.
So I tried to get all transaction I am getting response.
This is NFT by wallet

And this transactions by wallet address

Amoy is relatively new so I can see my mint transaction with the help of the methodID

Any idea what might be the issue here?

hello
what type of event was for that mint?
It doesn’t look like there is a transfer event there specific to a mint

Hi,
No there’s not.
Mint is only minting. I hav few different functions like minting, transfer, putonsale and buy.
You can check the contract here. Same is deployed on amoy here
And this is for my wallet address where if you check the events logs by that I can say the mint function was called.https://www.oklink.com/amoy/address/0xa10e79dd80c5c08dd8744e634897695e602dc653
But with the get NFT by wallet just the minted nfts wont be in the response?

it looks like this transaction failed

https://www.oklink.com/amoy/tx/0x3ac24312e8aee7860f8d084628e881e316fb12ec083bba5e496c035db007e1eb

That is just amtic transfer txn. You can check by my wallet address in event log method calling: 0x595c685d is the minting transaction

can you paste that transaction hash?

Sure,
0x8596fa1dca7eb56af6b0b6859d2e3ecdd1f3e100ca4ee34c6de4710ca94db538
https://www.oklink.com/amoy/tx/0x8596fa1dca7eb56af6b0b6859d2e3ecdd1f3e100ca4ee34c6de4710ca94db538/log

on Amoy you have to interact with this contract

https://www.oklink.com/amoy/address/0x73212c4760c61fbcd57b6adbc0fc5c9dfe54ef9d

not with the contract address from polygon, the transactions that you make now on Amoy to that contract address on polygon don’t do anything because there is no contract address with that address on Amoy.

But the method id remains the same right?
So far I am not able to figure out how to know which transaction is for minting. The method calling id is my only indication.
But thanks for the help…I’ll try to mint and interact with the contract again and let you know.

yes, the method should be the same, and the contract address was not the right one for Amoy chain.

Okay okay thanks…I’ll try again and let you know!

1 Like

Hey @cryptokid thanks a lot for the help,
It was completely my mistake. The previous contract address as somewhere stored in the env files and metamask was interacting with that contract itself it wasn’t even interacting with my Amoy deployed contract.

1 Like