Created
February 28, 2020 16:02
-
-
Save fortmarek/b9407779ef905be552ddcb83a6d597b4 to your computer and use it in GitHub Desktop.
Contract init
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import smartpy as sp | |
class Ballot(sp.Contract): | |
def __init__(self, name, manager, candidates, voters, numberOfVotes): | |
initialBallot = {} | |
for candidate in candidates: | |
# Initializing initialBallot where we save `candidateName` and set `numberOfVotes` to zero | |
initialBallot[candidate[0]] = sp.record(candidateName = candidate[1], numberOfVotes = 0) | |
initialVoters = { } | |
for voter in voters: | |
# For every voter set their remaining votes to maximum | |
initialVoters[voter] = numberOfVotes | |
self.init(name = name, manager = manager, ballot = initialBallot, voters = initialVoters, hasEnded = False, totalNumberOfVotes = 0, votesPerVoter = numberOfVotes) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment