How to get results by running the voting code on Ethereum?

0 votes

I executed the code posted here on the MIST Ethereum Wallet, the problem is I can't find how to "stop" the voting and get the final result. Can someone help me?

Sep 18, 2018 in Blockchain by slayer
• 29,300 points
77 views

1 answer to this question.

0 votes

In mist go to your contract and run the winningProposal() function. This computes the winning proposal taking all previous votes into account.

/// @dev Computes the winning proposal taking all
/// previous votes into account.
function winningProposal() constant
        returns (uint winningProposal)
{
    uint winningVoteCount = 0;
    for (uint p = 0; p < proposals.length; p++) {
        if (proposals[p].voteCount > winningVoteCount) {
            winningVoteCount = proposals[p].voteCount;
            winningProposal = p;
        }
    }
}

It will return the ID of the proposal with the most votes. See proposals struct:

// This is a type for a single proposal.
struct Proposal
{
    bytes32 name;   // short name (up to 32 bytes)
    uint voteCount; // number of accumulated votes
}
answered Sep 18, 2018 by digger
• 26,680 points

Related Questions In Blockchain

+1 vote
1 answer

How does a miner get to know that a transaction is verified by all the nodes?

Contrary to the popular belief, it is ...READ MORE

answered Mar 26, 2018 in Blockchain by Johnathon
• 9,090 points
418 views
0 votes
2 answers

How to get notified when an event triggers on ethereum smart contract?

Muchas gracias. ?Como puedo iniciar sesion? READ MORE

answered May 2 in Blockchain by aqowcmbevs
844 views
0 votes
1 answer

How to get account with ethers by default in ethereum private network?

Have you created an account before allocating ...READ MORE

answered Jan 9, 2019 in Blockchain by Omkar
• 69,030 points
340 views
0 votes
1 answer

Protocols used in a distributed/dlt system for the nodes to establish communication

yes all are over TCP/IP connections secured by TLS encryption in hashgraph architecture-hashgraph, ...READ MORE

answered Aug 6, 2018 in Blockchain by aryya
• 7,380 points
278 views
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,810 points
410 views
0 votes
1 answer
+1 vote
2 answers

How to get airdropped tokens to Ethereum wallet?

You also can use Frewallet This wallet is ...READ MORE

answered Dec 20, 2019 in Blockchain by anonymous
• 160 points
100 views
0 votes
1 answer

How to connect to already running go ethereum client using mist Ubuntu

Hey, you can solve the issue by using sudo ...READ MORE

answered Sep 18, 2018 in Blockchain by digger
• 26,680 points
98 views