This function fetches a ballot detail for each specific voter based on a specific governance proposal.
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
function getReceipt(uint proposalId, address voter) public view returns (Receipt memory)
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: