Crowdswap

Crowdswap lets websites embed token swaps through an HTML component

Crowdswap lets you add token swaps to a website using a configurable HTML component and its JavaScript loader. The component carries token addresses and chain IDs, while the loader renders the exchange interface. Visitors can exchange assets through that embedded interface, including supported cross-chain swaps. Integration involves placing the element in the page body, loading the script, and testing it in a browser. Referral attribution and appearance settings serve separate purposes within the same setup.

ยท last updated

The component, loader, and routing service have separate roles

The HTML element identifies the widget's place in your page, while its loader turns that element into an interactive exchange. The routing service supplies available exchange paths, connecting the embedded interface with the platform's trading functionality.

The platform compares decentralized exchange routes and uses its swap contract to call the selected exchange. Existing liquidity pools supply assets for those routes, and the contract handles the platform swap fee.

Token and network settings define the starting pair

The element's config attribute contains JSON settings for the default token pair shown to first-time visitors and for appearance.

Token selection

Input side

fromTokenAddress and fromChainId identify the initial input token and the network where the widget looks it up.

Output side

toTokenAddress and toChainId identify the initial output token and its network. Keep each address paired with the correct network.

Presentation settings

The theme setting chooses light or dark presentation independently of token selection.

Installation puts the configured element before the loader

For a referral-enabled installation, create the affiliate ID before configuring the component, then add the element, include the loader, and test the page.

Place <crowdswap-swap-widget> inside the HTML body . Its configuration contains the chosen token addresses and chain IDs. Use the values for the intended assets before testing the integration.

Include the supplied JavaScript loader near the end of the body, before its closing tag, so it follows the component markup. This script initializes and renders the widget.

Save the HTML and open it in a browser to check whether the embedded exchange appears and accepts interaction.

Browser checks separate page rendering from trade execution

Check the selected assets, networks, and wallet interaction separately, because each reveals a different aspect of the embedded exchange. For a first-time visitor, the displayed pair should match the configured tokens and their networks. Executing a swap additionally involves wallet authorization and the relevant blockchain transactions; the interface alone doesn't prove that an exchange has settled.

If the component remains empty, inspect the element and loader first, including whether the hosting environment preserves the custom HTML and permits JavaScript execution. A missing or blocked loader prevents initialization, so page integration needs attention before a specific trading route can be assessed.

Matching or different token networks distinguish same-chain and cross-chain swaps

Consider a hypothetical website configuration with different input and output tokens on one supported network and a dark theme. Does changing the destination network require a different component?

Matching source and destination networks describe a swap within one blockchain, while the dark theme controls the interface's appearance. The styling choice doesn't change which networks participate in the exchange.

In the second configuration, the output token belongs to another supported network. Its destination address matches that network; the source selection and theme stay unchanged. This configuration describes a cross-chain exchange because the source and destination networks differ.

The same component covers both configurations when the selected assets have a supported route. Changing the destination means keeping its token address and chain ID aligned.

Visual summary: Crowdswap: Matching or different token networks distinguish same-chain and cross-chain swaps

View full-size image

Referral attribution connects trading activity with the embedding site

The widget accepts an affiliateId configuration field for referral attribution. The affiliate earns commission when users register and trade through the website under the program's terms. A page view or a successfully rendered widget doesn't establish an earned commission. Keep the identifier assigned to your affiliate account distinct from the token addresses used to select assets.

Illustration: Crowdswap: Referral attribution connects trading activity with the embedding site
Referral attribution connects trading activity with the embedding site - diagram

View full-size image

The payment widget handles a different commercial task

The payment widget addresses merchant settlement, including the option to receive a preferred token while customers pay with another supported token. The exchange widget gives visitors a token-swapping interface. These functions can appear alongside each other on a commercial website, with different roles in the purchase process.

Receiving a preferred settlement token belongs to the payment product's configuration and terms. Embedding the exchange component alone doesn't establish that an order has been paid. Checkout confirmation needs evidence of payment to the merchant, beyond the presence of an exchange interface.

The API suits a custom exchange interface

The API provides routing and market data for applications that build their own interface, while the widget supplies a ready-made exchange component. The choice concerns how much of the trading interface your application needs to implement.

The API suits a custom exchange interface (Crowdswap) - illustration

View full-size image

A custom API integration needs its own interface around the wallet connection and trading inputs, which increases the implementation work. The standalone embed supplies those trading controls within the component, leaving the surrounding website's navigation and content under your control.

Common questions, answered

Can I add the swap widget through a visual website editor?

A visual editor can host this integration if it preserves the custom HTML element and allows the JavaScript loader to execute. An editor that only accepts text won't provide those capabilities. Its custom-code facilities and script restrictions determine compatibility.

Do the configured tokens restrict visitors to a single trading pair?

The settings select initial tokens for first-time visitors; initial choices don't establish a restriction on all trading pairs.

Is a custom loading screen required for the embedded widget?

A custom splash screen is optional and doesn't change the basic embedding steps.

Should visitors enter their wallet recovery phrases on the embedding website?

Visitors shouldn't provide wallet recovery phrases or private keys to the embedding website. The widget configuration uses token addresses and chain IDs, while wallet signing authorizes transactions. Those configuration values identify assets and networks; they don't require the website to collect wallet recovery secrets.

Does the standalone widget require my own routing backend?

The standalone embed uses the platform's exchange services and doesn't require you to implement your own routing backend. Your page hosts the configured component and loads its JavaScript. This differs from building a custom application around the API, where you implement the surrounding interface and integration.

How can a business get help integrating the exchange widget?

Businesses can contact Crowdswap's online support team or use its business enquiry form for help integrating the exchange widget. An integration enquiry can identify the component configuration, the hosting environment, and whether the interface renders. Keep private keys and recovery phrases out of any support message.