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:
- Stellar developer docs
- CreateClaimableBalanceOperation for creating claimable balances
-
getClaimableBalance(balanceId:Asynchronous) Retrieves detailed information about a specific claimable balance.
Declaration
Swift
open func getClaimableBalance(balanceId: String) async -> ClaimableBalanceDetailsResponseEnumParameters
balanceIdThe claimable balance ID (hex or B-encoded format)
Return Value
ClaimableBalanceDetailsResponseEnum with balance details or error
-
getClaimableBalances(asset:Asynchronouscursor: order: limit: ) 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>.ResponseEnumParameters
assetThe asset to filter claimable balances by
cursorPagination cursor for next page
orderSort order (.ascending or .descending)
limitMaximum 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>.ResponseEnumParameters
claimantAccountIdThe account ID that can claim the balances
cursorPagination cursor for next page
orderSort order (.ascending or .descending)
limitMaximum 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>.ResponseEnumParameters
sponsorAccountIdThe account ID that sponsors the balances
cursorPagination cursor for next page
orderSort order (.ascending or .descending)
limitMaximum number of records to return (default 10, max 200)
Return Value
PageResponse containing sponsored claimable balances or error
-
getClaimableBalancesFromUrl(url:Asynchronous) Loads claimable balances from a specific URL for pagination.
Declaration
Swift
open func getClaimableBalancesFromUrl(url: String) async -> PageResponse<ClaimableBalanceResponse>.ResponseEnumParameters
urlThe complete URL to fetch balances from (typically from PageResponse links)
Return Value
PageResponse containing claimable balances or error
View on GitHub
Install in Dash