Get Action

View the actions of a proposal.

The getActions function retrieves the details of a specified proposal by providing its unique proposal ID. This function allows governance participants and developers to inspect the actions of a given proposal, including:

  1. The contract addresses that the proposal intends to call.

  2. The values (ETH amounts) associated with each call.

  3. The function signatures that define which contract functions will be executed.

  4. The calldata payloads that encode function arguments for execution.

This function enables transparent governance by allowing any participant to review a proposal’s execution details before casting votes or executing the proposal.

Function Implementation in CHNGovernance

The getActions() function is implemented in the CHNGovernance contract to return a structured breakdown of the proposal's execution plan.

Function Signature

function getActions(uint proposalId)
    public
    view
    returns (
        address[] memory targets,
        uint[] memory values,
        string[] memory signatures,
        bytes[] memory calldatas
    )

Parameters

  • proposalId: The unique identifier of the proposal whose actions need to be retrieved.

  • RETURN:If the function call is successful, it returns the following arrays:

  1. targets[]: An array of contract addresses the proposal intends to interact with.

  2. values[]: An array of unsigned integers specifying the ETH value associated with each action.

  3. signatures[]: An array of function signatures that describe the functions to be executed.

  4. calldatas[]: An array of calldata (encoded function arguments) that will be passed to each function call.

If the proposal ID is invalid, the function reverts with an error.

Example Solidity Implementation

To retrieve the details of a proposal using Solidity, the getActions() function can be called from an instance of the CHNGovernance contract:

CHNGovernance gov = CHNGovernance(0x123...); // Contract address of CHNGovernance
uint proposalId = 123;
(address[] memory targets, uint[] memory values, string[] memory signatures, bytes[] memory calldatas) = gov.getActions(proposalId);

Web3.js Implementation (v1.2.6)

For interacting with the CHNGovernance contract using Web3.js, the following example demonstrates how to retrieve the proposal actions:

const proposalId = 123;
const {0: targets, 1: values, 2: signatures, 3: calldatas} = await gov.methods.getActions(proposalId).call();

Technical Considerations

  • The getActions() function is a view function, meaning it does not modify blockchain state and can be executed without incurring gas costs.

  • This function is useful for off-chain governance interfaces, allowing participants to inspect proposals before voting.

  • If a proposal ID is invalid, the function will revert, ensuring that only valid proposals are queried.

  • Governance dashboards and analysis tools should utilize this function to display proposal details in an understandable format.

Last updated