Skip to main content

x/async

Overview

The IAsync.sol precompile enables EVM smart contracts to interact with the x/async 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/async.

Code

You can find the x/async precomile code on GitHub: IAsync.sol

Precompile address

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

0x0000000000000000000000000000000000000903

Tasks

Create a new Task

  • Method: addFuture()
  • Description: Creates a Task. Emits the CreateFuture event.
  • Parameters :
    @param handler The unique name of the plugin
    @param input The plugin's input
    @param callback The address of callback contract
    Notes:
    • The following Plugins are currently available: pricepred, http. To learn more, see x/async: Plugins.
    • The callback parameter is optional. The callback contract must have a cb() function, allowing it to be invoked once the Task is ready.
  • Output:
    @return futureId The id of the task
  • Usage example: Create a new Task

Query Tasks

  • Method: futures()
  • Description: Returns a list of all Tasks in all states (including pending ones). See the FuturesResponse struct.
  • Parameters :
    @param pagination The pagination details
    @param creator Optional creator address filter
    @return response The paged tasks
  • Output:
    @return response The paged tasks
  • Usage example: Query Tasks

Query pending Tasks

  • Method: pendingFutures()
  • Description: Returns a list of all pending Tasks. See the PendingFuturesResponse struct.
  • Parameters :
    @param pagination The pagination details  
  • Output:
    @return response The paged tasks
  • Usage example: Query pending Tasks

Query a Task by ID

  • Method: futureById()
  • Description: Returns a Task by ID (pending Tasks included). See the FutureByIdResponse struct.
  • Parameters :
    @param futureId The task id   
  • Output:
    @return response The task response
  • Usage example: Query a Task by ID

Structs

Future

  • Description: A struct representing a Task.
uint64 id;
address creator;
string handler;
bytes input;

FutureVote

  • Description: A struct representing a vote on the results of a Task. Includes the FutureVoteType enum.
uint64 futureId;
bytes Voter;
FutureVoteType vote;

FutureResult

  • Description: A struct representing the result of a Task.
uint64 id;
bytes output;
bytes submitter;

FutureResponse

Future future;
FutureVote[] votes;
FutureResult result;

FuturesResponse

Types.PageResponse pagination;
FutureResponse[] futures;

PendingFuturesResponse

Types.PageResponse pagination;
Future[] futures;

FutureByIdResponse

FutureResponse futureResponse;

Enums

FutureVoteType

  • Description: The Task vote type.
Unspecified,
Verified,
Rejected

Events

CreateFuture

  • Description: An event emitted when a Task is created.
  • Parameters:
    uint64 indexed futureId,
    address indexed creator,
    string handler,
    address callbackAddress