Skip to content

Elections


Calls


clean_defunct_voters

See [Pallet::clean_defunct_voters].

Attributes

Name Type
num_voters u32
num_defunct u32

Python

call = substrate.compose_call(
    'Elections', 'clean_defunct_voters', {
    'num_defunct': 'u32',
    'num_voters': 'u32',
}
)

remove_member

See [Pallet::remove_member].

Attributes

Name Type
who AccountIdLookupOf<T>
slash_bond bool
rerun_election bool

Python

call = substrate.compose_call(
    'Elections', 'remove_member', {
    'rerun_election': 'bool',
    'slash_bond': 'bool',
    'who': 'AccountId',
}
)

remove_voter

See [Pallet::remove_voter].

Attributes

No attributes

Python

call = substrate.compose_call(
    'Elections', 'remove_voter', {}
)

renounce_candidacy

See [Pallet::renounce_candidacy].

Attributes

Name Type
renouncing Renouncing

Python

call = substrate.compose_call(
    'Elections', 'renounce_candidacy', {
    'renouncing': {
        'Candidate': 'u32',
        'Member': None,
        'RunnerUp': None,
    },
}
)

submit_candidacy

See [Pallet::submit_candidacy].

Attributes

Name Type
candidate_count u32

Python

call = substrate.compose_call(
    'Elections', 'submit_candidacy', {'candidate_count': 'u32'}
)

vote

See [Pallet::vote].

Attributes

Name Type
votes Vec<T::AccountId>
value BalanceOf<T>

Python

call = substrate.compose_call(
    'Elections', 'vote', {
    'value': 'u128',
    'votes': ['AccountId'],
}
)

Events


CandidateSlashed

A candidate was slashed by amount due to failing to obtain a seat as member or runner-up.

Note that old members and runners-up are also candidates.

Attributes

Name Type Composition
candidate <T as frame_system::Config>::AccountId AccountId
amount BalanceOf<T> u128

ElectionError

Internal error happened while trying to perform election.

Attributes

No attributes


EmptyTerm

No (or not enough) candidates existed for this round. This is different from NewTerm(\[\]). See the description of NewTerm.

Attributes

No attributes


MemberKicked

A member has been removed. This should always be followed by either NewTerm or EmptyTerm.

Attributes

Name Type Composition
member <T as frame_system::Config>::AccountId AccountId

NewTerm

A new term with new_members. This indicates that enough candidates existed to run the election, not that enough have has been elected. The inner value must be examined for this purpose. A NewTerm(\[\]) indicates that some candidates got their bond slashed and none were elected, whilst EmptyTerm means that no candidates existed to begin with.

Attributes

Name Type Composition
new_members Vec<(<T as frame_system::Config>::AccountId, BalanceOf<T>)> [('AccountId', 'u128')]

Renounced

Someone has renounced their candidacy.

Attributes

Name Type Composition
candidate <T as frame_system::Config>::AccountId AccountId

SeatHolderSlashed

A seat holder was slashed by amount by being forcefully removed from the set.

Attributes

Name Type Composition
seat_holder <T as frame_system::Config>::AccountId AccountId
amount BalanceOf<T> u128

Storage functions


Candidates

The present candidate list. A current member or runner-up can never enter this vector and is always implicitly assumed to be a candidate.

Second element is the deposit.

Invariant: Always sorted based on account id.

Python

result = substrate.query(
    'Elections', 'Candidates', []
)

Return value

[('AccountId', 'u128')]

ElectionRounds

The total number of vote rounds that have happened, excluding the upcoming one.

Python

result = substrate.query(
    'Elections', 'ElectionRounds', []
)

Return value

'u32'

Members

The current elected members.

Invariant: Always sorted based on account id.

Python

result = substrate.query(
    'Elections', 'Members', []
)

Return value

[{'deposit': 'u128', 'stake': 'u128', 'who': 'AccountId'}]

RunnersUp

