Seems like there are many related questions ex: here, but I still can't believe it is not supported in remix or am I misunderstanding it? seems like it is supported in production.

struct Test {
    address receiver;
    string date;

mapping(address => Test[]) public testInfo;

function getTestInfo(address _account) public constant returns (Test[]) {
    return testInfo[_account];

Is there anyway to execute that code and return an array of Test?


It will run however the output won't be decoded. You will see this message in the console:

failed to decode output: Error: Unsupported or invalid type: tuple

I was going to suggest destructuring and returning two arrays however there is a string in the struct, which is also cannot be returned since string is an array itself. You named it date so maybe it can be held in an uint field or maybe in a bytes32 field? If that's the case than you can do:

function getTestInfo(address _account) public constant returns (address[], bytes32[]) {

I.e., return struct fields in separate arrays and restructure them in your front-end.

  • ok so seems like it can be decoded in production environment? and not so sure what you meant by return struct fields in separate arrays. The size is dynamic. – bbusdriver Feb 1 '18 at 0:39
  • What are you referring to by 'production environment'? What I mean by destructing is suppose you want to return 10 Tests. You return 10 addresses and 10 bytes32s, let's call them receivers and dates. Each element in those arrays are set to the respective fields of the Test in the original array, e.g. receivers[0] == Tests[0].receiver and dates[0] == Tests[0].date. You can build a Tests array from this structure in the front-end. – lunr Feb 1 '18 at 0:49
  • Thanks. I just tried with your way and it worked. But I used bytes32 for dates ex: 2018-01-31 and what it returns is the address 0x323031382d30312d323800000000000000000000000000000000000000000000 What can be fixed? – bbusdriver Feb 1 '18 at 1:58
  • That's not an address, it's the hex representation of the string '2018-01-31', you can search for ways of converting it. If the formatting doesn't have to preserved, I suggest you use uints for dates. – lunr Feb 1 '18 at 2:18
  • Thank you very much. Hopefully I don't need to go through couple of more steps in the future. – bbusdriver Feb 1 '18 at 3:15

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.