This is my contract where I am building a list of members who will use a addVote function. The allMembersVoted function always seems to return false even though the Remix debugger shows that, the function does return true correctly. Can you please help me find out what is missing?

The flow is like this:

  • Create new contract
  • Build list
  • Vote
  • Check if every one has voted

    struct ListMembers {
        bytes32 listOwner;
        bytes32[] members;
    ListMembers public lm;
    mapping(bytes32 => bool) public addedMembers;
    // Constructor to initialise the ListMembers struct
    function Lister(bytes32 listOwner) {
        lm.listOwner = listOwner;
        lm.members.length = 1;
        lm.members[0] = listOwner;
    function buildList(bytes32[] listMembers) {
        lm.members.length = listMembers.length + 1;
        for (uint i = 0; i < listMembers.length; i++) {
            lm.members[i + 1] = listMembers[i];
    function addVote(bytes32 member, uint256 number) {
        if (memberAdded(member) == true) { // Check double votes
        } else {
            addedMembers[member] = true; // Confirm that vote added
            if (memberIsOwner(member) == true) {
                // Add vote with weight
            } else {
                // Add vote without weight 
    function memberAdded(bytes32 member) returns (bool) {
        return addedMembers[member];
    function allMembersVoted() returns (bool) {
        bool voted = true;
        for (uint i = 0; i < lm.members.length; i++) {
            voted = voted && addedMembers[lm.members[i]];
        return voted;

bumped to the homepage by Community 11 hours ago

This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.


Apparently, the culprit was the way I was adding to arrays. I changed the addition via index to push() and things are working now. So, lm.members[i + 1] = listMembers[i] became lm.members.push(listMembers[i])).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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