smartcontractkit / full-blockchain-solidity-course-js

Learn Blockchain, Solidity, and Full Stack Web3 Development with Javascript
12.4k stars 2.98k forks source link

Lesson 15: Issue with getting TokenURIs #5748

Open eugenekhoo1 opened 1 year ago

eugenekhoo1 commented 1 year ago

Hi, I am having issues getting the Token URIs using the useWeb3Contract function in NFTBox..as you can see my NFT boxes are not loading due to it being undefined.

Screenshot 2023-06-26 at 4 38 18 PM Screenshot 2023-06-26 at 4 38 32 PM

The issue seems to be with the follow code, but i cant seem to debug it:

const { runContractFunction: getTokenURI } = useWeb3Contract({
    abi: nftAbi,
    contractAddress: nftAddress,
    functionName: "tokenURI",
    params: {
      tokenId: tokenId,
    },
  });

I have checked my subgraph and it does show the correct nftAddress that the getTokenURI function uses as one of it params

Screenshot 2023-06-26 at 4 41 37 PM

I am also able to get the ActiveItems that the 'listings.js' code is calling.

Screenshot 2023-06-26 at 4 44 04 PM

Tried to troubleshoot, but seems like all the params for the useWeb3Contract are in order...so im not too sure what the issue is with loading..

Repos: NextJS code https://github.com/eugenekhoo1/nextjs-nft-marketplace

NFT Contracts https://github.com/eugenekhoo1/hardhat-nft-marketplace

Graph https://github.com/eugenekhoo1/graph-nft-marketplace