ClaimableBalancesService

public class ClaimableBalancesService : @unchecked Sendable

Service for querying claimable balances from the Stellar Horizon API.

Claimable balances allow creating asset transfers that recipients can claim later when specific conditions are met. Useful for implementing payment channels, escrow, and conditional transfers.

Example usage:

let sdk = StellarSDK()

// Get claimable balance details
let response = await sdk.claimableBalances.getClaimableBalanceDetails(
    claimableBalanceId: "00000000..."
)
switch response {
case .success(let balance):
    print("Amount: \(balance.amount)")
    print("Asset: \(balance.asset)")
    for claimant in balance.claimants {
        print("Claimant: \(claimant.destination)")
    }
case .failure(let error):
    print("Error: \(error)")
}

See also:

  • Retrieves detailed information about a specific claimable balance.

    Declaration

    Swift

    open func getClaimableBalance(balanceId: String) async -> ClaimableBalanceDetailsResponseEnum

    Parameters

    balanceId

    The claimable balance ID (hex or B-encoded format)

    Return Value

    ClaimableBalanceDetailsResponseEnum with balance details or error

  • Retrieves claimable balances filtered by asset with pagination support.

    Declaration

    Swift

    open func getClaimableBalances(asset: Asset, cursor: String? = nil, order: Order? = nil, limit: Int? = nil) async -> PageResponse<ClaimableBalanceResponse>.ResponseEnum

    Parameters

    asset

    The asset to filter claimable balances by

    cursor

    Pagination cursor for next page

    order

    Sort order (.ascending or .descending)

    limit

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

    Return Value

    PageResponse containing matching claimable balances or error

  • Retrieves claimable balances that can be claimed by a specific account.

    Declaration

    Swift

    open func getClaimableBalances(claimantAccountId: String, cursor: String? = nil, order: Order? = nil, limit: Int? = nil) async -> PageResponse<ClaimableBalanceResponse>.ResponseEnum

    Parameters

    claimantAccountId

    The account ID that can claim the balances

    cursor

    Pagination cursor for next page

    order

    Sort order (.ascending or .descending)

    limit

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

    Return Value

    PageResponse containing claimable balances for the specified claimant or error

  • Retrieves claimable balances sponsored by a specific account.

    Declaration

    Swift

    open func getClaimableBalances(sponsorAccountId: String, cursor: String? = nil, order: Order? = nil, limit: Int? = nil) async -> PageResponse<ClaimableBalanceResponse>.ResponseEnum

    Parameters

    sponsorAccountId

    The account ID that sponsors the balances

    cursor

    Pagination cursor for next page

    order

    Sort order (.ascending or .descending)

    limit

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

    Return Value

    PageResponse containing sponsored claimable balances or error

  • Loads claimable balances from a specific URL for pagination.

    Declaration

    Swift

    open func getClaimableBalancesFromUrl(url: String) async -> PageResponse<ClaimableBalanceResponse>.ResponseEnum

    Parameters

    url

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

    Return Value

    PageResponse containing claimable balances or error