StellarToml
public final class StellarToml : Sendable
Implements SEP-0001 - stellar.toml Discovery and Configuration.
This class parses and provides access to a domain’s stellar.toml file, which contains configuration and metadata about a Stellar integration. The stellar.toml file enables automatic discovery of services, validator nodes, asset information, and contact details.
SEP-0001 is foundational for the Stellar ecosystem, allowing wallets and applications to discover anchor services, validator information, and asset metadata from a domain.
Typical Usage
// Fetch stellar.toml from a domain
let result = await StellarToml.from(domain: "testanchor.stellar.org")
switch result {
case .success(let toml):
// Access account information
if let webAuthEndpoint = toml.accountInformation.webAuthEndpoint {
print("SEP-10 endpoint: \(webAuthEndpoint)")
}
// Access supported currencies
for currency in toml.currenciesDocumentation {
print("Asset: \(currency.code ?? ""), Issuer: \(currency.issuer ?? "")")
}
// Access transfer server
if let transferServer = toml.accountInformation.transferServer {
print("SEP-6 server: \(transferServer)")
}
case .failure(let error):
print("Error: \(error)")
}
Available Information
- Account Information: Service endpoints (SEP-6, SEP-10, SEP-12, SEP-24, SEP-31, SEP-38)
- Issuer Documentation: Organization details, contact information
- Currencies: Supported assets with metadata and regulatory info
- Validators: Validator node information for network operators
- Points of Contact: Key personnel and support contacts
See also:
- SEP-0001 Specification
- Supported version: 2.7.0
-
Service endpoints and signing keys from the stellar.toml ACCOUNT section.
Declaration
Swift
public let accountInformation: AccountInformation -
Organization and issuer metadata from the stellar.toml DOCUMENTATION section.
Declaration
Swift
public let issuerDocumentation: IssuerDocumentation -
Key personnel and support contact information from the stellar.toml PRINCIPALS section.
Declaration
Swift
public let pointsOfContact: [PointOfContactDocumentation] -
Supported asset definitions and metadata from the stellar.toml CURRENCIES section.
Declaration
Swift
public let currenciesDocumentation: [CurrencyDocumentation] -
Validator node configuration and history archives from the stellar.toml VALIDATORS section.
Declaration
Swift
public let validatorsInformation: [ValidatorInformation] -
Creates a StellarToml instance by parsing a TOML string.
Throws
TomlFileError.invalidTomlif the string is invalid or cannot be parsedDeclaration
Swift
public init(fromString string: String) throwsParameters
stringA string containing the stellar.toml content
-
from(domain:Asynchronoussecure: ) Loads and parses stellar.toml file from a domain per SEP-0001.
Fetches the stellar.toml file from
https://{domain}/.well-known/stellar.toml(orhttp://if secure is false) and parses its contents.Declaration
Swift
public static func from(domain: String, secure: Bool = true) async -> TomlForDomainEnumParameters
domainThe domain without scheme (e.g., “example.com”)
secureIf true, uses HTTPS to fetch stellar.toml (default: true)
Return Value
TomlForDomainEnum with the parsed StellarToml or an error
-
currencyFrom(url:Asynchronous) Loads currency information from a linked TOML file URL.
Per SEP-0001, a stellar.toml can link to separate TOML files for individual currencies by specifying
toml="https://DOMAIN/.well-known/CURRENCY.toml"as the currency’s only field.Declaration
Swift
public static func currencyFrom(url: String) async -> TomlCurrencyFromUrlEnumParameters
urlThe complete URL to the currency TOML file
Return Value
TomlCurrencyFromUrlEnum with the parsed CurrencyDocumentation or an error
View on GitHub
Install in Dash