getEvents method
Clients can request a filtered list of events emitted by a given ledger range. Soroban-RPC will support querying within a maximum 24 hours of recent ledgers. Note, this could be used by the client to only prompt a refresh when there is a new ledger with relevant events. It should also be used by backend Dapp components to "ingest" events into their own database for querying and serving. If making multiple requests, clients should deduplicate any events received, based on the event's unique id field. This prevents double-processing in the case of duplicate events being received. By default soroban-rpc retains the most recent 24 hours of events. See: https://developers.stellar.org/network/soroban-rpc/api-reference/methods/getEvents
Implementation
Future<GetEventsResponse> getEvents(GetEventsRequest request) async {
JsonRpcMethod getEvents =
JsonRpcMethod("getEvents", args: request.getRequestArgs());
dio.Response response = await _dio.post(_serverUrl,
data: json.encode(getEvents), options: dio.Options(headers: _headers));
if (enableLogging) {
print("getEvents response: $response");
}
return GetEventsResponse.fromJson(response.data);
}