currency From Url
Loads detailed currency information from an external TOML file.
Instead of embedding complete currency information directly in stellar.toml, organizations can link to separate TOML files for each currency. This is useful when currency information is extensive or when the same currency details need to be shared across multiple services.
When a currency entry in stellar.toml contains only a toml field pointing to an external URL (e.g., toml="https://DOMAIN/.well-known/USDC.toml"), use this method to fetch and parse the complete currency information.
Return
Currency containing the complete currency information
Parameters
The full URL to the currency TOML file
Optional custom HTTP client for testing or proxy configuration
Optional custom HTTP headers to include in the request
Throws
If the currency TOML file is not found (non-200 status code)
If the TOML content is invalid and cannot be parsed
Example:
val stellarToml = StellarToml.fromDomain("example.com")
// Check if any currencies link to external TOML files
stellarToml.currencies?.forEach { currency ->
currency.toml?.let { url ->
// This currency's details are in an external file
val fullCurrency = StellarToml.currencyFromUrl(url)
println("${fullCurrency.code}: ${fullCurrency.desc}")
println("Issuer: ${fullCurrency.issuer}")
if (fullCurrency.isAssetAnchored == true) {
println("Anchored to: ${fullCurrency.anchorAsset}")
}
}
}