Election

Celo

0x8d6677192144292870907e3fa8a5527fe55a7ff6

Proxy implementation: 0xbd7d392bb2ef07063256e875f363d4fb2931780e

Solidity v0.5.13+commit.5b0b510c

🤖
Query this contract from your AI
Reference: 0x8d6677192144292870907e3fa8a5527fe55a7ff6
Sample prompt: "Tell me the current state of celo/0x8d6677192144292870907e3fa8a5527fe55a7ff6"
No AI wired up yet? → mcp.smarts.md
Celo is a docs-only chain on Smarts: source code and ABI are indexed, but live on-chain data (state, recent events, admin profile) is not currently available. AI agents can still query get_contract_info and get_contract_source via MCP.

Overview

Read Functions
54
Write Functions
20
Events
14

Read Functions

allowedToVoteOverMaxNumberOfGroups(address) view

Parameters

Name Type Description
address

Returns

Name Type Description
bool
cachedVotesByAccount(address) view

Parameters

Name Type Description
address

Returns

Name Type Description
totalVotes uint256
canReceiveVotes(group: address, value: uint256) view

Returns whether or not a group can receive the specified number of votes.

dev: Note that groups may still receive additional votes via rewards even if this function returns false.

Parameters

Name Type Description
group address The address of the group.
value uint256 The number of votes.

Returns

Name Type Description
bool Whether or not a group can receive the specified number of votes.
checkProofOfPossession(sender: address, blsKey: bytes, blsPop: bytes) view

Checks a BLS proof of possession.

dev: This function will be deprecated in L2.

Parameters

Name Type Description
sender address The address signed by the BLS key to generate the proof of possession.
blsKey bytes The BLS public key that the validator is using for consensus, should pass proof of possession. 48 bytes.
blsPop bytes The BLS public key proof-of-possession, which consists of a signature on the account address. 96 bytes.

Returns

Name Type Description
bool True upon success.
electNValidatorAccounts(minElectableValidators: uint256, maxElectableValidators: uint256) view

Parameters

Name Type Description
minElectableValidators uint256
maxElectableValidators uint256

Returns

Name Type Description
address[]
electNValidatorSigners(minElectableValidators: uint256, maxElectableValidators: uint256) view

Parameters

Name Type Description
minElectableValidators uint256
maxElectableValidators uint256

Returns

Name Type Description
address[]
electValidatorAccounts() view

Returns a list of elected validators with seats allocated to groups via the D'Hondt method.

Returns

Name Type Description
address[] The list of elected validators.
electValidatorSigners() view

Returns a list of elected validator signers with seats allocated to groups via the D'Hondt method.

Returns

Name Type Description
address[] The list of elected validator signers.
electabilityThreshold() view

Returns

Name Type Description
value uint256
electableValidators() view

Returns

Name Type Description
min uint256
max uint256
fractionMulExp(aNumerator: uint256, aDenominator: uint256, bNumerator: uint256, bDenominator: uint256, exponent: uint256, _decimals: uint256) view

calculate a * b^x for fractions a, b to `decimals` precision

dev: This function will be deprecated in L2.

Parameters

Name Type Description
aNumerator uint256 Numerator of first fraction
aDenominator uint256 Denominator of first fraction
bNumerator uint256 Numerator of exponentiated fraction
bDenominator uint256 Denominator of exponentiated fraction
exponent uint256 exponent to raise b to
_decimals uint256 precision

Returns

Name Type Description
uint256 Numerator of the computed quantity (not reduced).
uint256 Denominator of the computed quantity (not reduced).
getActiveVoteUnitsForGroup(group: address) view

Returns the total active vote units made for `group`.

Parameters

Name Type Description
group address The address of the validator group.

Returns

Name Type Description
uint256 The total active vote units made for `group`.
getActiveVoteUnitsForGroupByAccount(group: address, account: address) view

Returns the active vote units for `group` made by `account`.

Parameters

Name Type Description
group address The address of the validator group.
account address The address of the voting account.

Returns

Name Type Description
uint256 The active vote units for `group` made by `account`.
getActiveVotes() view

Returns the active votes received across all groups.

Returns

Name Type Description
uint256 The active votes received across all groups.
getActiveVotesForGroup(group: address) view

Returns the active votes made for `group`.

Parameters

Name Type Description
group address The address of the validator group.

Returns

