I have a smart contract with a custom token which holds some data. The Token data is defined in a struct and stored in an array:
struct Token {
string text;
uint256 value;
}
Token[] public _token;
On my web page I want to display all the tokens of the current user. Therefore I have a function in my smart contract which fetches all tokenId
s of the given address. That function is really quick, but when I want to retrieve all Tokens from the Token[]
array with the ids I get from the previous function it lasts very long! Especially if the user has many tokens...
To fetch all the tokens of the user I iterate over all tokenId
s and perform the following request:
const token= await this.tokenContract.methods._token(tokenId).call();
Does anybody has an idea how to speed up the retrieval?