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,370 points
701 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,740 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 27, 2018 in Blockchain by Johnathon
• 9,090 points
2,871 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, 2020 in Blockchain by aqowcmbevs
2,406 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,220 points
1,713 views
+1 vote
1 answer

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

yes all are over TCP/IP connections secured ...READ MORE

answered Aug 6, 2018 in Blockchain by aryya
• 7,460 points
1,460 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,790 points
1,943 views
0 votes
1 answer

Hyperledger Sawtooth vs Quorum in concurrency and speed Ask

Summary: Both should provide similar reliability of ...READ MORE

answered Sep 26, 2018 in IoT (Internet of Things) by Upasana
• 8,620 points
1,469 views
+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
1,219 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,740 points
719 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP