Cancel

Cancelling a proposal via onchain interaction.

The cancel() function allows the Guardian or any eligible participant to cancel a governance proposal that has not yet been executed. This mechanism provides a safeguard against malicious or outdated proposals that no longer align with the protocol’s best interests.

A proposal can be canceled under the following conditions:

  • If the Guardian invokes the cancel function, the proposal will be immediately revoked.

  • If the proposer no longer holds the required delegated voting power (i.e., less than the proposal threshold), then any address may call cancel() to remove the proposal from governance consideration.

Function Implementation in CHNGovernance

The cancel() function ensures that only valid, unexecuted proposals can be removed, maintaining governance security and integrity.

Function Signature:

function cancel(uint proposalId) public

Parameters

  • proposalId: The unique identifier of the governance proposal to be canceled. The proposal must not have been executed.

  • RETURN: The function does not return a value. If the proposal is invalid, already executed, or unauthorized for cancellation, the transaction reverts with an error.

Example Solidity Implementation

To cancel a proposal using Solidity, the cancel() function can be called from an instance of the CHNGovernance contract:

CHNGovernance gov = CHNGovernance(0x123...); // Contract address of CHNGovernance
gov.cancel(proposalId);

Web3.js Implementation (v1.2.6)

For interacting with the CHNGovernance contract using Web3.js, the following example demonstrates how to cancel a proposal:

const tx = await gov.methods.cancel(proposalId).send({ from: sender });

Technical Considerations

  • The cancel() function is state-modifying and will incur gas costs.

  • The proposal must not have been executed for it to be eligible for cancellation.

  • If the Guardian initiates cancellation, it is immediately effective.

  • If the proposer loses their delegated voting power, any participant may call cancel() to remove the proposal.

  • If an attempt is made to cancel an already executed proposal, the transaction will revert with an error.

  • The Onyx governance framework ensures that cancellation actions are recorded transparently on-chain.

Last updated