Name Type Description
uint256 The active votes made for `group`.
getActiveVotesForGroupByAccount(group: address, account: address) view

Returns the active votes for `group` made by `account`.

Parameters

Name Type Description
group address The address of the validator group.
account address The address of the voting account.

Returns

Name Type Description
uint256 The active votes for `group` made by `account`.
getBlockNumberFromHeader(header: bytes) view

Parses block number out of header.

dev: This function will be deprecated in L2.

Parameters

Name Type Description
header bytes RLP encoded header

Returns

Name Type Description
uint256 Block number.
getBlockedByContract() view

Returns the address of the contract imposing the block.

Returns

Name Type Description
blockedBy address
getCurrentValidatorSigners() view

Returns get current validator signers using the precompiles.

Returns

Name Type Description
address[] List of current validator signers.
getElectabilityThreshold() view

Gets the election threshold.

Returns

Name Type Description
uint256 Threshold value as unwrapped fraction.
getElectableValidators() view

Returns the minimum and maximum number of validators that can be elected.

Returns

Name Type Description
uint256 The minimum number of validators that can be elected.
uint256 The maximum number of validators that can be elected.
getEligibleValidatorGroups() view

Returns the list of validator groups eligible to elect validators.

Returns

Name Type Description
address[] The list of validator groups eligible to elect validators.
getEpochNumber() view

Returns the epoch number at a block.

Returns

Name Type Description
uint256 Current epoch number.
getEpochNumberOfBlock(blockNumber: uint256) view

Returns the epoch number at a block.

Parameters

Name Type Description
blockNumber uint256 Block number where epoch number is calculated.

Returns

Name Type Description
uint256 Epoch number.
getEpochSize() view

Returns the current epoch size in blocks.

dev: This function will be deprecated in L2.

Returns

Name Type Description
uint256 The current epoch size in blocks.
getGroupEligibility(group: address) view

Returns whether or not a group is eligible to receive votes.

dev: Eligible groups that have received their maximum number of votes cannot receive more.

Parameters

Name Type Description
group address

Returns

Name Type Description
bool Whether or not a group is eligible to receive votes.
getGroupEpochRewardsBasedOnScore(group: address, totalEpochRewards: uint256, groupScore: uint256) view

Returns the amount of rewards that voters for `group` are due at the end of an epoch.

dev: Eligible groups that have received their maximum number of votes cannot receive more.

Parameters

Name Type Description
group address The group to calculate epoch rewards for.
totalEpochRewards uint256 The total amount of rewards going to all voters.
groupScore uint256 The score of the group.

Returns

Name Type Description
uint256 The amount of rewards that voters for `group` are due at the end of an epoch.
getGroupsVotedForByAccount(account: address) view

Returns the groups that `account` has voted for.

Parameters

Name Type Description
account address The address of the account casting votes.

Returns

Name Type Description
address[] The groups that `account` has voted for.
getNumVotesReceivable(group: address) view

Returns the number of votes that a group can receive.

dev: Note that a group's vote total may exceed this number through rewards or config changes.

Parameters

Name Type Description
group address The address of the group.

Returns

Name Type Description
uint256 The number of votes that a group can receive.
getParentSealBitmap(blockNumber: uint256) view

Gets the parent seal bitmap from the header at the given block number.

dev: This function will be deprecated in L2.

Parameters

Name Type Description
blockNumber uint256 Block number to retrieve. Must be within 4 epochs of the current number.

Returns

Name Type Description
bytes32 Bitmap parent seal with set bits at indices corresponding to signing validators.
getPendingVotesForGroup(group: address) view

Returns the pending votes made for `group`.

Parameters

Name Type Description
group address The address of the validator group.

Returns

Name Type Description
uint256 The pending votes made for `group`.
getPendingVotesForGroupByAccount(group: address, account: address) view

Returns the pending votes for `group` made by `account`.

Parameters

Name Type Description
group address The address of the validator group.
account address The address of the voting account.

Returns

Name Type Description
uint256 The pending votes for `group` made by `account`.
getTotalVotes() view

Returns the total votes received across all groups.

Returns

Name Type Description
uint256 The total votes received across all groups.
getTotalVotesByAccount(account: address) view

Returns the total number of votes cast by an account.

Parameters

Name Type Description
account address The address of the account.

Returns

Name Type Description
uint256 The total number of votes cast by an account.
getTotalVotesForEligibleValidatorGroups() view

Returns list of all validator groups and the number of votes they've received.

