Election

Celo

0x8d6677192144292870907e3fa8a5527fe55a7ff6

Proxy 實作合約: 0xbd7d392bb2ef07063256e875f363d4fb2931780e

Solidity v0.5.13+commit.5b0b510c

🤖
透過你的 AI 查詢此合約
參考: 0x8d6677192144292870907e3fa8a5527fe55a7ff6
範例提示詞: "Tell me the current state of celo/0x8d6677192144292870907e3fa8a5527fe55a7ff6"
還沒有接入 AI?→ mcp.smarts.md
Celo 在 Smarts 上是僅文件鏈:原始碼和 ABI 已索引,但目前不提供即時鏈上資料(狀態、最新事件、管理員概覽)。AI 代理仍可透過 MCP 呼叫 get_contract_info 和 get_contract_source。

概覽

讀取函式
54
寫入函式
20
事件
14

讀取函式

allowedToVoteOverMaxNumberOfGroups(address) view

Check whether the given address is allowed to vote even if it has reached the maximum number of groups.✨ AI

參數

名稱 類型 描述
address

回傳值

名稱 類型 描述
bool True if the address is permitted to vote despite reaching the max groups; false otherwise.✨ AI
cachedVotesByAccount(address) view

Return the cached vote count for the specified account.✨ AI

參數

名稱 類型 描述
address

回傳值

名稱 類型 描述
totalVotes uint256 Total cached votes for the account as a uint256.✨ AI
canReceiveVotes(group: address, value: uint256) view

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

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

參數

名稱 類型 描述
group address The address of the group.
value uint256 The number of votes.

回傳值

名稱 類型 描述
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.

開發者: This function will be deprecated in L2.

參數

名稱 類型 描述
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.

回傳值

名稱 類型 描述
bool True upon success.
electNValidatorAccounts(minElectableValidators: uint256, maxElectableValidators: uint256) view

Selects and returns a set of validator addresses within the requested size bounds.✨ AI

參數

名稱 類型 描述
minElectableValidators uint256 Minimum number of validator accounts to select.✨ AI
maxElectableValidators uint256 Maximum number of validator accounts to select.✨ AI

回傳值

名稱 類型 描述
address[] Array of elected validator addresses; length will be between minElectableValidators and maxElectableValidators inclusive.✨ AI
electNValidatorSigners(minElectableValidators: uint256, maxElectableValidators: uint256) view

Return a list of validator signer addresses elected between the provided min and max bounds.✨ AI

參數

名稱 類型 描述
minElectableValidators uint256 Minimum number of validators to elect (inclusive).✨ AI
maxElectableValidators uint256 Maximum number of validators to elect (inclusive).✨ AI

回傳值

名稱 類型 描述
address[] Array of elected validator signer addresses, with length between minElectableValidators and maxElectableValidators.✨ AI
electValidatorAccounts() view

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

回傳值

名稱 類型 描述
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.

回傳值

名稱 類型 描述
address[] The list of elected validator signers.
electabilityThreshold() view

Returns the current numeric threshold a candidate must meet to be eligible for election.✨ AI

回傳值

名稱 類型 描述
value uint256 The electability threshold as an unsigned integer (units depend on contract context, e.g., votes or token balance).✨ AI
electableValidators() view

Returns the current minimum and maximum numbers of validators eligible for election.✨ AI

回傳值

名稱 類型 描述
min uint256 min: the minimum number of validators that can be elected✨ AI
max uint256 max: the maximum number of validators that can be elected✨ AI
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

開發者: This function will be deprecated in L2.

參數

名稱 類型 描述
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

回傳值

名稱 類型 描述
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`.

參數

名稱 類型 描述
group address The address of the validator group.

回傳值

名稱 類型 描述
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`.

參數

名稱 類型 描述
group address The address of the validator group.
account address The address of the voting account.

回傳值

名稱 類型 描述
uint256 The active vote units for `group` made by `account`.
getActiveVotes() view

Returns the active votes received across all groups.

回傳值

名稱 類型 描述
uint256 The active votes received across all groups.
getActiveVotesForGroup(group: address) view

Returns the active votes made for `group`.

參數

名稱 類型 描述
group address The address of the validator group.

回傳值

