x/async
Overview
The IAsync
precompile allows calling the x/async
module from EVM smart contracts.
In this article, you'll find a full list of available methods and events. You can use them for querying and managing the following components:
To learn how to use this precompile, refer to Interact with x/async
.
Precompile address
To reference the IAsync
precompile in your code, use the following precompile address:
0x0000000000000000000000000000000000000903
Futures
Create a new Future
- Method:
addFuture()
- Description: Creates a Future. Emits the
CreateFuture
event. - Parameters :
@param handler The unique name of the handler
@param input The handler's input - Output:
@return futureId The id of the future
- Usage example: Create a new Future
Query Futures
- Method:
futures()
- Description: Returns a list of all Futures 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 futures - Output:
@return response The paged futures
- Usage example: Query Futures
Query pending Futures
- Method:
pendingFutures()
- Description: Returns a list of all pending Futures. See the
PendingFuturesResponse
struct. - Parameters :
@param pagination The pagination details
- Output:
@return response The paged futures
- Usage example: Query pending Futures
Query a Future by ID
- Method:
futureById()
- Description: Returns a Future by ID (pending Futures included). See the
FutureByIdResponse
struct. - Parameters :
@param futureId The future id
- Output:
@return response The future response
- Usage example: Query a Future by ID
Structs
Future
- Description: A struct representing a Future.
uint64 id;
address creator;
string handler;
bytes input;
FutureVote
- Description: A struct representing a vote on the results of a Future. Includes the
FutureVoteType
enum.
uint64 futureId;
bytes Voter;
FutureVoteType vote;
FutureResult
- Description: A struct representing the result of a Future.
uint64 id;
bytes output;
bytes submitter;
FutureResponse
- Description: A struct representing a Future and its data. Includes the
Future
,FutureVote
, andFutureResult
structs.
Future future;
FutureVote[] votes;
FutureResult result;
FuturesResponse
- Description: A response returned when you query Futures. Includes the
FutureResponse
struct.
Types.PageResponse pagination;
FutureResponse[] futures;
PendingFuturesResponse
- Description: A response returned when you query pending Futures. Includes the
Future
struct.
Types.PageResponse pagination;
Future[] futures;
FutureByIdResponse
- Description: A response returned when you query a Future by ID. Includes the
FutureResponse
struct.
FutureResponse futureResponse;
Enums
FutureVoteType
- Description: The Future vote type.
Unspecified,
Verified,
Rejected
Events
CreateFuture
- Description: An event emitted when a Future is created.
- Parameters:
@param creator The address of the creator
@param futureId The future Id
@param handler The name of the handler