LogoLogo
  • Introduction to Unizen
    • Unizen Overview
      • Unizen Liquidity Distribution Mechanism (ULDM)
        • ULDM Performance
      • Unizen Interoperability Protocol (UIP)
        • LayerZero
        • DeBridge
        • Stargate
        • Celer
        • Axelar
        • Thorchain
    • Unizen Dashboard
      • General
      • Portfolio
      • History
    • Unizen Trade
      • Fees
    • Unizen Explore
      • Unizen Omni-Chain Data Pool
    • Unizen Earn
  • ZCX
    • Token Utility
    • Tokenomics
  • API - Introduction
    • Introduction
    • Before you get started
      • Understanding Price Impact and Price Slippage in Token Swaps
      • Token Allowance Management for Non-updatable Allowance Tokens
      • Tokens with taxes
      • Wrapping and Unwrapping Native Tokens
      • Quote expiration deadline
    • Security Best Practices for Integrating Unizen
      • Why disable CORS
      • How to integrate with a reverse proxy
    • Version 2 of our smart contracts
      • Migration to smart contract v2
  • API - GET STARTED
    • QuickStart guide
    • Swagger
    • Information endpoints
      • GET /trade/v1/info/chains
      • GET /trade/v1/info/sources
      • GET/v1/info/cross-providers
      • GET /trade/v1/info/token/search
      • GET /v1/info/token/popular
      • GET /trade/v1/info/token/{chainId}/{tokenAddress}
      • GET /trade/v1/info/tokenLogo/{chainId}/{tokenAddress}
      • GET /info/thorchain-inbound-address
      • GET /trade/v1/info/tx/{txHash}
      • GET /trade/v1/info/trade/{chainId}/{txHash}
      • GET /trade/v1/info/trades
    • Approval
      • GET /trade/v1/{chainId}/approval/spender
      • GET /trade/v1/{chainId}/approval/transaction
      • GET /trade/v1/{chainId}/approval/allowance
    • Single-Chain Swap
      • GET /trade/v1/{chainId}/quote/single
      • GET /trade/v1/{chainId}/swap/single
      • Send transaction in evm chains
      • Send transaction in Solana
    • Cross-Chain Swap
      • GET /trade/v1/{chainId}/quote/cross
      • GET /trade/v1/{chainId}/swap/cross
      • Send transaction
    • Gasless orders
      • POST /trade/v1/gasless/typed-data
      • POST /v1/gasless/estimate
      • POST /v1/gasless/create
      • POST /v1/gasless/cancel
      • GET /trade/v1/gasless/status/{orderId}
      • GET /v1/gasless/orderByAddress/{address}
    • UTXO Assets and Cosmos Swap
      • GET /trade/v1/{chainId}/quote/cross 1
      • GET /trade/v1/{chainId}/swap/cross
      • Sending transactions
    • Efficient Quote Retrieval with Batch Processing
      • GET /trade/v1/{chainId}/batch_quote/single
    • Error Messages
  • GASLESS TRADES
    • Obtaining gasless quotes
    • Gas estimation
    • Executing the trade
    • Following the orders
  • On-Chain Contracts - Get Started
    • Integration with Unizen Contracts for Token Swapping
    • Registering Errors on Smart Contract Calls
  • PERMIT2
    • What is Permit2?
    • Usage in our api
  • WIDGET - Get Started
    • Embed the Unizen Widget
    • Playground
  • Other
    • Smart Contracts
    • Security Audits
    • Roadmap
  • links
    • Unizen
    • Marketing Website
    • Medium
    • Twitter
    • Discord
    • Telegram
Powered by GitBook
On this page

Was this helpful?

  1. WIDGET - Get Started

Embed the Unizen Widget

Integrating the Unizen Widget into Your WebApp

PreviousUsage in our apiNextSmart Contracts

Last updated 8 months ago

Was this helpful?

To integrate the Unizen widget into your web application using an iframe, follow these steps. This guide will walk you through the process of embedding the widget and customizing its parameters.

