TransactionsService
public class TransactionsService : @unchecked Sendable
Service for querying and submitting transactions on the Stellar network.
The TransactionsService provides methods to retrieve transaction history, submit new transactions to the network, and check SEP-29 memo requirements. Supports both synchronous and asynchronous transaction submission modes.
Example usage:
let sdk = StellarSDK()
// Get transaction details
let txResponse = await sdk.transactions.getTransactionDetails(
transactionHash: "abc123..."
)
// Submit a transaction
let submitResponse = await sdk.transactions.submitTransaction(
transaction: myTransaction
)
switch submitResponse {
case .success(let result):
print("Transaction successful: \(result.hash)")
case .destinationRequiresMemo(let accountId):
print("Destination \(accountId) requires a memo (SEP-29)")
case .failure(let error):
print("Error: \(error)")
}
See also:
-
getTransactions(cursor:Asynchronousorder: limit: ) Retrieves a paginated list of all transactions from Horizon.
Declaration
Swift
open func getTransactions(cursor: String? = nil, order: Order? = nil, limit: Int? = nil) async -> PageResponse<TransactionResponse>.ResponseEnumParameters
cursorOptional cursor for pagination continuation
orderOptional sort order (ascending or descending by ledger sequence)
limitOptional maximum number of records to return (default 10, max 200)
Return Value
PageResponse containing transaction records or error
-
getTransactions(forAccount:Asynchronousfrom: order: limit: ) Retrieves transactions for a specific account.
Declaration
Swift
open func getTransactions(forAccount accountId: String, from cursor: String? = nil, order: Order? = nil, limit: Int? = nil) async -> PageResponse<TransactionResponse>.ResponseEnumParameters
accountIdThe Stellar account ID to query transactions for
cursorOptional cursor for pagination continuation
orderOptional sort order (ascending or descending by ledger sequence)
limitOptional maximum number of records to return (default 10, max 200)
Return Value
PageResponse containing transaction records or error
-
Retrieves transactions for a specific claimable balance.
Declaration
Swift
open func getTransactions(forClaimableBalance claimableBalanceId: String, from cursor: String? = nil, order: Order? = nil, limit: Int? = nil) async -> PageResponse<TransactionResponse>.ResponseEnumParameters
claimableBalanceIdThe claimable balance ID, as a “B…” strkey or as hex in any of its widths
cursorOptional cursor for pagination continuation
orderOptional sort order (ascending or descending by ledger sequence)
limitOptional maximum number of records to return (default 10, max 200)
Return Value
PageResponse containing transaction records, or a badRequest error naming the reason when the id holds none of those spellings
-
getTransactions(forLiquidityPool:Asynchronousfrom: order: limit: ) Retrieves transactions for a specific liquidity pool.
Declaration
Swift
open func getTransactions(forLiquidityPool liquidityPoolId: String, from cursor: String? = nil, order: Order? = nil, limit: Int? = nil) async -> PageResponse<TransactionResponse>.ResponseEnumParameters
liquidityPoolIdThe liquidity pool ID (hex or L-prefixed format, auto-decoded)
cursorOptional cursor for pagination continuation
orderOptional sort order (ascending or descending by ledger sequence)
limitOptional maximum number of records to return (default 10, max 200)
Return Value
PageResponse containing transaction records or error
-
getTransactions(forLedger:Asynchronousfrom: order: limit: ) Retrieves transactions for a specific ledger sequence.
Declaration
Swift
open func getTransactions(forLedger ledger: String, from cursor: String? = nil, order: Order? = nil, limit: Int? = nil) async -> PageResponse<TransactionResponse>.ResponseEnumParameters
ledgerThe ledger sequence number or “latest” for the most recent ledger
cursorOptional cursor for pagination continuation
orderOptional sort order (ascending or descending by ledger sequence)
limitOptional maximum number of records to return (default 10, max 200)
Return Value
PageResponse containing transaction records or error
-
getTransactionDetails(transactionHash:Asynchronous) Retrieves detailed information for a specific transaction by hash.
Declaration
Swift
open func getTransactionDetails(transactionHash: String) async -> TransactionDetailsResponseEnumParameters
transactionHashThe unique transaction hash identifier (hex-encoded)
Return Value
TransactionDetailsResponseEnum with transaction details or error
-
Submits a transaction to the Stellar network with optional SEP-29 memo validation.
Declaration
Swift
open func submitTransaction(transaction: Transaction, skipMemoRequiredCheck: Bool = false) async -> TransactionPostResponseEnumParameters
transactionThe signed transaction to submit
skipMemoRequiredCheckSet to true to bypass SEP-29 memo requirement validation (default: false)
Return Value
TransactionPostResponseEnum with submission result, memo requirement notice, or error
-
Submits a transaction asynchronously, returning immediately after validation.
The transaction is validated and queued but the method returns before ledger inclusion.
Declaration
Swift
open func submitAsyncTransaction(transaction: Transaction, skipMemoRequiredCheck: Bool = false) async -> TransactionPostAsyncResponseEnumParameters
transactionThe signed transaction to submit
skipMemoRequiredCheckSet to true to bypass SEP-29 memo requirement validation (default: false)
Return Value
TransactionPostAsyncResponseEnum with async submission result, memo requirement notice, or error
-
Submits a fee bump transaction, which wraps a signed inner transaction and pays its fee from the fee source account.
The SEP-29 memo requirement check runs against the inner transaction of the encoded envelope, which is the payload that is posted, because the fee bump wrapper carries neither a memo nor operations.
Declaration
Swift
open func submitFeeBumpTransaction(transaction: FeeBumpTransaction, skipMemoRequiredCheck: Bool = false) async -> TransactionPostResponseEnumParameters
transactionThe signed fee-bump transaction to submit
skipMemoRequiredCheckSet to true to bypass SEP-29 memo requirement validation (default: false)
Return Value
TransactionPostResponseEnum with submission result, memo requirement notice, or error
-
Submits a fee bump transaction asynchronously, returning immediately after validation.
The SEP-29 memo requirement check runs against the inner transaction of the encoded envelope, which is the payload that is posted, because the fee bump wrapper carries neither a memo nor operations.
Declaration
Swift
open func submitFeeBumpAsyncTransaction(transaction: FeeBumpTransaction, skipMemoRequiredCheck: Bool = false) async -> TransactionPostAsyncResponseEnumParameters
transactionThe signed fee-bump transaction to submit
skipMemoRequiredCheckSet to true to bypass SEP-29 memo requirement validation (default: false)
Return Value
TransactionPostAsyncResponseEnum with async submission result, memo requirement notice, or error
-
Posts a transaction envelope directly to Horizon with optional SEP-29 memo validation.
A fee bump envelope is checked against its inner transaction. An envelope that cannot be parsed is submitted without the check and left to Horizon’s validation.
Declaration
Swift
open func postTransaction(transactionEnvelope: String, skipMemoRequiredCheck: Bool = false) async -> TransactionPostResponseEnumParameters
transactionEnvelopeThe base64-encoded transaction envelope XDR
skipMemoRequiredCheckSet to true to bypass SEP-29 memo requirement validation (default: false)
Return Value
TransactionPostResponseEnum with submission result, memo requirement notice, or error
-
Posts a transaction envelope asynchronously, returning immediately after validation.
A fee bump envelope is checked against its inner transaction. An envelope that cannot be parsed is submitted without the check and left to Horizon’s validation.
Declaration
Swift
open func postTransactionAsync(transactionEnvelope: String, skipMemoRequiredCheck: Bool = false) async -> TransactionPostAsyncResponseEnumParameters
transactionEnvelopeThe base64-encoded transaction envelope XDR
skipMemoRequiredCheckSet to true to bypass SEP-29 memo requirement validation (default: false)
Return Value
TransactionPostAsyncResponseEnum with async submission result, memo requirement notice, or error
-
Streams real-time transaction updates via Server-Sent Events from Horizon.
Declaration
Swift
open func stream(for transactionsType: TransactionsChange) -> TransactionsStreamItemParameters
transactionsTypeThe filter specifying which transactions to stream (all, by account, claimable balance, or ledger)
Return Value
TransactionsStreamItem for receiving streaming transaction updates
-
getTransactionsFromUrl(url:Asynchronous) Retrieves transactions from a complete Horizon URL.
Useful for pagination navigation with “next” or “prev” links from a PageResponse.
Declaration
Swift
open func getTransactionsFromUrl(url: String) async -> PageResponse<TransactionResponse>.ResponseEnumParameters
urlThe complete Horizon URL to fetch transactions from
Return Value
PageResponse containing transaction records or error
View on GitHub
Install in Dash