broadcastTransaction method

Future<Map> broadcastTransaction(
  1. String encodedTransaction
)

Calls near RPC API's broadcast_tx_commit to broadcast the transaction and waits until transaction is fully complete.

Implementation

Future<Map<dynamic, dynamic>> broadcastTransaction(
    String encodedTransaction) async {
  var body = json.encode({
    "jsonrpc": "2.0",
    "id": "dontcare",
    "method": "broadcast_tx_commit",
    "params": [encodedTransaction]
  });
  Map<String, String> headers = {};
  headers[Constants.contentType] = Constants.applicationJson;

  try {
    http.Response responseData =
        await http.post(Uri.parse(providerURL), headers: headers, body: body);
    Map jsonBody = jsonDecode(responseData.body);
    return jsonBody;
  } catch (exp) {
    return {"EXCEPTION": exp};
  }
}