sendTransaction method

Future<SendTransactionResponse> sendTransaction(
  1. 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. This supports all transactions, not only smart contract-related transactions. See: https://soroban.stellar.org/api/methods/sendTransaction

Implementation

Future<SendTransactionResponse> sendTransaction(
    Transaction transaction) async {
  String transactionEnvelopeXdr = transaction.toEnvelopeXdrBase64();

  JsonRpcMethod getAccount = JsonRpcMethod("sendTransaction",
      args: {'transaction': 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);
}