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:

  • 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>.ResponseEnum

    Parameters

    cursor

    Optional cursor for pagination continuation

    order

    Optional sort order (ascending or descending by ledger sequence)

    limit

    Optional maximum number of records to return (default 10, max 200)

    Return Value

    PageResponse containing transaction records or error

  • 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>.ResponseEnum

    Parameters

    accountId

    The Stellar account ID to query transactions for

    cursor

    Optional cursor for pagination continuation

    order

    Optional sort order (ascending or descending by ledger sequence)

    limit

    Optional 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>.ResponseEnum

    Parameters

    claimableBalanceId

    The claimable balance ID (hex or B-prefixed format, auto-decoded)

    cursor

    Optional cursor for pagination continuation

    order

    Optional sort order (ascending or descending by ledger sequence)

    limit

    Optional maximum number of records to return (default 10, max 200)

    Return Value

    PageResponse containing transaction records or error

  • 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>.ResponseEnum

    Parameters

    liquidityPoolId

    The liquidity pool ID (hex or L-prefixed format, auto-decoded)

    cursor

    Optional cursor for pagination continuation

    order

    Optional sort order (ascending or descending by ledger sequence)

    limit

    Optional maximum number of records to return (default 10, max 200)

    Return Value

    PageResponse containing transaction records or error

  • 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>.ResponseEnum

    Parameters

    ledger

    The ledger sequence number or “latest” for the most recent ledger

    cursor

    Optional cursor for pagination continuation

    order

    Optional sort order (ascending or descending by ledger sequence)

    limit

    Optional maximum number of records to return (default 10, max 200)

    Return Value

    PageResponse containing transaction records or error

  • Retrieves detailed information for a specific transaction by hash.

    Declaration

    Swift

    open func getTransactionDetails(transactionHash: String) async -> TransactionDetailsResponseEnum

    Parameters

    transactionHash

    The 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 -> TransactionPostResponseEnum

    Parameters

    transaction

    The signed transaction to submit

    skipMemoRequiredCheck

    Set 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 -> TransactionPostAsyncResponseEnum

    Parameters

    transaction

    The signed transaction to submit

    skipMemoRequiredCheck

    Set 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 to replace an existing transaction with higher fees.

    Declaration

    Swift

    open func submitFeeBumpTransaction(transaction: FeeBumpTransaction) async -> TransactionPostResponseEnum

    Parameters

    transaction

    The signed fee-bump transaction to submit

    Return Value

    TransactionPostResponseEnum with submission result or error

  • Submits a fee-bump transaction asynchronously, returning immediately after validation.

    Declaration

    Swift

    open func submitFeeBumpAsyncTransaction(transaction: FeeBumpTransaction) async -> TransactionPostAsyncResponseEnum

    Parameters

    transaction

    The signed fee-bump transaction to submit

    Return Value

    TransactionPostAsyncResponseEnum with async submission result or error

  • Posts a transaction envelope directly to Horizon with optional SEP-29 memo validation.

    Declaration

    Swift

    open func postTransaction(transactionEnvelope: String, skipMemoRequiredCheck: Bool = false) async -> TransactionPostResponseEnum

    Parameters

    transactionEnvelope

    The base64-encoded transaction envelope XDR

    skipMemoRequiredCheck

    Set 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.

    Declaration

    Swift

    open func postTransactionAsync(transactionEnvelope: String, skipMemoRequiredCheck: Bool = false) async -> TransactionPostAsyncResponseEnum

    Parameters

    transactionEnvelope

    The base64-encoded transaction envelope XDR

    skipMemoRequiredCheck

    Set 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) -> TransactionsStreamItem

    Parameters

    transactionsType

    The filter specifying which transactions to stream (all, by account, claimable balance, or ledger)

    Return Value

    TransactionsStreamItem for receiving streaming transaction updates

  • 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>.ResponseEnum

    Parameters

    url

    The complete Horizon URL to fetch transactions from

    Return Value

    PageResponse containing transaction records or error