名稱 類型 描述
uint256 The active votes made for `group`.
getActiveVotesForGroupByAccount(group: address, account: address) view

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

參數

名稱 類型 描述
group address The address of the validator group.
account address The address of the voting account.

回傳值

名稱 類型 描述
uint256 The active votes for `group` made by `account`.
getBlockNumberFromHeader(header: bytes) view

Parses block number out of header.

開發者: This function will be deprecated in L2.

參數

名稱 類型 描述
header bytes RLP encoded header

回傳值

名稱 類型 描述
uint256 Block number.
getBlockedByContract() view

Returns the address of the contract imposing the block.

回傳值

名稱 類型 描述
blockedBy address
getCurrentValidatorSigners() view

Returns get current validator signers using the precompiles.

回傳值

名稱 類型 描述
address[] List of current validator signers.
getElectabilityThreshold() view

Gets the election threshold.

回傳值

名稱 類型 描述
uint256 Threshold value as unwrapped fraction.
getElectableValidators() view

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

回傳值

名稱 類型 描述
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.

回傳值

名稱 類型 描述
address[] The list of validator groups eligible to elect validators.
getEpochNumber() view

Returns the epoch number at a block.

回傳值

名稱 類型 描述
uint256 Current epoch number.
getEpochNumberOfBlock(blockNumber: uint256) view

Returns the epoch number at a block.

參數

名稱 類型 描述
blockNumber uint256 Block number where epoch number is calculated.

回傳值

名稱 類型 描述
uint256 Epoch number.
getEpochSize() view

Returns the current epoch size in blocks.

開發者: This function will be deprecated in L2.

回傳值

名稱 類型 描述
uint256 The current epoch size in blocks.
getGroupEligibility(group: address) view

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

開發者: Eligible groups that have received their maximum number of votes cannot receive more.

參數

名稱 類型 描述
group address

回傳值

名稱 類型 描述
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.

開發者: Eligible groups that have received their maximum number of votes cannot receive more.

參數

名稱 類型 描述
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.

回傳值

名稱 類型 描述
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.

參數

名稱 類型 描述
account address The address of the account casting votes.

回傳值

名稱 類型 描述
address[] The groups that `account` has voted for.
getNumVotesReceivable(group: address) view

Returns the number of votes that a group can receive.

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

參數

名稱 類型 描述
group address The address of the group.

回傳值

名稱 類型 描述
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.

開發者: This function will be deprecated in L2.

參數

名稱 類型 描述
blockNumber uint256 Block number to retrieve. Must be within 4 epochs of the current number.

回傳值

名稱 類型 描述
bytes32 Bitmap parent seal with set bits at indices corresponding to signing validators.
getPendingVotesForGroup(group: address) view

Returns the pending votes made for `group`.

參數

名稱 類型 描述
group address The address of the validator group.

回傳值

名稱 類型 描述
uint256 The pending votes made for `group`.
getPendingVotesForGroupByAccount(group: address, account: address) view

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

參數

名稱 類型 描述
group address The address of the validator group.
account address The address of the voting account.

回傳值

名稱 類型 描述
uint256 The pending votes for `group` made by `account`.
getTotalVotes() view

Returns the total votes received across all groups.

回傳值

名稱 類型 描述
uint256 The total votes received across all groups.
getTotalVotesByAccount(account: address) view

Returns the total number of votes cast by an account.

參數

名稱 類型 描述
account address The address of the account.

回傳值

名稱 類型 描述
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.

回傳值