Important Notice: Please notify us to whitelist your site before integrating our widget.

Unizen Playground URL:

Step-by-Step Guide

  1. Set Up Parameters:

    You can customize the widget by changing the values in the params object. Here’s a brief explanation of each parameter: Trade params

    • uuid: Your uuid.

    • apiKeyId: Your API key ID.

    • themeName: The theme of the widget (dark or light).

    • inputCurrency: The input currency address, for native currency, use Zero Address.

    • outputCurrency: The output currency address, for native currency, use Zero Address.

    • inputChainId: The chain ID of the input currency.

    • outputChainId: The chain ID of the output currency.

    • tokenFromAmount: The amount of the input currency, if you want to trade exact in. For example, if you want to trade 1.1 ETH => tokenFromAmount = '1.1'. NOTE: if exact out trade, leave it empty.

    • tokenToAmount: The amount of the output currency, if you want to trade exact out. NOTE: if exact in trade, leave it empty.

    Theme params

    • primaryTextColorLight: Primary text color in light mode.

    • primaryTextColorDark: Primary text color in dark mode.

    • secondaryTextColor: Secondary text color.

    • interactiveColorLight: Interactive color in light mode.

    • interactiveColorDark: Interactive color in dark mode.

    • accentColorLight: Accent color in light mode.

    • accentColorDark: Accent color in dark mode.

    • containerCardColorLight: Container card color in light mode.

    • containerCardColorDark: Container card color in dark mode.

    • dialogColorLight: Dialog background color in light mode.

    • dialogColorDark: Dialog background color in dark mode.

    • cardRadius: Border radius for cards.

    • buttonRadius: Border radius for buttons.

    • tokenLogoShadowSize: The size of the shadow applied to token logos, for example: '0 0 0 0'

    • font: The font used in the widget. It should match one of the available font classes. This is available font list: 'fira-code', 'baloo', 'poppins', 'lato', 'nunito', 'raleway', 'montserrat', 'oswald', 'playfair', 'barlow', 'rubik', 'cormorant', 'noto', 'alegreya', 'inter'

    Other params

    • networkSelector: Represents the UI option for selecting a network, usually a dropdown or selector. (string: 'true' or 'false')

    • categorySelector: Represents the UI option for selecting a category currency: (string: 'true' or 'false')

    • networks: A comma-separated list of supported networks. For example: 137,56

    Example params for trade from 1000 USDT to ETH on Ethereum:

    const params = {
        uuid: 'your uuid',
        apiKeyId: 'your apiKeyId',
        themeName: 'dark',
        inputCurrency: '0xdac17f958d2ee523a2206206994597c13d831ec7', // USDT address
        outputCurrency: '0x0000000000000000000000000000000000000000', // ETH address (native currency)
        inputChainId: '1', // Ethereum mainnet chain ID
        outputChainId: '1', // Ethereum mainnet chain ID
        tokenFromAmount: '1000', // Exact in amount of 1000 USDT
        tokenToAmount: '', // Leave empty for exact in trade
        primaryTextColorLight: 'red',
        primaryTextColorDark: 'blue',
        secondaryTextColor: 'blue',
        interactiveColorLight: 'orange',
        interactiveColorDark: 'purple',
        accentColorLight: 'pink',
        accentColorDark: 'cyan',
        containerCardColorLight: 'yellow',
        containerCardColorDark: 'yellow',
        dialogColorLight: 'green',
        dialogColorDark: 'green',
        cardRadius: '10px',
        buttonRadius: '5px'
      };
  2. Generate Widget URL: Construct the URL for the widget by appending the parameters to the base URL. const WIDGET_URL = `https://zcx.com/widget?${new URLSearchParams(params)}`;

  3. Embed the Widget in an iframe:

      <iframe
            src={WIDGET_URL}
            title='Unizen Exchange Widget'
            className={clsx(
              'w-[600px]',
              'h-[600px]',
              'border-2'
            )}>
          </iframe>

https://www.unizen.io/widget