You can add the Mayan cross-chain swap widget to your website by including a few lines of code:
(example: )
<script src="https://cdn.mayan.finance/mayan_widget_v_1_2_3.js"
integrity="sha256-cuUqfbhmgeDDfwx+QGh6ncdr9kAxv8M+MLftyZ+lj9k="
crossorigin="anonymous" onload="(function () {
const config = {
appIdentity: {
name: 'My Project',
icon: './logo.png', // should be relative address
uri: 'https://myproject.io',
},
rpcs: {
solana: "https://example.rpc.com/solana" // must be added
}
}
MayanSwap.init('swap_widget', config)
})()"
/>
That's it! You now have a fully-functional native to native bridge on your website.
Customizing Your Widget
You can customize the widget to suit your needs, such as limiting tokens or networks. Here’s a complete example showing different parameters you can set:
appIdentity: This object contains information about your project, such as the name, icon, and website URL.
rpcs: This object contains the RPC URLs for the blockchain networks you want to support. Make sure to update these URLs with your own URLs.
solanaReferrerAddress, evmReferrerAddress: if you wish to receive referrer fee you can assign your wallet address to these parameters.
referrerBps: You can set the referrerBps you are willing to receive from user (Max: 50 bps)
If you don't specify list of tokens/chains, all the the supported tokens/chains will appear.
solanaExtraRpcs: Optional field to improve transaction speed and success rate by sending transactions to multiple RPCs. Use this if user experience is a priority.
isNarrow: A flag to render the widget in containers less than 300px wide. Not recommended as it can damage the widget interface.
colors: This object allows you to customize the colors of the widget by setting the following properties:
To avoid redeclaring web components if you've already added WalletConnect dependencies to your project or use a third party that includes it, use the version of the widget without WalletConnect:
type MayanWidgetConfigType = {
appIdentity: {
uri: string;
icon: string; // should be relative
name: string;
}; // use for Wallet Adapter
setDefaultToken?: boolean;
rpcs?: { [index in MayanWidgetChainName]?: string };
solanaExtraRpcs?: string[];
defaultGasDrop?: { [index in MayanWidgetChainName]?: number };
sourceChains?: MayanWidgetChainName[];
destinationChains?: MayanWidgetChainName[];
tokens?: {
from?: { [index in MayanWidgetChainName]?: string[] };
to?: { [index in MayanWidgetChainName]?: string[] };
featured?: { [index in MayanWidgetChainName]?: string[] };
};
solanaReferrerAddress?: string;
evmReferrerAddress?: string;
referrerBps?: number;
// Theme
isNarrow?: boolean;
colors?: Colors;
}
Full Example
sourceChains: List of supported source chains by the widget. To fetch list of supported tokens you can use the .
destinationChains: List of supported destination chains by the widget. To fetch list of supported tokens you can use the .
tokens: This object contains the list of token mint/contract addresses for each network you want to support. You can add or remove tokens as needed.
You can check the list of supported chains by Mayan using .
defaultGasDrop: You can change the default gas of for each chain.
if you don't set this parameter, widget will use values from the this .
For a full example of the integration, you can check the source code of on . This repository provides a comprehensive example of how to integrate the Mayan Swap Widget into a project.