Search
Close this search box.

How to Integrate the AnyAlt Widget Using iFrame

The AnyAlt Widget provides a seamless way to embed a cross-chain token swap interface directly into your website or application. This guide walks you through the setup, from basic integration to advanced customization—so you can quickly enable cross-chain token swaps for your users using an iFrame.

By the end of this guide, you’ll build a fully functional token buy/swap feature using the AnyAlt Widget.

What You’ll Need

  • A code editor (like VSCode)
  • A web browser for testing
  • An API Key (Request one here)

Let’s get started.

How the AnyAlt Widget Works

The AnyAlt Widget embeds directly into your website using an iFrame and communicates securely via postMessage. Key features include:

  • Customizable default token (e.g., USDT, ETH).
  • Light/dark theme support.
  • Cross-chain compatibility (EVM, Solana, etc.).

The widget handles all the complexity, so you can integrate cross-chain swap with just a few lines of code.

Quick iFrame Setup

For a fast integration, paste this code into an HTML file (e.g., index.html):

<!DOCTYPE html>

<html>

<head>

  <title>AnyAlt Widget Demo</title>

</head>

<body>

  <h1>Swap Tokens with AnyAlt</h1>

  <!-- AnyAlt Widget iFrame -->

 <!-- AnyAlt Widget iFrame -->
  <iframe
  src="https://iframe.anyalt.finance?apiKey=pk_qVLFXBIMKUFralU4dAtXs4awZ&minDepositAmount=0&tokenName=USDT&tokenSymbol=USDT&tokenAddress=0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9&tokenChainId=42161&tokenDecimals=6&tokenChainType=EVM&tokenLogoUrl=https://example.com/usdt-logo.png&theme=dark&backgroundColor=rgb(7,11,23)"
  style="width: 100%; height: 1000px; border: none;"
  title="Widget"
></iframe>

</body>

</html>
  1. Replace YOUR_API_KEY with your actual API key.
  2. Save the file and open it in a browser.

You should now see a fully functional token swap interface!

Required iFrame Parameters

The widget needs these parameters to work:

ParameterDescriptionExample
apiKeyYour AnyAlt API keyapiKey=abc123
minDepositAmountMinimum deposit amount (set 0 for no limit)minDepositAmount=10
tokenSymbolToken symbol (e.g., “USDT”)tokenSymbol=USDT
tokenNameToken name (e.g., “USDT”)tokenName=USDT
tokenAddressToken contract addresstokenaddress=0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9
tokenDecimals Number of decimals (number)tokenDecimals=6
tokenChainTypeChain type (“EVM”, “SOLANA”)tokenChainType=EVM
tokenChainIdChain ID (number)tokenchainId=42161

Optional Customizations

ParameterDescriptionExample
themeUI theme (light or dark)theme=dark
tokenLogoUrlURL to token logotokenLogoUrl=https://example.com/logo.png
backgroundColorWidget background (hex, RGB, or name)backgroundColor=rgb(7,11,23)

When all parameters are completed, the code for src should look like this:

 src="https://iframe.anyalt.finance?apiKey=pk_qVLFXBIMKUFralU4dAtXs4awZ&minDepositAmount=0&tokenName=USDT&tokenSymbol=USDT&tokenAddress=0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9&tokenChainId=42161&tokenDecimals=6&tokenChainType=EVM&tokenLogoUrl=https://example.com/usdt-logo.png&theme=dark&backgroundColor=rgb(7,11,23)"

If you’ve entered and saved the code correctly, your webpage will now display a fully functional swap widget like this:

To customize and style the widget via iFrame, explore the iframe documentation for advanced options.

You’ve successfully integrated the AnyAlt Widget using the iframe—your users can now swap tokens seamlessly on your site!

Need more help? Visit the AnyAlt Documentation.

Share the Post:

Related Articles