Getting Started
AnyAlt Widget requires an API key.
Contact us via the form and get your API key first.
Integrating the AnyAlt Widget into your web3 project is simple and straightforward. Follow these steps to quickly get up and running:
Step 1: Install the Package
Begin by installing the AnyAlt widget and `@tanstack/react-query`, which is a direct dependency, using your package manager of choice
Note: Ensure that your project is using
react
andreact-dom
version 18 or 19, as these are required dependencies for the@anyalt/widget
package.
Step 2: Import the font family and styles
Step 2: Wrap Your Application with the providers
The QueryClientProvider
and WidgetProvider
set up the required context (such as theming) for the widget. In your main application file, import the provider along with the default theme and wrap your app as shown below:
Note: You can customize the theme by providing your own theme object instead of
defaultTheme
if you wish to match your project’s branding.
Step 3: Import and Use the AnyAltWidget
Create a component that imports and uses the AnyaltWidget
. The widget handles the UI for cross-chain swaps and last-mile transactions. A sample integration might look like this:
How It Works
Modal Control: The
useModal
hook suppliesisOpen
,onOpen
, andonClose
to control the display of the widget. A button or any trigger in your app can open the widget modal.Configuration Props:
inputToken
andfinalToken
: Define the tokens involved in the swap and final transaction.widgetTemplate
: If value isTOKEN_BUY
, then it is token purchase usecase. If you want to provide users to purchase your token, you can set your token information including logo url intoinputToken
props. In this casefinalToken
props is not required. Value is optional and by default it will useDEPOSIT_TOKEN
.apiKey
: A required key for authentication or connecting to AnyAlt’s backend services.minDepositAmount
: Sets the minimum deposit amount needed to trigger a transaction.
Callbacks:
estimateCallback
: Allows you to run custom logic (like querying exchange rates or fee estimations) before executing the final transaction.executeCallBack
: Executes your project-specific last-mile transaction and returns relevant transaction hashes and details.
By following these steps, you can integrate the AnyAlt Widget quickly, ensuring that your web3 project supports seamless cross-chain interactions with minimal effort.
Last updated