EffectsService

public class EffectsService : @unchecked Sendable

Service for querying effects from the Stellar Horizon API.

Effects represent specific changes to the ledger caused by operations. Each operation produces one or more effects. Examples include account created, account credited, trustline created, signer added, etc.

Example usage:

let sdk = StellarSDK()

// Get effects for an account
let response = await sdk.effects.getEffects(
    forAccount: "GACCOUNT...",
    limit: 20
)
switch response {
case .success(let page):
    for effect in page.records {
        print("Effect type: \(effect.effectType)")
        if let credited = effect as? AccountCreditedEffectResponse {
            print("Credited: \(credited.amount)")
        }
    }
case .failure(let error):
    print("Error: \(error)")
}

See also:

  • Retrieves all effects from the Stellar network with pagination support.

    Effects are the specific ways that the ledger was changed by any operation. This function responds with a page of effects. Pages represent a subset of a larger collection of objects to avoid returning millions of records in a single request.

    See: Stellar developer docs

    Declaration

    Swift

    open func getEffects(from cursor: String? = nil, order: Order? = nil, limit: Int? = nil) async -> PageResponse<EffectResponse>.ResponseEnum

    Parameters

    cursor

    Optional paging token, specifying where to start returning records from

    order

    Optional sort order - .ascending or .descending

    limit

    Optional maximum number of records to return. Default: 10, max: 200

    Return Value

    PageResponse containing effects or error

  • Retrieves all effects that changed a specific account with pagination support.

    Returns relevant effects from the creation of the account to the current ledger.

    See: Stellar developer docs

    Declaration

    Swift

    open func getEffects(forAccount accountId: String, from cursor: String? = nil, order: Order? = nil, limit: Int? = nil) async -> PageResponse<EffectResponse>.ResponseEnum

    Parameters

    accountId

    The Stellar account ID

    cursor

    Optional paging token, specifying where to start returning records from

    order

    Optional sort order - .ascending or .descending

    limit

    Optional maximum number of records to return. Default: 10, max: 200

    Return Value

    PageResponse containing effects for the account or error

  • Retrieves all effects that occurred in a specific ledger with pagination support.

    Effects are the specific ways that the ledger was changed by any operation. This function responds with a page of effects. Pages represent a subset of a larger collection of objects to avoid returning millions of records in a single request.

    See: Stellar developer docs

    Declaration

    Swift

    open func getEffects(forLedger ledger: String, from cursor: String? = nil, order: Order? = nil, limit: Int? = nil) async -> PageResponse<EffectResponse>.ResponseEnum

    Parameters

    ledger

    The Stellar ledger sequence number

    cursor

    Optional paging token, specifying where to start returning records from

    order

    Optional sort order - .ascending or .descending

    limit

    Optional maximum number of records to return. Default: 10, max: 200

    Return Value

    PageResponse containing effects for the ledger or error

  • Retrieves all effects that occurred as a result of a specific operation with pagination support.

    This function responds with a page of effects. Pages represent a subset of a larger collection of objects to avoid returning millions of records in a single request.

    See: Stellar developer docs

    Declaration

    Swift

    open func getEffects(forOperation operation: String, from cursor: String? = nil, order: Order? = nil, limit: Int? = nil) async -> PageResponse<EffectResponse>.ResponseEnum

    Parameters

    operation

    The Stellar operation ID

    cursor

    Optional paging token, specifying where to start returning records from

    order

    Optional sort order - .ascending or .descending

    limit

    Optional maximum number of records to return. Default: 10, max: 200

    Return Value

    PageResponse containing effects for the operation or error

  • Retrieves all effects that occurred as a result of a specific transaction with pagination support.

    This function responds with a page of effects. Pages represent a subset of a larger collection of objects to avoid returning millions of records in a single request.

    See: Stellar developer docs

    Declaration

    Swift

    open func getEffects(forTransaction hash: String, from cursor: String? = nil, order: Order? = nil, limit: Int? = nil) async -> PageResponse<EffectResponse>.ResponseEnum

    Parameters

    hash

    The transaction hash (hex-encoded)

    cursor

    Optional paging token, specifying where to start returning records from

    order

    Optional sort order - .ascending or .descending

    limit

    Optional maximum number of records to return. Default: 10, max: 200

    Return Value

    PageResponse containing effects for the transaction or error

  • Retrieves all effects that changed a specific liquidity pool with pagination support.

    Declaration

    Swift

    open func getEffects(forLiquidityPool liquidityPoolId: String, from cursor: String? = nil, order: Order? = nil, limit: Int? = nil) async -> PageResponse<EffectResponse>.ResponseEnum

    Parameters

    liquidityPoolId

    The liquidity pool ID (L-address or hex format)

    cursor

    Optional paging token, specifying where to start returning records from

    order

    Optional sort order - .ascending or .descending

    limit

    Optional maximum number of records to return. Default: 10, max: 200

    Return Value

    PageResponse containing effects for the liquidity pool or error

  • Streams real-time effect updates via Server-Sent Events from Horizon.

    Declaration

    Swift

    open func stream(for transactionsType: EffectsChange) -> EffectsStreamItem

    Parameters

    transactionsType

    The filter specifying which effects to stream (all, by account, ledger, operation, transaction, or liquidity pool)

    Return Value

    EffectsStreamItem for receiving streaming effect updates

  • Loads effects from a specific URL for pagination.

    Declaration

    Swift

    open func getEffectsFromUrl(url: String) async -> PageResponse<EffectResponse>.ResponseEnum

    Parameters

    url

    The complete URL to fetch effects from (typically from PageResponse links)

    Return Value

    PageResponse containing effects or error