Returns

Name Type Description
groups address[] List of all validator groups
values uint256[] Number of votes each validator group received.
getTotalVotesForGroup(group: address) view

Returns the total votes made for `group`.

Parameters

Name Type Description
group address The address of the validator group.

Returns

Name Type Description
uint256 The total votes made for `group`.
getTotalVotesForGroupByAccount(group: address, account: address) view

Returns the total votes for `group` made by `account`.

Parameters

Name Type Description
group address The address of the validator group.
account address The address of the voting account.

Returns

Name Type Description
uint256 The total votes for `group` made by `account`.
getVerifiedSealBitmapFromHeader(header: bytes) view

Verifies the BLS signature on the header and returns the seal bitmap. The validator set used for verification is retrieved based on the parent hash field of the header. If the parent hash is not in the blockchain, verification fails.

dev: This function will be deprecated in L2.

Parameters

Name Type Description
header bytes RLP encoded header

Returns

Name Type Description
bytes32 Bitmap parent seal with set bits at indices correspoinding to signing validators.
getVersionNumber() pure

Returns the storage, major, minor, and patch version of the contract.

Returns

Name Type Description
uint256 Storage version of the contract.
uint256 Major version of the contract.
uint256 Minor version of the contract.
uint256 Patch version of the contract.
hasActivatablePendingVotes(account: address, group: address) view

Returns whether or not an account's votes for the specified group can be activated.

dev: Pending votes cannot be activated until an election has been held.

Parameters

Name Type Description
account address The account with pending votes.
group address The validator group that `account` has pending votes for.

Returns

Name Type Description
bool Whether or not `account` has activatable votes for `group`.
hashHeader(header: bytes) view

Computes hash of header.

dev: This function will be deprecated in L2.

Parameters

Name Type Description
header bytes RLP encoded header

Returns

Name Type Description
bytes32 Header hash.
initialized() view

Returns

Name Type Description
bool
isBlocked() view

Checks if the contract is currently blocked.

dev: The function returns false if no blocking contract has been set.

Returns

Name Type Description
bool Returns true if the contract is blocked, otherwise false.
isOwner() view
dev: Returns true if the caller is the current owner.

Returns

Name Type Description
bool
maxNumGroupsVotedFor() view

Returns

Name Type Description
uint256
minQuorumSize(blockNumber: uint256) view

Returns the minimum number of required signers for a given block number.

dev: This function will be deprecated in L2.

Parameters

Name Type Description
blockNumber uint256

Returns

Name Type Description
uint256
minQuorumSizeInCurrentSet() view

Computes byzantine quorum from current validator set size

dev: This function will be deprecated in L2.

Returns

Name Type Description
uint256 Byzantine quorum of validators.
numberValidatorsInCurrentSet() view

Gets the size of the current elected validator set.

Returns

Name Type Description
uint256 Size of the current elected validator set.
numberValidatorsInSet(blockNumber: uint256) view

Gets the size of the validator set that must sign the given block number.

dev: This function will be deprecated in L2.

Parameters

Name Type Description
blockNumber uint256 Block number to retrieve the validator set from.

Returns

Name Type Description
uint256 Size of the validator set.
owner() view
dev: Returns the address of the current owner.

Returns

Name Type Description
address
registry() view

Returns

Name Type Description
address
validatorAddressFromCurrentSet(index: uint256) view

Gets a validator address from the current validator set.

Parameters

Name Type Description
index uint256 Index of requested validator in the validator set.

Returns

Name Type Description
address Address of validator at the requested index.
validatorSignerAddressFromCurrentSet(index: uint256) view

Gets a validator signer address from the current validator set.

Parameters

Name Type Description
index uint256 Index of requested validator in the validator set.

Returns

Name Type Description
address Address of validator signer at the requested index.
validatorSignerAddressFromSet(index: uint256, blockNumber: uint256) view

Gets a validator signer address from the validator set at the given block number.

dev: This function will be deprecated in L2.

Parameters

Name Type Description
index uint256 Index of requested validator in the validator set.
blockNumber uint256 Block number to retrieve the validator set from.

Returns

Name Type Description
address Address of validator signer at the requested index.

Write Functions

activate(group: address) nonpayable

Converts `account`'s pending votes for `group` to active votes.

dev: Pending votes cannot be activated until an election has been held.

Parameters

Name Type Description
group address The validator group to vote for.