名稱 類型 描述
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`.

參數

名稱 類型 描述
group address The address of the validator group.

回傳值

名稱 類型 描述
uint256 The total votes made for `group`.
getTotalVotesForGroupByAccount(group: address, account: address) view

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

參數

名稱 類型 描述
group address The address of the validator group.
account address The address of the voting account.

回傳值

名稱 類型 描述
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.

開發者: This function will be deprecated in L2.

參數

名稱 類型 描述
header bytes RLP encoded header

回傳值

名稱 類型 描述
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.

回傳值

名稱 類型 描述
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.

開發者: Pending votes cannot be activated until an election has been held.

參數

名稱 類型 描述
account address The account with pending votes.
group address The validator group that `account` has pending votes for.

回傳值

名稱 類型 描述
bool Whether or not `account` has activatable votes for `group`.
hashHeader(header: bytes) view

Computes hash of header.

開發者: This function will be deprecated in L2.

參數

名稱 類型 描述
header bytes RLP encoded header

回傳值

名稱 類型 描述
bytes32 Header hash.
initialized() view

Checks whether the election contract has been initialized.✨ AI

回傳值

名稱 類型 描述
bool True if the contract has completed its initialization process, otherwise false.✨ AI
isBlocked() view

Checks if the contract is currently blocked.

開發者: The function returns false if no blocking contract has been set.

回傳值

名稱 類型 描述
bool Returns true if the contract is blocked, otherwise false.
isOwner() view

Checks whether the caller is the contract owner.✨ AI

開發者: Returns true if the caller is the current owner.

回傳值

名稱 類型 描述
bool true if the caller is the contract owner, otherwise false.✨ AI
maxNumGroupsVotedFor() view

Return the maximum number of groups a voter is allowed to vote for.✨ AI

回傳值

名稱 類型 描述
uint256 Maximum number of groups a voter may vote for (uint256).✨ AI
minQuorumSize(blockNumber: uint256) view

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

開發者: This function will be deprecated in L2.

參數

名稱 類型 描述
blockNumber uint256

回傳值

名稱 類型 描述
uint256
minQuorumSizeInCurrentSet() view

Computes byzantine quorum from current validator set size

開發者: This function will be deprecated in L2.

回傳值

名稱 類型 描述
uint256 Byzantine quorum of validators.
numberValidatorsInCurrentSet() view

Gets the size of the current elected validator set.

回傳值

名稱 類型 描述
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.

開發者: This function will be deprecated in L2.

參數

名稱 類型 描述
blockNumber uint256 Block number to retrieve the validator set from.

回傳值

名稱 類型 描述
uint256 Size of the validator set.
owner() view

Returns the address of the contract owner.✨ AI

開發者: Returns the address of the current owner.

回傳值

名稱 類型 描述
address The address of the current contract owner.✨ AI
registry() view

Get the address of the registry contract associated with this election.✨ AI

回傳值

名稱 類型 描述
address The address of the registry contract used to manage eligible voters and candidates.✨ AI
validatorAddressFromCurrentSet(index: uint256) view

Gets a validator address from the current validator set.

參數

名稱 類型 描述
index uint256 Index of requested validator in the validator set.

回傳值

名稱 類型 描述
address Address of validator at the requested index.
validatorSignerAddressFromCurrentSet(index: uint256) view

Gets a validator signer address from the current validator set.

參數

名稱 類型 描述
index uint256 Index of requested validator in the validator set.

回傳值

名稱 類型 描述
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.

開發者: This function will be deprecated in L2.

參數

名稱 類型 描述
index uint256 Index of requested validator in the validator set.
blockNumber uint256 Block number to retrieve the validator set from.

回傳值

名稱 類型 描述
address Address of validator signer at the requested index.

寫入函式

activate(group: address) nonpayable

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

開發者: Pending votes cannot be activated until an election has been held.

參數

名稱 類型 描述
group address The validator group to vote for.

回傳值

名稱 類型 描述
bool True upon success.
activateForAccount(group: address, account: address) nonpayable

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

開發者: Pending votes cannot be activated until an election has been held.

參數

名稱 類型 描述
group address The validator group to vote for.
account address The validateor group account's pending votes to active votes

回傳值

名稱 類型 描述
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.

開發者: Can only be called directly by the protocol.

參數

名稱 類型 描述
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.

參數

名稱 類型 描述
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.

回傳值

名稱 類型 描述
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.

開發者: Should be called only once.

參數

名稱 類型 描述
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.

參數

名稱 類型 描述
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.

開發者: Can only be called by the registered "Validators" contract.

參數

名稱 類型 描述
group address The address of the validator group.
renounceOwnership() nonpayable

Renounces ownership of the contract, leaving the contract without an owner.✨ AI

開發者: 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`

開發者: Fails if the account has not voted on a validator group.

參數

名稱 類型 描述
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.

回傳值

