# Proposal State

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`

The `state()` function ensures that governance participants can query and verify the status of proposals, maintaining transparency in decision-making.

#### Function Signature

```
function state(uint proposalId) public view returns (ProposalState)
```

**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:

```

CHNGovernance gov = CHNGovernance(0x123...); // Contract address of CHNGovernance
CHNGovernance.ProposalState proposalState = gov.state(123);
```

#### 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:

{% code overflow="wrap" %}

```javascript
const proposalStates = ['Pending', 'Active', 'Canceled', 'Defeated', 'Succeeded', 'Queued', 'Expired', 'Executed'];
const proposalId = 123;
const result = await gov.methods.state(proposalId).call();
const proposalState = proposalStates[result];
```

{% endcode %}

#### 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.


---

# 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/proposal-state.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.
