1

I have deployed a basic ERC721 token with some image metadata. I want to build a dashboard to view all the tokens and looking for an effective way of doing it.
One approach I have tried is:

Loop through all the tokens given the number of tokens deployed and make a request for each tokenURI as shown below:

var numTokens = 10
var datas = []

for (let i = 0; i < numTokens; i++) {
  let data = await contract.methods.tokenURI(i);
  datas.push(data);
}

Here, for 10 tokens 10 requests will be made and 100 requests for 100 tokens which seems very ineffective. What would be an effective way to list all tokens in the dashboard?

1

Check the MakerDao Multicall.js a library that allows multiple calls to smart contracts with a single JSON-RPC request.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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