Returns

Name Type Description
bool True upon success.
activateForAccount(group: address, account: address) nonpayable

Converts `account`'s pending votes for `group` to active votes.

dev: Pending votes cannot be activated until an election has been held.

Parameters

Name Type Description
group address The validator group to vote for.
account address The validateor group account's pending votes to active votes

Returns

Name Type Description
bool True upon success.
distributeEpochRewards(group: address, value: uint256, lesser: address, greater: address) nonpayable

Distributes epoch rewards to voters for `group` in the form of active votes.

dev: Can only be called directly by the protocol.

Parameters

Name Type Description
group address The group whose voters will receive rewards.
value uint256 The amount of rewards to distribute to voters for the group.
lesser address The group receiving fewer votes than `group` after the rewards are added.
greater address The group receiving more votes than `group` after the rewards are added.
forceDecrementVotes(account: address, value: uint256, lessers: address[], greaters: address[], indices: uint256[]) nonpayable

Reduces the total amount of `account`'s voting gold by `value` by iterating over all groups voted for by account.

Parameters

Name Type Description
account address Address to revoke votes from.
value uint256 Maximum amount of votes to revoke.
lessers address[] The groups receiving fewer votes than the i'th `group`, or 0 if the i'th `group` has the fewest votes of any validator group.
greaters address[] The groups receivier more votes than the i'th `group`, or 0 if the i'th `group` has the most votes of any validator group.
indices uint256[] The indices of the i'th group in the account's voting list.

Returns

Name Type Description
uint256 Number of votes successfully decremented.
initialize(registryAddress: address, minElectableValidators: uint256, maxElectableValidators: uint256, _maxNumGroupsVotedFor: uint256, _electabilityThreshold: uint256) nonpayable

Used in place of the constructor to allow the contract to be upgradable via proxy.

dev: Should be called only once.

Parameters

Name Type Description
registryAddress address The address of the registry core smart contract.
minElectableValidators uint256 The minimum number of validators that can be elected.
maxElectableValidators uint256
_maxNumGroupsVotedFor uint256 The maximum number of groups that an account can vote for at once.
_electabilityThreshold uint256 The minimum ratio of votes a group needs before its members can be elected.
markGroupEligible(group: address, lesser: address, greater: address) nonpayable

Marks a group eligible for electing validators.

Parameters

Name Type Description
group address The address of the validator group.
lesser address The address of the group that has received fewer votes than this group.
greater address The address of the group that has received more votes than this group.
markGroupIneligible(group: address) nonpayable

Marks a group ineligible for electing validators.

dev: Can only be called by the registered "Validators" contract.

Parameters

Name Type Description
group address The address of the validator group.
renounceOwnership() nonpayable
dev: Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.
revokeActive(group: address, value: uint256, lesser: address, greater: address, index: uint256) nonpayable

Revokes `value` active votes for `group`

dev: Fails if the account has not voted on a validator group.

Parameters

Name Type Description
group address The validator group to revoke votes from.
value uint256 The number of votes to revoke.
lesser address The group receiving fewer votes than the group for which the vote was revoked, or 0 if that group has the fewest votes of any validator group.
greater address The group receiving more votes than the group for which the vote was revoked, or 0 if that group has the most votes of any validator group.
index uint256 The index of the group in the account's voting list.

Returns

Name Type Description
bool True upon success.
revokeAllActive(group: address, lesser: address, greater: address, index: uint256) nonpayable

Revokes all active votes for `group`

dev: Fails if the account has not voted on a validator group.

Parameters

Name Type Description
group address The validator group to revoke votes from.
lesser address The group receiving fewer votes than the group for which the vote was revoked, or 0 if that group has the fewest votes of any validator group.
greater address The group receiving more votes than the group for which the vote was revoked, or 0 if that group has the most votes of any validator group.
index uint256 The index of the group in the account's voting list.

Returns

Name Type Description
bool True upon success.
revokePending(group: address, value: uint256, lesser: address, greater: address, index: uint256) nonpayable

Revokes `value` pending votes for `group`

dev: Fails if the account has not voted on a validator group.

Parameters

Name Type Description
group address The validator group to revoke votes from.
value uint256 The number of votes to revoke.
lesser address The group receiving fewer votes than the group for which the vote was revoked, or 0 if that group has the fewest votes of any validator group.
greater address The group receiving more votes than the group for which the vote was revoked, or 0 if that group has the most votes of any validator group.
index uint256 The index of the group in the account's voting list.

