sendTransaction method

Future<SendTransactionResponse> sendTransaction(
  1. Transaction transaction
)
inherited

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://developers.stellar.org/network/soroban-rpc/api-reference/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);
}