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 :
Notes:
@param handler The unique name of the plugin
@param input The plugin's input
@param callback The address of callback contract- The following Plugins are currently available:
pricepred
,http
. To learn more, seex/async
: Plugins. - The
callback
parameter is optional. The callback contract must have acb()
function, allowing it to be invoked once the Task is ready.
- The following Plugins are currently available:
- 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
- Description: A struct representing a Task and its data. Includes the
Future
,FutureVote
, andFutureResult
structs.
Future future;
FutureVote[] votes;
FutureResult result;
FuturesResponse
- Description: A response returned when you query Task. Includes the
FutureResponse
struct.
Types.PageResponse pagination;
FutureResponse[] futures;
PendingFuturesResponse
- Description: A response returned when you query pending Task. Includes the
Future
struct.
Types.PageResponse pagination;
Future[] futures;
FutureByIdResponse
- Description: A response returned when you query a Task by ID. Includes the
FutureResponse
struct.
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