Skip to main content

IERC20Votes

Asset Tokenization Studio Team

IERC20Votes

Interface for the ERC-20 Votes extension that enables on-chain governance delegation and checkpoint-based vote tracking.

Methods​

CLOCK_MODE​

function CLOCK_MODE() external view returns (string)

Description of the clock

Returns​

NameTypeDescription
_0stringundefined

checkpoints​

function checkpoints(address _account, uint256 _pos) external view returns (struct Checkpoints.Checkpoint)

Returns the checkpoint at a given position for an account's vote history.

Parameters​

NameTypeDescription
_accountaddressAddress whose checkpoint history is queried.
_posuint256Zero-based index into the account's checkpoint array.

Returns​

NameTypeDescription
_0Checkpoints.CheckpointThe checkpoint struct at the given position.

clock​

function clock() external view returns (uint48)

Clock used for flagging checkpoints. Can be overridden to implement timestamp based checkpoints (and voting).

Returns​

NameTypeDescription
_0uint48undefined

delegate​

function delegate(address _delegatee) external nonpayable

Delegates the caller's voting power to delegatee.

Delegates votes from the sender to delegatee.

Parameters​

NameTypeDescription
_delegateeaddressAddress that will receive the caller's voting power.

delegates​

function delegates(address _account) external view returns (address)

Returns the delegate address that account has chosen.

Returns the delegate that account has chosen.

Parameters​

NameTypeDescription
_accountaddressAddress whose chosen delegate is queried.

Returns​

NameTypeDescription
_0addressAddress of the delegate chosen by account.

getPastTotalSupply​

function getPastTotalSupply(uint256 _timepoint) external view returns (uint256)

Returns the total vote supply available at a past timepoint.

Returns the total supply of votes available at a specific moment in the past. If the clock() is configured to use block numbers, this will return the value at the end of the corresponding block. NOTE: This value is the sum of all available votes, which is not necessarily the sum of all delegated votes. Votes that have not been delegated are still part of total supply, even though they would not participate in a vote.

Parameters​

NameTypeDescription
_timepointuint256Block number or timestamp at which the total supply is resolved.

Returns​

NameTypeDescription
_0uint256Total vote supply at timepoint.

getPastVotes​

function getPastVotes(address _account, uint256 _timepoint) external view returns (uint256)

Returns the vote weight of account at a past timepoint.

Returns the amount of votes that account had at a specific moment in the past. If the clock() is configured to use block numbers, this will return the value at the end of the corresponding block.

Parameters​

NameTypeDescription
_accountaddressAddress whose historical vote weight is queried.
_timepointuint256Block number or timestamp at which the weight is resolved.

Returns​

NameTypeDescription
_0uint256Vote weight of account at timepoint.

getVotes​

function getVotes(address _account) external view returns (uint256)

Returns the current vote weight of account.

Returns the current amount of votes that account has.

Parameters​

NameTypeDescription
_accountaddressAddress whose current vote weight is queried.

Returns​

NameTypeDescription
_0uint256Current vote weight of account.

initializeERC20Votes​

function initializeERC20Votes(bool _activated) external nonpayable

Initialises the ERC-20Votes capability on the token.

Parameters​

NameTypeDescription
_activatedboolWhether the voting feature should be active after initialisation.

isActivated​

function isActivated() external view returns (bool)

Returns whether the ERC-20Votes voting feature is currently active.

Returns​

NameTypeDescription
_0boolTrue if the voting feature is active, false otherwise.

numCheckpoints​

function numCheckpoints(address _account) external view returns (uint256)

Returns the total number of vote checkpoints recorded for an account.

Parameters​

NameTypeDescription
_accountaddressAddress whose checkpoint count is queried.

Returns​

NameTypeDescription
_0uint256The number of checkpoints stored for the account.

Events​

DelegateChanged​

event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate)

Emitted when an account changes their delegate

Parameters​

NameTypeDescription
delegator indexedaddressThe account that changed their delegation
fromDelegate indexedaddressThe previous delegate address
toDelegate indexedaddressThe new delegate address

DelegateVotesChanged​

event DelegateVotesChanged(address indexed delegate, uint256 previousBalance, uint256 newBalance)

Emitted when delegate votes change due to balance changes

Parameters​

NameTypeDescription
delegate indexedaddressThe delegate whose votes changed
previousBalanceuint256The previous vote balance
newBalanceuint256The new vote balance

ERC20VotesInitialized​

event ERC20VotesInitialized(bool activated)

Emitted once when the ERC-20Votes capability is initialised on a token.

Fires exclusively from initializeERC20Votes after the storage write succeeds.

Parameters​

NameTypeDescription
activatedboolWhether the ERC-20Votes feature is active after initialisation.

Errors​

AbafChangeForBlockForbidden​

error AbafChangeForBlockForbidden(uint256 blockNumber)

Raised when attempting to change ABAF for a block that is forbidden

Parameters​

NameTypeDescription
blockNumberuint256The block number that is forbidden

BrokenClockMode​

error BrokenClockMode()

Raised when the clock mode is broken

FutureLookup​

error FutureLookup(uint256 timepoint, uint256 currentClock)

Raised when querying past votes or supply with a future timepoint

Parameters​

NameTypeDescription
timepointuint256The requested future timepoint
currentClockuint256The current clock value