AssetsService
public class AssetsService : @unchecked Sendable
Service for querying asset information from the Stellar Horizon API.
The AssetsService provides methods to retrieve information about all assets issued on the Stellar network, including supply statistics, number of accounts, and issuer details. Can filter by asset code and issuer.
Example usage:
let sdk = StellarSDK()
// Get all assets with code "USD"
let response = await sdk.assets.getAssets(
for: "USD",
limit: 100
)
switch response {
case .success(let page):
for asset in page.records {
print("\(asset.assetCode): \(asset.assetIssuer)")
print("Accounts: \(asset.numAccounts)")
print("Amount: \(asset.amount)")
}
case .failure(let error):
print("Error: \(error)")
}
See also:
- Stellar developer docs
- AssetResponse for asset data structure
-
getAssets(for:AsynchronousassetIssuer: cursor: order: limit: ) This function calls the endpoint that represents all assets. It will give you all the assets in the system along with various statistics about each. See Stellar developer docs
This fuction responds with a page of assets. Pages represent a subset of a larger collection of objects. As an example, it would be unfeasible to provide the All Transactions endpoint without paging. Over time there will be millions of transactions in the Stellar network’s ledger and returning them all over a single request would be unfeasible.
Declaration
Swift
open func getAssets(for assetCode: String? = nil, assetIssuer: String? = nil, cursor: String? = nil, order: Order? = nil, limit: Int? = nil) async -> PageResponse<AssetResponse>.ResponseEnumParameters
assetCodeOptional. Code of the Asset to filter by.
assetIssuerOptional. Issuer of the Asset to filter by.
cursorOptional. A paging token, specifying where to start returning records from.
orderOptional. The order in which to return rows, “asc” or “desc”, ordered by assetCode then by assetIssuer.
limitOptional. Maximum number of records to return. Default: 10
-
getAssetsFromUrl(url:Asynchronous) Loads assets for a given url if valid. E.g. for a “next” link from a PageResponse
object. Declaration
Swift
open func getAssetsFromUrl(url: String) async -> PageResponse<AssetResponse>.ResponseEnumParameters
urlThe url to be used to load the assets.
View on GitHub
Install in Dash