fromDomain

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

Creates a WebAuthForContracts instance by discovering configuration from a domain's stellar.toml.

This is the recommended way to initialize WebAuthForContracts. It automatically fetches the stellar.toml file from the specified domain and extracts the required configuration:

  • WEB_AUTH_FOR_CONTRACTS_ENDPOINT: The authentication endpoint URL

  • WEB_AUTH_CONTRACT_ID: The web auth contract ID (C... address)

  • SIGNING_KEY: The server's public signing key for validating challenges

The stellar.toml file is fetched from: https://{domain}/.well-known/stellar.toml

Return

WebAuthForContracts instance configured from the domain's stellar.toml

Parameters

domain

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

network

The Stellar network (Network.PUBLIC or Network.TESTNET)

httpClient

Optional custom HTTP client for testing or proxy configuration

httpRequestHeaders

Optional custom HTTP headers to include in requests

Throws

If WEB_AUTH_FOR_CONTRACTS_ENDPOINT is missing from stellar.toml

If WEB_AUTH_CONTRACT_ID is missing from stellar.toml

If SIGNING_KEY is missing from stellar.toml