# Cancel

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:

```javascript
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.

<br>

<br>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.onyx.org/governance/cancel.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
