Not able to get all values in public array

domschdomsch Member Posts: 11
I am currently trying to keep track of all votes in a poll by pushing the polls to a bytes32 array. It all seems to be working fine, except that I can't get all of the values in the array.

Here is the contract. I am using the vote function in this case:

As you can see, the contract is keeping track of numvotes (5 in this example). So when I call contract.votes() afterwards, I only get the hex value of the first vote, which is "0x6266647373000000000000000000000000000000000000000000000000000000".

Anyone have a clue what's going on and how to fix this?


  • domschdomsch Member Posts: 11
    tjade273 said:

    Calling contract.votes() is the same as calling contract.votes(0), so it will give you the first value in the array. The getter function only gets single values.

    If you want to return the whole array, you should write your own getter function, or iterate over contract.votes(i).

    Alright thanks
Sign In or Register to comment.