I have a solidity contract which stores an array of Proposal information:

contract Submissions {

    Proposal[] public proposals;

    struct Proposal {
        // ....

In a test (using truffle framework), I am trying to access the proposal data:

const proposals = await Submissions.proposals();

But I get this exception:

Invalid number of arguments to Solidity function

I don't understand this as it is not a function and therefore requires no arguments. Elsewhere in my tests I have successfully gathered contract data using this method (although not for arrays) - what am I missing?

1 Answer 1


The automatically generated getter for an array accepts a single parameter: the index into the array.

So you should be able to call proposals(0), proposals(1), etc. to fetch members of the array.

  • Just one question though, indexing like that seems to return an address rather than the entire struct that I have defined - why is that? And what address is it referring to? Aug 17, 2018 at 14:11
  • You might have to share what you're seeing. Each call should return a Proposal, though I think some members of the struct might be skipped if their types are not supported by the ABI encoder. Without knowing what's in Proposal, it's hard to speculate further.
    – user19510
    Aug 17, 2018 at 14:24

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.