I am trying to fetch the metadata of a erc721 token by calling the tokenURI function. This is being done using cloud functions:
const web3 = Moralis.web3ByChain(“0x13881”); // Polygon mumbai
const abi = Moralis.abis.erc721;
// create contract instance
const contract = new web3.eth.Contract(abi, contractAddress);
// get contract name
//const name = await contract.methods.name().call()
let uri = await contract.methods.tokenURI(tokenId).call();
When looking at the logs, I receive this error:
Failed running cloud function HandleTransfer for user undefined with:
Input: {“contractAddress”:“0x06e65c70b752b996e3dc0c66c8424e14b52b8266”,“from”:“0x0000000000000000000000000000000000000000”,“tokenId”:“36”}
Error: {“message”:“Cannot read properties of undefined (reading ‘erc721’)”,“code”:141}
As you can see the contract address and tokenId seem to be correct. I was previously able to call this the other day with no issue. Im wondering if it is a abi issue.
Would appreciate some help.