# Get Receipt

The `getReceipt` function retrieves the ballot receipt for a specific voter in relation to a particular governance proposal. This function enables governance participants and developers to track and verify voting activity, ensuring transparency in the decision-making process.

#### Function Implementation in `CHNGovernance`

The `getReceipt()` function is implemented in the `CHNGovernance` contract to return structured voting details for a given voter’s participation in a proposal.

#### Function Signature

{% code overflow="wrap" %}

```
function getReceipt(uint proposalId, address voter) public view returns (Receipt memory)
```

{% endcode %}

#### Parameters

* `proposalId`: The unique identifier of the governance proposal being queried.
* `voter`: The Ethereum address of the voter whose receipt is requested.
* `RETURN:` If the function call is successful, it returns a Receipt struct, containing:
  * `hasVoted` (bool): Indicates whether the voter has already cast a vote.
  * `support` (uint): Represents the type of vote cast (e.g., For, Against, Abstain).
  * `votes` (uint): The number of votes the voter allocated to the proposal.

If the proposal ID is invalid, or the voter has not participated, the function reverts with an error.

#### Example Solidity Implementation

To retrieve a voter's ballot receipt using Solidity, the `getReceipt()` function can be called from an instance of the CHNGovernance contract:

```
CHNGovernance gov = CHNGovernance(0x123...); // Contract address of CHNGovernance
Receipt memory ballot = gov.getReceipt(proposalId, voterAddress);
```

#### Web3.js Implementation (v1.2.6)

For interacting with the `CHNGovernance` contract using Web3.js, the following example demonstrates how to retrieve a voter's receipt:

```javascript
const proposalId = 11;
const voterAddress = '0x123...';
const result = await gov.methods.getReceipt(proposalId, voterAddress).call();
const { hasVoted, support, votes } = result;
```

#### Technical Considerations

* The `getReceipt()` function is a view function, meaning it does not modify blockchain state and can be executed without incurring gas costs.
* If the voter has not participated in the proposal, the function may return a default empty receipt or revert with an error.
* This function is useful for governance dashboards, allowing stakeholders to track who voted, how they voted, and how many votes were cast.
* Governance analytics tools should integrate this function to provide real-time voting insights.


---

# 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/get-receipt.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.
