Sep45No Contract Id Exception
Exception thrown when the domain's stellar.toml is missing the WEB_AUTH_CONTRACT_ID.
SEP-45 requires the server's stellar.toml to contain a WEB_AUTH_CONTRACT_ID field that specifies the contract address (C...) used for authentication. This contract implements the web_auth_verify function that validates authentication requests.
The WEB_AUTH_CONTRACT_ID is critical for security validation:
Clients verify the challenge targets this specific contract
Prevents attacks where malicious servers direct auth to wrong contracts
Ensures the authentication flow uses the intended contract implementation
To resolve this error:
Check the stellar.toml at https://{domain}/.well-known/stellar.toml
Look for WEB_AUTH_CONTRACT_ID field (should be a C... address)
Verify the WEB_AUTH_FOR_CONTRACTS_ENDPOINT is also present
Contact the service provider if the contract ID should be available
Example - Handle missing contract ID:
try {
val webAuth = WebAuthForContracts.fromDomain("example.com", Network.PUBLIC)
} catch (e: Sep45NoContractIdException) {
println("Domain ${e.domain} does not have WEB_AUTH_CONTRACT_ID configured")
// Contact service provider or check configuration
}