The current reserved runners-up.

Invariant: Always sorted based on rank (worse to best). Upon removal of a member, the last (i.e. best) runner-up will be replaced.

Python

result = substrate.query(
    'Elections', 'RunnersUp', []
)

Return value

[{'deposit': 'u128', 'stake': 'u128', 'who': 'AccountId'}]

Voting

Votes and locked stake of a particular voter.

TWOX-NOTE: SAFE as AccountId is a crypto hash.

Python

result = substrate.query(
    'Elections', 'Voting', ['AccountId']
)

Return value

{'deposit': 'u128', 'stake': 'u128', 'votes': ['AccountId']}

Constants


CandidacyBond

How much should be locked up in order to submit one's candidacy.

Value

500000000000000

Python

constant = substrate.get_constant('Elections', 'CandidacyBond')

DesiredMembers

Number of members to elect.

Value

13

Python

constant = substrate.get_constant('Elections', 'DesiredMembers')

DesiredRunnersUp

Number of runners_up to keep.

Value

15

Python

constant = substrate.get_constant('Elections', 'DesiredRunnersUp')

MaxCandidates

The maximum number of candidates in a phragmen election.

Warning: This impacts the size of the election which is run onchain. Chose wisely, and consider how it will impact T::WeightInfo::election_phragmen.

When this limit is reached no more candidates are accepted in the election.

Value

100

Python

constant = substrate.get_constant('Elections', 'MaxCandidates')

MaxVoters

The maximum number of voters to allow in a phragmen election.

Warning: This impacts the size of the election which is run onchain. Chose wisely, and consider how it will impact T::WeightInfo::election_phragmen.

When the limit is reached the new voters are ignored.

Value

768

Python

constant = substrate.get_constant('Elections', 'MaxVoters')

MaxVotesPerVoter

Maximum numbers of votes per voter.

Warning: This impacts the size of the election which is run onchain. Chose wisely, and consider how it will impact T::WeightInfo::election_phragmen.

Value

10

Python

constant = substrate.get_constant('Elections', 'MaxVotesPerVoter')

PalletId

Identifier for the elections-phragmen pallet's lock

Value

'0x706872656c656374'

Python

constant = substrate.get_constant('Elections', 'PalletId')

TermDuration

How long each seat is kept. This defines the next block number at which an election round will happen. If set to zero, no elections are ever triggered and the module will be in passive mode.

Value

50400

Python

constant = substrate.get_constant('Elections', 'TermDuration')

VotingBondBase

Base deposit associated with voting.

This should be sensibly high to economically ensure the pallet cannot be attacked by creating a gigantic number of votes.

Value

1000000000000

Python

constant = substrate.get_constant('Elections', 'VotingBondBase')

VotingBondFactor

The amount of bond that need to be locked for each vote (32 bytes).

Value

1000000000000

Python

constant = substrate.get_constant('Elections', 'VotingBondFactor')

Errors


DuplicatedCandidate

Duplicated candidate submission.


InsufficientCandidateFunds

Candidate does not have enough funds.


InvalidRenouncing

The renouncing origin presented a wrong Renouncing parameter.


InvalidReplacement

Prediction regarding replacement after member removal is wrong.


InvalidVoteCount

The provided count of number of votes is incorrect.


InvalidWitnessData

The provided count of number of candidates is incorrect.


LowBalance

Cannot vote with stake less than minimum balance.


MaximumVotesExceeded

Cannot vote more than maximum allowed.


MemberSubmit

Member cannot re-submit candidacy.


MustBeVoter

Must be a voter.


NoVotes

Must vote for at least one candidate.


NotMember

Not a member.


RunnerUpSubmit

Runner cannot re-submit candidacy.


TooManyCandidates

Too many candidates have been created.


TooManyVotes

Cannot vote more than candidates.


UnableToPayBond

Voter can not pay voting bond.


UnableToVote

Cannot vote when no candidates or members exist.