Skip to main content

x/act

Overview

The IAct.sol precompile enables EVM smart contracts to interact with the x/act module.

In this article, you'll find a full list of available methods, allowing you to query and manage the following components:

To learn how to use this precompile, refer to Interact with x/act.

Code

You can find the x/act precomile code on GitHub: IAct.sol

Precompile address

To reference the IAct precompile in your code, use the following precompile address:

0x0000000000000000000000000000000000000901

Rules

Create a new Rule

  • Method: newTemplate()

  • Description: Creates a new Rule (template). Emits the CreateTemplate event.

  • Code:

    function newTemplate(
    string calldata name,
    string calldata definition
    ) external returns (uint64);
  • Parameters:

    @param name The template name
    @param definition The template definition
  • Output:

    @return template id
  • Usage example: Create a new Space

Update a Rule

  • Method: updateTemplate()
  • Description: Updates a Rule (template). Emits the UpdateTemplate event.
  • Code:
    function updateTemplate(
    uint64 templateId,
    string calldata name,
    string calldata definition
    ) external returns (bool);
  • Parameters:
    @param templateId The id of the template
    @param name The template name
    @param definition The template definition
  • Output:
    @return true If execution was successful
  • Usage example: Create a new Space

Query Rules

  • Method: templates()
  • Description: Returns a list of all Rules (templates). See the TemplatesResponse struct.
  • Code:
    function templates(
    Types.PageRequest calldata pagination,
    address creator
    ) external view returns (TemplatesResponse memory response);
  • Parameters:
    @param pagination The pagination details
    @param creator The template creator
  • Output:
    @return response The paged templates
  • Usage example: Create a new Space

Query a Rule by ID

  • Method: templateById()
  • Description: Returns a Rule (template) by ID. See the TemplateByIdResponse struct.
  • Code:
    function templateById(
    uint64 templateId
    ) external view returns (TemplateByIdResponse memory response);
  • Parameters:
    @param templateId The id of the template
  • Output:
    @return response The template
  • Usage example: Create a new Space

Actions

Vote for an Action

  • Method: voteForAction()
  • Description: Votes for an Action. Emits the ActionVoted event, returns ActionStatus.
  • Code:
    function voteForAction(
    uint64 actionId,
    VoteType voteType
    ) external returns (string memory);
  • Parameters:
    @param actionId The id of the action
    @param voteType The type of the vote
  • Output:
    @return action status
  • Usage example: Create a new Space

Revoke an Action

  • Method: revokeAction()
  • Description: Revokes an Action.
  • Code:
    function revokeAction(
    uint64 actionId
    ) external returns (bool);
  • Parameters:
    @param actionId The id of the action
  • Output:
    return true If execution was successful
  • Usage example: Create a new Space

Query Actions

  • Method: actions()
  • Description: Returns a list of all Actions. See the ActionsResponse struct.
  • Code:
    function actions(
    Types.PageRequest calldata pagination
    ) external view returns (ActionsResponse memory response);
  • Parameters:
    @param pagination The pagination details
  • Output:
    @return response The paged actions
  • Usage example: Create a new Space

Query Actions by address

  • Method: actionsByAddress()
  • Description: Returns a list of Actions by participant address—ActionsByAddressResponse. You can filter the output by ActionStatus.
  • Code:
    function actionsByAddress(
    Types.PageRequest calldata pagination,
    address addr,
    ActionStatus status
    ) external view returns (ActionsByAddressResponse memory response);
  • Parameters:
    @param pagination The pagination details
    @param addr The participant address
    @param status The action status
  • Output:
    @return response The paged actions
  • Usage example: Create a new Space

Query an Action by ID

  • Method: actionById()
  • Description: Returns an Action by ID. See the ActionByIdResponse struct.
  • Code:
    function actionById(
    uint64 actionId
    ) external view returns (ActionByIdResponse memory response);
  • Parameters:
    @param actionId The id of the action
  • Output:
    @return response The action
  • Usage example: Create a new Space

Query the Action status by ID

  • Method: checkAction()
  • Description: Returns the status of an Action with a given ID. See the ActionStatus enum.
  • Code:
    function checkAction(
    uint64 actionId
    ) external returns (string memory);
  • Parameters:
    @param actionId The action id
  • Output:
    @return action status
  • Usage example: Create a new Space

Structs

Template

  • Description: A struct representing a Rule (template).
  • Code:
    struct Template {
    uint64 id;
    address creator;
    string name;
    string expression;
    }

TemplatesResponse

  • Description: A response returned when you query Rules. Includes the Template struct.
  • Code:
    struct TemplatesResponse {
    Types.PageResponse pagination;
    Template[] templates;
    }

TemplateByIdResponse

Action

  • Description: A struct representing an Action. Includes the ActionStatus enum.
  • Code:
    struct Action {
    uint64 id;
    ActionStatus status;
    Types.AnyType msg;
    Types.AnyType result;
    address creator;
    uint64 timeoutHeight;
    Types.Timestamp createdAt;
    Types.Timestamp updatedAt;
    string approveExpression;
    string rejectExpression;
    address[] mentions;
    ActionVote[] votes;
    }

ActionsResponse

  • Description: A response returned when you query Actions. Includes the Action struct.
  • Code:
    struct ActionsResponse {
    Types.PageResponse pagination;
    Action[] actions;
    }

ActionsByAddressResponse

  • Description: A response returned when you query an Action by ID. Includes the Action struct.
  • Code:

    struct ActionsByAddressResponse {
    Types.PageResponse pagination;
    Action[] actions;
    }

ActionByIdResponse

Enums

ActionStatus

  • Description: The status of an Action.
  • Code:
    enum ActionStatus {
    Unspecified,
    Pending,
    Completed,
    Revoked,
    Timeout
    }

VoteType

  • Description: The vote type.
  • Code:
    enum VoteType {
    None,
    Approve,
    Reject
    }

Events

CreateTemplate

  • Description: An event emitted when a Rule is created.
  • Code:
    event CreateTemplate(
    address indexed creator,
    uint64 templateId
    );
  • Parameters:
    @param name The template name
    @param definition The template definition

UpdateTemplate

  • Description: An event emitted when a Rule is updated.
  • Code:
    event UpdateTemplate(
    address indexed author,
    uint64 templateId
    );
  • Parameters:
    @param creator The address of the creator
    @param templateId The template id

CreateAction

  • Description: An event emitted when an Action is created.
  • Code:
    event CreateAction(
    address indexed creator,
    uint64 actionId
    );
  • Parameters:
    @param author The address of the author
    @param templateId The template id

ActionStateChange

  • Description: An event emitted when the status of an Action is changed.
  • Code:
    event ActionStateChange(
    address indexed author,
    uint64 actionId,
    ActionStatus previousStatus,
    ActionStatus newStatus
    );
  • Parameters:
    @param author The address of the author
    @param actionId The action Id
    @param previousStatus The previous status of the action
    @param newStatus The new status of the action

ActionVoted

  • Description: An event emitted when an Action is voted on. Includes the VoteType enum.
  • Code:
    event ActionVoted(
    address indexed participant,
    uint64 actionId,
    VoteType voteType
    );
  • Parameters:
    @param participant The address of the participant
    @param actionId The action Id
    @param voteType The type of the vote