I've been doing some research around this issue, but I couldn't find a definite answer. I'm using solidity 0.4.24.
I have a contract like this:
contract {
struct FutureOperation is Ownable {
uint256 date;
uint256 price;
uint256 amount;
string name;
}
FutureOperation[] futureOperations;
// ...
function getAllFutureOperations() public onlyOwner returns (FutureOperation[]) {
return futureOperations;
}
}
When I compile this in Remix I get the following error:
browser/myfuturetoken.sol:53:64: TypeError: This type is only supported in the new experimental ABI encoder. Use "pragma experimental ABIEncoderV2;" to enable the feature.
I found some blog posts saying that I should de-structure the fields in the struct to return them as arrays of the primitive types. So, in this case, it would look something like this:
function getAllFutureOperations() public onlyOwner returns (uint256[] dates, uint256[] prices, uint256[] amounts, string[] names) {
return futureOperations;
}
Is there an alternative for that? Are the newer compilers capable of returning an array of structs?
Thanks.