fromDomain

suspend fun fromDomain(domain: String, httpClient: HttpClient? = null, httpRequestHeaders: Map<String, String>? = null): StellarToml

Fetches and parses stellar.toml from a domain's well-known location.

Automatically constructs the standard stellar.toml URL for the given domain and fetches the content via HTTPS. The standard location is always: https://DOMAIN/.well-known/stellar.toml

This is the primary method for discovering a domain's Stellar integration information. Organizations publish their stellar.toml file at this standardized location to allow wallets, anchors, and other services to discover their capabilities and configuration.

Return

StellarToml containing the parsed stellar.toml data

Parameters

domain

The domain name (without protocol). E.g., "example.com"

httpClient

Optional custom HTTP client for testing or proxy configuration

httpRequestHeaders

Optional custom HTTP headers to include in the request

Throws

If the stellar.toml file is not found (non-200 status code)

If the TOML content is invalid and cannot be parsed

Example:

// Fetch stellar.toml from a domain
try {
val stellarToml = StellarToml.fromDomain("example.com")

// Check if the domain supports WebAuth
stellarToml.generalInformation.webAuthEndpoint?.let {
println("WebAuth supported at: $it")
}

// Check for transfer server
stellarToml.generalInformation.transferServerSep24?.let {
println("SEP-24 transfers available")
}
} catch (e: Exception) {
println("Failed to fetch stellar.toml: ${e.message}")
}

Example with custom headers:

val stellarToml = StellarToml.fromDomain(
"example.com",
httpRequestHeaders = mapOf("User-Agent" to "MyWallet/1.0")
)