fromDomain

suspend fun fromDomain(domain: String, horizonUrl: String? = null, network: Network? = null, httpClient: HttpClient? = null, httpRequestHeaders: Map<String, String>? = null): Sep08Service

Creates a Sep08Service by discovering regulated assets from stellar.toml.

Fetches the stellar.toml file from the specified domain and extracts all regulated asset entries. The network and Horizon URL are resolved from the provided parameters or from the stellar.toml configuration.

Resolution order for network:

  1. Explicit network parameter if provided

  2. NETWORK_PASSPHRASE from stellar.toml, mapped to known networks or created as custom

Resolution order for Horizon URL:

  1. Explicit horizonUrl parameter if provided

  2. HORIZON_URL from stellar.toml

  3. Default Horizon URL for the resolved network (public, testnet, or futurenet)

Return

Sep08Service configured with regulated assets from the domain's stellar.toml

Parameters

domain

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

horizonUrl

Optional Horizon server URL override

network

Optional network override

httpClient

Optional custom HTTP client for testing

httpRequestHeaders

Optional custom headers for requests

Throws

If the network passphrase or Horizon URL cannot be determined

Example:

// Auto-configure from stellar.toml
val sep08 = Sep08Service.fromDomain("example.com")

// With explicit network and Horizon URL
val sep08Testnet = Sep08Service.fromDomain(
domain = "testanchor.example.com",
horizonUrl = "https://horizon-testnet.stellar.org",
network = Network.TESTNET
)