名稱 類型 描述
bool True upon success.
revokeAllActive(group: address, lesser: address, greater: address, index: uint256) nonpayable

Revokes all active votes for `group`

開發者: Fails if the account has not voted on a validator group.

參數

名稱 類型 描述
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.

回傳值

名稱 類型 描述
bool True upon success.
revokePending(group: address, value: uint256, lesser: address, greater: address, index: uint256) nonpayable

Revokes `value` pending votes for `group`

開發者: Fails if the account has not voted on a validator group.

參數

名稱 類型 描述
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.

回傳值

名稱 類型 描述
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.

參數

名稱 類型 描述
flag bool The on/off flag.
setBlockedByContract(_blockedBy: address) nonpayable

Sets the address of the blocking contract.

開發者: Can only be called by the owner of the contract.

參數

名稱 類型 描述
_blockedBy address The address of the contract that will determine if this contract is blocked.
setElectabilityThreshold(threshold: uint256) nonpayable

Sets the electability threshold.

參數

名稱 類型 描述
threshold uint256 Electability threshold as unwrapped Fraction.

回傳值

名稱 類型 描述
bool True upon success.
setElectableValidators(min: uint256, max: uint256) nonpayable

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

參數

名稱 類型 描述
min uint256 The minimum number of validators that can be elected.
max uint256 The maximum number of validators that can be elected.

回傳值

名稱 類型 描述
bool True upon success.
setMaxNumGroupsVotedFor(_maxNumGroupsVotedFor: uint256) nonpayable

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

參數

名稱 類型 描述
_maxNumGroupsVotedFor uint256 The maximum number of groups an account can vote for.

回傳值

名稱 類型 描述
bool True upon success.
setRegistry(registryAddress: address) nonpayable

Updates the address pointing to a Registry contract.

參數

名稱 類型 描述
registryAddress address The address of a registry contract for routing to other contracts.
transferOwnership(newOwner: address) nonpayable

Transfers ownership of the contract to the specified new owner address.✨ AI

開發者: Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.

參數

名稱 類型 描述
newOwner address Address that will become the new owner of the contract.✨ AI
updateTotalVotesByAccountForGroup(account: address, group: address) nonpayable

Counts and caches account's votes for group.

參數

名稱 類型 描述
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`.

開發者: Fails if `group` is empty or not a validator group.

參數

名稱 類型 描述
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.

回傳值

名稱 類型 描述
bool True upon success.

事件

AllowedToVoteOverMaxNumberOfGroups(account: address, flag: bool)
名稱 類型 已索引 描述
account address
flag bool
BlockedBySet(_blockedBy: address)
名稱 類型 已索引 描述
_blockedBy address
ElectabilityThresholdSet(electabilityThreshold: uint256)
名稱 類型 已索引 描述
electabilityThreshold uint256
ElectableValidatorsSet(min: uint256, max: uint256)
名稱 類型 已索引 描述
min uint256
max uint256
EpochRewardsDistributedToVoters(group: address, value: uint256)
名稱 類型 已索引 描述
group address
value uint256
MaxNumGroupsVotedForSet(maxNumGroupsVotedFor: uint256)
名稱 類型 已索引 描述
maxNumGroupsVotedFor uint256
OwnershipTransferred(previousOwner: address, newOwner: address)
名稱 類型 已索引 描述
previousOwner address
newOwner address
RegistrySet(registryAddress: address)
名稱 類型 已索引 描述
registryAddress address
ValidatorGroupActiveVoteRevoked(account: address, group: address, value: uint256, units: uint256)
名稱 類型 已索引 描述
account address
group address
value uint256
units uint256
ValidatorGroupMarkedEligible(group: address)
名稱 類型 已索引 描述
group address
ValidatorGroupMarkedIneligible(group: address)
名稱 類型 已索引 描述
group address
ValidatorGroupPendingVoteRevoked(account: address, group: address, value: uint256)
名稱 類型 已索引 描述
account address
group address
value uint256
ValidatorGroupVoteActivated(account: address, group: address, value: uint256, units: uint256)
名稱 類型 已索引 描述
account address
group address
value uint256
units uint256
ValidatorGroupVoteCast(account: address, group: address, value: uint256)
名稱 類型 已索引 描述
account address
group address
value uint256