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:
- Stellar developer docs
- EffectResponse for effect data structures
-
getEffects(from:Asynchronousorder: limit: ) 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.
Declaration
Swift
open func getEffects(from cursor: String? = nil, order: Order? = nil, limit: Int? = nil) async -> PageResponse<EffectResponse>.ResponseEnumParameters
cursorOptional paging token, specifying where to start returning records from
orderOptional sort order - .ascending or .descending
limitOptional maximum number of records to return. Default: 10, max: 200
Return Value
PageResponse containing effects or error
-
getEffects(forAccount:Asynchronousfrom: order: limit: ) Retrieves all effects that changed a specific account with pagination support.
Returns relevant effects from the creation of the account to the current ledger.
Declaration
Swift
open func getEffects(forAccount accountId: String, from cursor: String? = nil, order: Order? = nil, limit: Int? = nil) async -> PageResponse<EffectResponse>.ResponseEnumParameters
accountIdThe Stellar account ID
cursorOptional paging token, specifying where to start returning records from
orderOptional sort order - .ascending or .descending
limitOptional maximum number of records to return. Default: 10, max: 200
Return Value
PageResponse containing effects for the account or error
-
getEffects(forLedger:Asynchronousfrom: order: limit: ) 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.
Declaration
Swift
open func getEffects(forLedger ledger: String, from cursor: String? = nil, order: Order? = nil, limit: Int? = nil) async -> PageResponse<EffectResponse>.ResponseEnumParameters
ledgerThe Stellar ledger sequence number
cursorOptional paging token, specifying where to start returning records from
orderOptional sort order - .ascending or .descending
limitOptional maximum number of records to return. Default: 10, max: 200
Return Value
PageResponse containing effects for the ledger or error
-
getEffects(forOperation:Asynchronousfrom: order: limit: ) 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.
Declaration
Swift
open func getEffects(forOperation operation: String, from cursor: String? = nil, order: Order? = nil, limit: Int? = nil) async -> PageResponse<EffectResponse>.ResponseEnumParameters
operationThe Stellar operation ID
cursorOptional paging token, specifying where to start returning records from
orderOptional sort order - .ascending or .descending
limitOptional maximum number of records to return. Default: 10, max: 200
Return Value
PageResponse containing effects for the operation or error
-
getEffects(forTransaction:Asynchronousfrom: order: limit: ) 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.
Declaration
Swift
open func getEffects(forTransaction hash: String, from cursor: String? = nil, order: Order? = nil, limit: Int? = nil) async -> PageResponse<EffectResponse>.ResponseEnumParameters
hashThe transaction hash (hex-encoded)
cursorOptional paging token, specifying where to start returning records from
orderOptional sort order - .ascending or .descending
limitOptional maximum number of records to return. Default: 10, max: 200
Return Value
PageResponse containing effects for the transaction or error
-
getEffects(forLiquidityPool:Asynchronousfrom: order: limit: ) 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>.ResponseEnumParameters
liquidityPoolIdThe liquidity pool ID (L-address or hex format)
cursorOptional paging token, specifying where to start returning records from
orderOptional sort order - .ascending or .descending
limitOptional 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) -> EffectsStreamItemParameters
transactionsTypeThe filter specifying which effects to stream (all, by account, ledger, operation, transaction, or liquidity pool)
Return Value
EffectsStreamItem for receiving streaming effect updates
-
getEffectsFromUrl(url:Asynchronous) Loads effects from a specific URL for pagination.
Declaration
Swift
open func getEffectsFromUrl(url: String) async -> PageResponse<EffectResponse>.ResponseEnumParameters
urlThe complete URL to fetch effects from (typically from PageResponse links)
Return Value
PageResponse containing effects or error
View on GitHub
Install in Dash