Solidity: How can I return a list of user-defined function?

0 votes

I want to return a list of user-defined struct

function sortByEtherValues (string category) public view returns (JobStruct[]) {
...
}

I am getting the following error:

Failed to decode output: Error: Unsupported or invalid type: tuple
Sep 26, 2018 in Blockchain by slayer
• 29,050 points

retagged Nov 22, 2018 by Priyaj 50 views

1 answer to this question.

0 votes

You can do it with something like this:

struct JobStruct {
  uint a;
  uint b;
  uint c;
}

function sortByEtherValues (string category) public view returns (uint, uint, uint) {
  JobStruct memory js = JobStruct(1, 2, 3);
  return (js.a, js.b, js.c);
}
answered Sep 26, 2018 by digger
• 27,630 points

Related Questions In Blockchain

+1 vote
2 answers
0 votes
1 answer

How can I get the same return value as solidity `abi.encodePacked` in Golang?

This is what I used:  package main import ( ...READ MORE

answered Sep 26, 2018 in Blockchain by slayer
• 29,050 points
379 views
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
126 views
0 votes
1 answer
0 votes
1 answer

Solidity geth: Error encountered during contract execution [Bad instruction]

recipes is a dynamic storage array. You need ...READ MORE

answered Oct 15, 2018 in Blockchain by Omkar
• 67,290 points
66 views
0 votes
1 answer

How do I compile a piece of Solidity Code using eris' javascript?

The easiest way to compile Solidity is ...READ MORE

answered Sep 27, 2018 in Blockchain by digger
• 27,630 points
31 views
0 votes
1 answer

How to return data on execution of invoke function?

You can do this using a response ...READ MORE

answered Jul 23, 2018 in Blockchain by digger
• 27,630 points
31 views