Returns

Name Type Description
bool True upon success.
setAllowedToVoteOverMaxNumberOfGroups(flag: bool) nonpayable

Allows to turn on/off voting over maxNumGroupsVotedFor. Once this is turned on and account voted for more than maxNumGroupsVotedFor, it is account's obligation to run updateTotalVotesByAccountForGroup once a day. If not run, voting power of account will not reflect rewards awarded.

Parameters

Name Type Description
flag bool The on/off flag.
setBlockedByContract(_blockedBy: address) nonpayable

Sets the address of the blocking contract.

dev: Can only be called by the owner of the contract.

Parameters

Name Type Description
_blockedBy address The address of the contract that will determine if this contract is blocked.
setElectabilityThreshold(threshold: uint256) nonpayable

Sets the electability threshold.

Parameters

Name Type Description
threshold uint256 Electability threshold as unwrapped Fraction.

Returns

Name Type Description
bool True upon success.
setElectableValidators(min: uint256, max: uint256) nonpayable

Updates the minimum and maximum number of validators that can be elected.

Parameters

Name Type Description
min uint256 The minimum number of validators that can be elected.
max uint256 The maximum number of validators that can be elected.

Returns

Name Type Description
bool True upon success.
setMaxNumGroupsVotedFor(_maxNumGroupsVotedFor: uint256) nonpayable

Updates the maximum number of groups an account can be voting for at once.

Parameters

Name Type Description
_maxNumGroupsVotedFor uint256 The maximum number of groups an account can vote for.

Returns

Name Type Description
bool True upon success.
setRegistry(registryAddress: address) nonpayable

Updates the address pointing to a Registry contract.

Parameters

Name Type Description
registryAddress address The address of a registry contract for routing to other contracts.
transferOwnership(newOwner: address) nonpayable
dev: Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.

Parameters

Name Type Description
newOwner address
updateTotalVotesByAccountForGroup(account: address, group: address) nonpayable

Counts and caches account's votes for group.

Parameters

Name Type Description
account address The address of the voting account.
group address The address of the validator group.
vote(group: address, value: uint256, lesser: address, greater: address) nonpayable

Increments the number of total and pending votes for `group`.

dev: Fails if `group` is empty or not a validator group.

Parameters

Name Type Description
group address The validator group to vote for.
value uint256 The amount of gold to use to vote.
lesser address The group receiving fewer votes than `group`, or 0 if `group` has the fewest votes of any validator group.
greater address The group receiving more votes than `group`, or 0 if `group` has the most votes of any validator group.

Returns

Name Type Description
bool True upon success.

Events

AllowedToVoteOverMaxNumberOfGroups(account: address, flag: bool)
Name Type Indexed Description
account address
flag bool
BlockedBySet(_blockedBy: address)
Name Type Indexed Description
_blockedBy address
ElectabilityThresholdSet(electabilityThreshold: uint256)
Name Type Indexed Description
electabilityThreshold uint256
ElectableValidatorsSet(min: uint256, max: uint256)
Name Type Indexed Description
min uint256
max uint256
EpochRewardsDistributedToVoters(group: address, value: uint256)
Name Type Indexed Description
group address
value uint256
MaxNumGroupsVotedForSet(maxNumGroupsVotedFor: uint256)
Name Type Indexed Description
maxNumGroupsVotedFor uint256
OwnershipTransferred(previousOwner: address, newOwner: address)
Name Type Indexed Description
previousOwner address
newOwner address
RegistrySet(registryAddress: address)
Name Type Indexed Description
registryAddress address
ValidatorGroupActiveVoteRevoked(account: address, group: address, value: uint256, units: uint256)
Name Type Indexed Description
account address
group address
value uint256
units uint256
ValidatorGroupMarkedEligible(group: address)
Name Type Indexed Description
group address
ValidatorGroupMarkedIneligible(group: address)
Name Type Indexed Description
group address
ValidatorGroupPendingVoteRevoked(account: address, group: address, value: uint256)
Name Type Indexed Description
account address
group address
value uint256
ValidatorGroupVoteActivated(account: address, group: address, value: uint256, units: uint256)
Name Type Indexed Description
account address
group address
value uint256
units uint256
ValidatorGroupVoteCast(account: address, group: address, value: uint256)
Name Type Indexed Description
account address
group address
value uint256