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:

enter image description here

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.

  • Pretty sure you can return multiple arrays. No idea what's wrong however.
    – Maxpeinas
    Aug 20 '18 at 9:23
  • oh, you're right! But it seems very pain for front-end medium.com/coinmonks/…
    – Ha ĐANG
    Aug 20 '18 at 9:29

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.