LogoLogo
  • Introduction
    • Chain Info
    • Smart Contracts
    • About Onyx
  • DEVELOPERS
    • Building dApp
    • Estimating Gas
    • Development Framework
    • Web3 Toolkits
    • Onyx SDK
    • Run Full Node
  • GOVERNANCE
    • Overview
    • Governor
    • Security
    • Quorum Votes
    • Proposal Threshold
    • Proposal Max Operations
    • Voting Delay
    • Voting Period
    • Propose
    • Queue
    • Execute
    • Cancel
    • Get Action
    • Get Receipt
    • Proposal State
    • Cast Vote
    • Vote By Signature
    • Timelock
  • Points
    • Onyx Points
    • Earning Points
      • 🟢Passive Points
      • 🔜Activity Points
      • 🔜App Points
  • Whitelisted Assets
  • Onyx AI
    • AI Agent
    • Core Features
    • Wallet Infrastructure
    • 🔜Roadmap
  • API
    • Onyx Governance API
    • Core API Endpoints
    • GET: /proposal
    • GET: /proposal/:proposalId
    • GET: /voter/:proposalId
    • GET: /voter/accounts
    • GET: /voter/history/:address
  • RESOURCES
    • Terms of Service
    • Bug Bounty
Powered by GitBook
On this page
Export as PDF
  1. GOVERNANCE

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.

PreviousExecuteNextGet Action

Last updated 3 months ago