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:

enter image description here

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?

  • 1
    The source array will not be accessible from the native getter when queries from web3. You may have to implement your own getter to retrieve the struct's array elements. See an earlier answer here: ethereum.stackexchange.com/questions/63493/….
    – razgraf
    Commented Jan 10, 2022 at 13:09
  • I was able to work out the problem based on your answer. Writing a getter for the transaction in my contract yielded the expected result. Thank you for saving me further headache and apologies for not searching properly before posting!
    – Leo_95
    Commented Jan 10, 2022 at 13:31

1 Answer 1


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:

function getSources(uint transactionId) external returns (uint[] memory sources) {
      sources = transactions[transactionId].sources; // In case you have array of transactions

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.