0

I want to retrieve metadataURI, but I got this error

cannot estimate gas; transaction may fail or may require manual gas limit (error={"reason":"processing response error","code":"SERVER_ERROR","body":"{\"jsonrpc\":\"2.0\",\"id\":61,\"error\":{\"code\":-32000,\"message\":\"execution reverted\"}}","error":{"code":-32000},"requestBody":"{\"method\":\"eth_call\",\"params\":[{\"to\":\"0x5fbdb2315678afecb367f032d93f642f64180aa3\",\"data\":\"0xc87b56dd0000000000000000000000000000000000000000000000000000000000000001\"},\"latest\"],\"id\":61,\"jsonrpc\":\"2.0\"}","requestMethod":"POST","url":"https://rpc-mumbai.maticvigil.com"}, method="call", transaction={"to":"0x5FbDB2315678afecb367f032d93F642f64180aa3","data":"0xc87b56dd0000000000000000000000000000000000000000000000000000000000000001","accessList":null}, code=UNPREDICTABLE_GAS_LIMIT, version=providers/5.2.0)

Code

async function getNFT({contract, provider, tokenId}) {
  console.log(tokenId)
  console.log(contract)
  const metadataURI = await contract.tokenURI(tokenId);
  // const metadata = await fetchIPFSJSON(metadataURI);
  // console.log('metadata: ', metadata)

  // if (metadata.image) {
  //   metadata.image = makeGatewayURL(metadata.image);
  // }

  // return metadata;
}

Here my console log

enter image description here

2
  • Did you try contract.tokenURI(tokenId).call() Commented Dec 26, 2022 at 10:15
  • can you show tokenURI() function ?
    – noro meb
    Commented Dec 26, 2022 at 10:18

2 Answers 2

1

tokenURI() does not require to spend gas since its a view function;

The EVM is returning an error message "Execution reverted" which means that you're actually calling the contract correctly but there is something wrong with the logic; This narrows down the problem to the tokenURI() function

PLease add the tokenURI code to your question to keep troubleshooting

0

Most probably the token is still not minted. Cross verify it once and also that your rpc-network is correct.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.