I need to create a struc to store the funds, the asdress who send the funds and date/time, It’ll store these three values for all transactions when some one sends ethers to a contract. So I came up with the thought of using structs and create an array to populate that. Can some one help me out how to create struct with above mentioned three properties, and populate an array (who’s size should be dynamic obviously).

It’s urgent to do in an hour, so any suggestions will be appreciated. Please come up with any other suggestions (if u find some other idea more suitable for my work).


1 Answer 1


Given a struct like this:

struct Funds {
    uint amount;
    address sender;
    uint time;

You can create an array of structs like this:

Funds[] fundArray;
fundArray.push(Funds(<amount>, <address>, <time>))
  • Specifying the length of array isn’t necessary? Apr 26, 2018 at 18:50
  • Can u give a code snippet to populate this array properties? Apr 26, 2018 at 18:51
  • Depends on if you want a dynamic or static array. Check out documentation here. Not specifying the array length makes it dynamic. Push statement has been added. Apr 26, 2018 at 18:51
  • Can I print whole array from a function? Can I see that code snippet? Thanks already :) Apr 26, 2018 at 19:25
  • That is a different question you should be asking in a different post. If my answer satisfied your original question, you can mark it as such, and ask your new question in a new thread. Apr 26, 2018 at 19:59

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.