API reference

The AnyAlt SDK provides a set of powerful functions that enable you to manage the complete cross-chain swap flow. Below is an overview of each API function available within the SDK.

AnyAlt SDK Class

Constructor

  • new AnyAlt(apiKey: string)

    • Description: Creates a new instance of the AnyAlt SDK.

    • Parameters:

      • apiKey (string): Your unique API key for authenticating requests.

    • Returns: An instance of the AnyAlt SDK.

Methods

getChains

  • getChains(): Promise<SupportedChainsResponse>

    • Description: Retrieves a list of available blockchain networks.

    • Parameters:

      N/A

    • Returns:

      export interface SupportedChainsResponse {
        /** Array of supported chains */
        chains: SupportedChain[];
      }
      
      export interface SupportedChain {
        /**
         * UUID of the chain db entry
         * @example "1"
         */
        id: string;
        /**
         * Chain name
         * @example "ETH"
         */
        name: string;
        /**
         * Chain default decimals
         * @example 18
         */
        defaultDecimals: number | null;
        /**
         * Chain ID
         * @example 1
         */
        chainId: number | null;
        /**
         * Chain type
         * @example "EVM, SOLANA, etc."
         */
        chainType: string;
        /**
         * Chain logo URL
         * @example "https://example.com/logo.png"
         */
        logoUrl: string | null;
        /**
         * Chain display name
         * @example "Ethereum"
         */
        displayName: string | null;
        /**
         * Chain short name
         * @example "ETH"
         */
        shortName: string | null;
        /**
         * Chain RPC URL
         * @example "https://mainnet.infura.io/v3/..."
         */
        rpcUrl: string | null;
      }
    • Usage Example:

      const response = await anyalt.getChains({});
      const chains = response.chains;

getTokens

  • getTokens(params: GetTokensRequestParams): Promise<SupportedTokensResponse>

    • Description: Retrieves a paginated list of tokens for a specific network.

    • Parameters:

    • Returns:

    • Usage Example:

getBestRoute

  • getBestRoute(args: RoutesRequest): Promise<BestRouteResponse>

    • Description: Calculates the optimal route for executing a cross-chain swap between a source and destination token.

    • Parameters:

    • Returns:

    • Usage Example:

confirmRoute

  • confirmRoute(args: ConfirmRouteRequest): Promise<ConfirmRouteResponse>

    • Description: Confirms the selected swap route and prepares the operation for execution.

    • Parameters:

    • Returns:

    • Usage Example:

executeSwap

  • executeSwap(operationId: string, slippage: string, swaps: SwapResult[], onProgress?: (progress: TransactionProgress) => void): Promise

    • Description: Executes the cross-chain swap operation using the specified parameters and monitors its progress via a callback.

    • Parameters:

      • operationId (string): The operation ID obtained from the confirmRoute function.

      • slippage (string): Maximum acceptable slippage percentage, as a string (e.g., "3").

      • swaps (SwapResult[]): The swaps attribute of the best route or confirmed route response. See getBestRouteabove for defined types.

      • onProgress ((progress: TransactionProgress) => void)): A function that receives progress updates.

    • Returns: void

    • Usage Example:


This API reference provides a comprehensive overview of the functions available in the AnyAlt SDK. Using these methods, you can build a fully customized interface to manage cross-chain swaps and last-mile transactions while maintaining complete control over the user experience.

Last updated