Getting Started

Integrating the AnyAlt SDK into your project gives you full control over the cross-chain swap and last-mile transaction processes without the constraints of a pre-built UI. Follow these steps to integrate and start using the SDK:

Step 1: Install the SDK Package

Install the AnyAlt SDK using your package manager of choice

npm install @anyalt/sdk
# or
yarn add @anyalt/sdk
# or
pnpm add @anyalt/sdk

Step 2: Initialize the SDK

Begin by creating an instance of the AnyAlt class using your API key. This instance will be used to access all SDK functions:

import { AnyAlt } from '@anyalt/sdk';

const anyalt = new AnyAlt('<YOUR_API_KEY>');

Step 3: Retrieve Available Chains and Tokens

To let your end-users select a source token and chain, fetch the list of available chains and tokens:

Step 4: Obtain the Best Swap Route

Once a user selects the source and destination tokens, determine the optimal cross-chain swap route:

Step 5: Confirm the Swap Route

After obtaining the best route, confirm it by providing the selected route, wallet mappings, and the destination address:

Step 6: Execute the Swap

Finally, execute the cross-chain swap. You can track the progress of the transaction using a callback function:

The progress callback uses typical IoC or dependency injection, where the progress being injected into it is of type TransactionProgress :

By following these steps, you can integrate the AnyAlt SDK into your project and build a fully customized UI for managing cross-chain swaps and transactions.

Last updated