getSources

open suspend fun getSources(chainId: String, zeroXApiKey: String? = null): Result<ZeroXSourcesResponse>

Retrieves available swap sources for a chain.

This method fetches the list of available swap sources (e.g., Uniswap, Sushiswap, Curve) for the specified chain. The ZeroX API key can be configured in two ways:

  1. Portal Dashboard (Recommended): Configure your ZeroX API key in the Portal Dashboard. The SDK will use it automatically when zeroXApiKey is null.

  2. Per-Request Override: Provide the API key in the zeroXApiKey parameter to override the Dashboard configuration for this specific request.

Return

A Result containing ZeroXSourcesResponse with available swap sources as an array of source names (e.g., "Uniswap", "Sushiswap", "Curve").

Parameters

chainId

The chain ID in the format "eip155:{chainId}" (e.g., "eip155:1" for Ethereum mainnet, "eip155:137" for Polygon).

zeroXApiKey

Optional ZeroX API key to override the one configured in Portal Dashboard.

  • If null: The SDK will use the API key configured in the Portal Dashboard.

  • If provided: This API key will be used for this request, overriding the Dashboard configuration.

  • The API key is used to authenticate requests to the ZeroX API service and is included in the request body.

Throws

if the URL cannot be constructed, or network/decoding errors if the request fails.