Keyboard shortcuts

Press or to navigate between chapters

Press ? to show this help

Press Esc to hide this help

VotingUnitsTrait

A trait that must be implemented when integrating {VotesComponent} into a contract. It offers a mechanism to retrieve the number of voting units for a given account at the current time.

Fully qualified path: openzeppelin_governance::votes::votes::VotesComponent::VotingUnitsTrait

pub trait VotingUnitsTrait<TState>

Trait functions

get_voting_units

Returns the number of voting units for a given account. For ERC20, this is typically the token balance. For ERC721, this is typically the number of tokens owned.

WARNING: While any formula can be used as a measure of voting units, the internal vote accounting of the contract may be compromised if voting units are transferred in any external flow by following a different formula. For example, when implementing the hook for ERC20, the number of voting units transferred should match the formula given by the get_voting_units implementation.

Fully qualified path: openzeppelin_governance::votes::votes::VotesComponent::VotingUnitsTrait::get_voting_units

fn get_voting_units(self: @TState, account: ContractAddress) -> u256