alchemy-sdk-js icon indicating copy to clipboard operation
alchemy-sdk-js copied to clipboard

The nft endpoint is returning a token URI error even though the token URI is valid

Open outdoteth opened this issue 2 years ago • 8 comments

On the goerli testnet, the nft endpoint is returning a token URI error even though the token URI is valid:

const { pageKey, ownedNfts } = await alchemy.nft.getNftsForOwner(
  "0xE70989f0A6b50E3c8Ef6Df57e994E99AA79EbD27",
  { contractAddresses: [""0xe47463a0b8fd39286d7a72ca8e334795779e2f77""], }
);

Results in the following error:

"Contract returned a broken token uri, do not retry"

Screenshot 2022-11-02 at 12 20 16

But the token URI is correct and valid so why is it giving me this error?

See correct data returned from the token URI: https://wrappedpunks.com:3000/api/punks/metadata/1

outdoteth avatar Nov 02 '22 12:11 outdoteth

I'm experiencing the same thing, I also sometimes get: error: "IPFS gateway timed out" specially right after minting an NFT and fetching right after, even though polyscan shows the transaction to be successful. I'm working on Mumbai testnet. I've also tried with axios directly to the endpoint https://polygon-mumbai.g.alchemy.com/nft/v2/ and get the same result.

franzrecinos avatar Nov 02 '22 18:11 franzrecinos

@outdoteth Can you try calling alchemy.nft.refreshContract()on the contracts with timed out gateways or parsing errors to try and refetch the metadata again? We try to ingest contracts regularly, but sometimes the ingestion can miss a contract if the gateways uri is down.

thebrianchen avatar Nov 02 '22 22:11 thebrianchen

@thebrianchen That results in an error saying that only eth mainnet is supported (im on goerli)

Screenshot 2022-11-02 at 23 09 38

outdoteth avatar Nov 02 '22 23:11 outdoteth

If you have the token id, could you try refreshNftMetadata()?

thebrianchen avatar Nov 02 '22 23:11 thebrianchen

I'm experiencing the same thing, I also sometimes get: error: "IPFS gateway timed out" specially right after minting an NFT and fetching right after, even though polyscan shows the transaction to be successful. I'm working on Mumbai testnet. I've also tried with axios directly to the endpoint https://polygon-mumbai.g.alchemy.com/nft/v2/ and get the same result.

Also experiencing this on trying to get all NFTs from an erc1155 contract. We use a locally run ipfs node and on the contract the uri is as follows: ipfs://[insert hash]. Sometimes I get all the tokens, sometimes a few and sometimes none. It differs per request.

LALauw avatar Nov 03 '22 23:11 LALauw

Hi @outdoteth the NFT you reported above has a token uri with SSL certificate problems, so we can't retrieve the metadata at the uri https://wrappedpunks.com:3000/api/punks/metadata/1 SSL certificate problem: unable to get local issuer certificate)

niveda-krish avatar Nov 11 '22 07:11 niveda-krish

@franzrecinos @LALauw the IPFS gateway time out error is expected to happen for new mints because IPFS is a decentralized file storage solution which has some initial latency by design. Only a very tiny fraction of nfts are affected by ipfs gateway timeouts according to our metrics. Should be resolvable by retries and using refreshNftMetadata.

niveda-krish avatar Nov 11 '22 07:11 niveda-krish

the NFT you reported above has a token uri with SSL certificate problems

@niveda-krish The cert seems to be fine for me. Maybe I am misreading this though.

Screenshot 2022-11-14 at 13 41 21 Screenshot 2022-11-14 at 13 42 18

outdoteth avatar Nov 14 '22 13:11 outdoteth

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs

github-actions[bot] avatar Dec 15 '22 02:12 github-actions[bot]