Ethereum Asked by Mindful on December 5, 2021
I have similar functions like this and they work fine:
function getBarsOfParticipant() external view returns (uint256[], uint16[], bool[]) {
uint256[] barIds = participantToBarIds[msg.sender];
uint256[] memory ids = new uint256[](barIds.length);
uint16[] memory lengths = new uint16[](barIds.length);
bool[] memory forSale = new bool[](barIds.length);
for (uint16 i = 0; i <= barIds.length; i++) {
Bar storage bar = bars[barIds[i]];
ids[i] = barIds[i];
lengths[i] = bar.length;
forSale[i] = bar.forSale;
}
return (ids, lengths, forSale);
}
Although the above code compiles, I always get this error at the front-end:
Any suggestions?
I think that you cannot return the tuple of array like this (uint256[], uint16[], bool[])
Just return an index of each element lile (uint256, uint16, bool)
; so you need to return length of the array and iterate in the dapp to get all the data.
Answered by Ha ĐANG on December 5, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP