sendTransaction method Null safety
- Transaction transaction
Submit a real transaction to the stellar network. This is the only way to make changes “on-chain”. Unlike Horizon, this does not wait for transaction completion. It simply validates and enqueues the transaction. Clients should call getTransactionStatus to learn about transaction success/failure.
Implementation
Future<SendTransactionResponse> sendTransaction(
Transaction transaction) async {
if (!this.acknowledgeExperimental) {
printExperimentalFlagErr();
return SendTransactionResponse.fromJson(_experimentalErr);
}
String transactionEnvelopeXdr = transaction.toEnvelopeXdrBase64();
JsonRpcMethod getAccount =
JsonRpcMethod("sendTransaction", args: transactionEnvelopeXdr);
dio.Response response = await _dio.post(_serverUrl,
data: json.encode(getAccount), options: dio.Options(headers: _headers));
if (enableLogging) {
print("sendTransaction response: $response");
}
return SendTransactionResponse.fromJson(response.data);
}