I have the following struct in my contract
struct Transaction {
TransactionType transactionType;
uint256 id;
uint256 productId;
uint256 timestamp;
address from;
address to;
uint256[] source;
uint256 test;
}
which I then initialize like this
uint256[] memory source = new uint256[](1);
source[0] = 55;
Transaction memory transaction = Transaction(*other params*, source, 999);
In a test where I let above code run and examine the transaction in the debugger it looks like the following:
The object is supposed to contain 8 elements, but only 7 are shown.
Following the address fields at indices 4/5 is the uint field test.
What happened to the array field source?
Best Answer
Reference types (arrays, mappings, struct) that are part of the structure are not being returned when you try to return structure data. You can notice that only value types are returned.
You should create a function that would act as a getter that will access the data you need and return it back.
For your example: