I have a following struct,

struct Funds {
uint amount;
address sender;
uint time;
Funds[] public fundArray;

function StructsDemo() public{
    fundArray.push(Funds(100,0xca35b7d915458ef540ade6068dfe2f44e8fa733c, 12345678910));
    fundArray.push(Funds(200,0xca35b7d915458ef540ade6068dfe2f44e8fa733c, 12345678910));
function getArray() public view returns(Funds[] array){
    return fundArray;

When I run getArray() function, it returns me following error: error: Failed to decode output: Error: Unsupported or invalid type: tuple

I'm intending to print whole of the array, any suggestions will be appreciated. Thanks


Take a look at the solidity frequently asked questions for v0.4.23:

Can you return an array or a string from a solidity function call?


Yes. See array_receiver_and_returner.sol.

What is problematic, though, is returning any variably-sized data (e.g. a variably-sized array like uint[]) from a fuction called from within Solidity. This is a limitation of the EVM and will be solved with the next protocol update.

Returning variably-sized data as part of an external transaction or call is fine.

I have made bold the relevant statement. It seems for your purposes, you will need to use a static array with a defined size.

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.