postPoolTransaction function

Future<Response?> postPoolTransaction(
  1. Map<String, dynamic> transaction
)

POST request to the /transaction-pool endpoint. Sends an L2 transaction to the network @param {object} transaction - Transaction data returned by TxUtils.generateL2Transaction @returns {string} Transaction id

Implementation

Future<http.Response?> postPoolTransaction(
    Map<String, dynamic> transaction) async {
  Set<String> nextForgerUrls = await getNextForgerUrls();
  Set<String> forgerUrls = getForgerUrls(nextForgerUrls);
  Set<http.Response?> responsesArray = Set();
  for (String apiUrl in forgerUrls) {
    http.Response? response =
        await post(apiUrl, TRANSACTIONS_POOL_URL, body: transaction);
    responsesArray.add(response);
  }
  return filterResponses(responsesArray);
}