Proposal State
Fetching the live status of a governance proposal.
The state function retrieves the current state of a specified governance proposal. The function returns an enumerated value representing one of the possible states defined in the CHNGovernance
contract. This function allows governance participants to track the progress and outcome of any proposal.
Function Implementation in CHNGovernance
CHNGovernance
The state()
function ensures that governance participants can query and verify the status of proposals, maintaining transparency in decision-making.
Function Signature
Parameters
proposalId
: The unique identifier of the proposal whose state is being queried.RETURN
: If the function call is successful, it returns an enumerated type ProposalState, which may have one of the following values:Pending
: The proposal has been submitted and is awaiting the start of the voting period.Active
: The proposal is currently in the voting period.Canceled
: The proposal was canceled before execution.Defeated
: The proposal did not receive enough votes to pass.Succeeded
: The proposal was approved but has not yet been queued for execution.Queued
: The proposal is in the Timelock queue awaiting execution.Expired
: The proposal was approved but was not executed before the expiration period.Executed
: The proposal was successfully executed, and the proposed changes were applied.
Example Solidity Implementation
To retrieve the state of a proposal using Solidity, the state()
function can be called from an instance of the CHNGovernance
contract:
Web3.js Implementation (v1.2.6)
For interacting with the CHNGovernance
contract using Web3.js, the following example demonstrates how to retrieve a proposal’s state:
Technical Considerations
The
state()
function is a view function, meaning it does not modify blockchain state and can be executed without incurring gas costs.The proposal state helps governance participants track where a proposal stands in the decision-making process.
Proposals that expire before execution need to be resubmitted if they are still relevant.
This function is useful for governance dashboards, monitoring tools, and voting interfaces, providing real-time tracking of proposals.
If a proposal ID is invalid, the function reverts with an error.
Last updated