How I do I push the first value to this:

  struct Balance {
    address owner;
    uint amount;
    DeepBalance[] deepBalance;


  struct DeepBalance{
    address swap ;
    uint amount ;
Balance[] balances;

this doesn't work, but is what I feel in the bottom of my heart is close:

DeepBalance[] memory deepBalance;
  owner: 0,
  amount: 0,
  deepBalance: DeepBalance({
      swap: 0,
      amount: 0

1 Answer 1


As far as I know, it's currently not possible to achieve what you want to do.

As @toothleth_byte proposed in his comment, you could look at this answer but it will only work with mappings, not arrays.

What you could do is to use a mapping and also store the unique ids of the mapping elements in an array if you want the ability to loop through the elements.

  • Thanks for the answer, I ended up doing just that, but it is a little disappointing having to waste more gas for little quirks like this
    – thefett
    Dec 11, 2017 at 13:32

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.