Step by step guide to set up the Marswap Aggregator Widget
Authentication
REQUIRED
Enter your API Key and Integrator ID you received from the Marswap Team to authenticate the widget and start receiving quotes.
<MarswapWidget apiKey={'4b5f885c-b764-4160-95f4-00ceb5124abb'} //Example API Key integration={ { id:'test-widget' } }/>
InitMarswapWidget({widgetElementId:'marswap-widget'}, { apiKey:'4b5f885c-b764-4160-95f4-00ceb5124abb',//Example API Key integration: { id:'test-widget' }})
Integration Fees
OPTIONAL
You can choose to receive a percentage of the swap to gain additional revenue for your project.
Specify a feeAmount of up to 1%.
Enter the address of the wallet that should receive the integration fee as feeReceiver.
<MarswapWidget integration={ { id:'test-widget', feeAmount:'0.1',// 0.1% feeReceiver:'0x_fee_wallet_address'// Enter wallet address to receive fees } }/>
InitMarswapWidget({widgetElementId:'marswap-widget'}, { integration: { id:'test-widget', feeAmount:'0.1',// 0.1% feeReceiver:'0x_fee_wallet_address'// Enter wallet address to receive fees }})
Token List
OPTIONAL
You can create your own project specific token list, use the Marswap default list or use a combination of both.
If you do not pass in the tokenList parameter then the widget defaults to the Marswap Aggregator token list.
If you specify your own token list then by default it will be combined with the Marswap Aggregator token list. To prevent this you can set useMarswapTokenList equal to false.
buyTokenOrSellTokenHasFeesmust be set to true if the token has taxes otherwise the transaction might fail.
<MarswapWidget tokenList={[ { chainId:109, address:'0xABbAF2746C46f8F269e0a252285ABE9d8D8CDf63', symbol:'MSWAPF', name:'MarSwap Farm', decimals:18, buyTokenOrSellTokenHasFees:true, logoURI:'https://dex.marswap.exchange/images/tokens/MSWAP.png', }, { chainId:25, address:'0xaad00d36dbc8343c3505ba51418a43d3622d2964', symbol:'CLMRS', name:'Crolon Mars', decimals:18, buyTokenOrSellTokenHasFees:true, logoURI:'https://assets.coingecko.com/coins/images/26385/standard/resized-image-Promo-removebg-preview.png?1696525462', }, ]} useMarswapTokenList={true} //Set false to only use the token list above./>
InitMarswapWidget({widgetElementId:'marswap-widget'}, { tokenList: [ { chainId:109, address:'0xABbAF2746C46f8F269e0a252285ABE9d8D8CDf63', symbol:'MSWAPF', name:'MarSwap Farm', decimals:18, buyTokenOrSellTokenHasFees:true, logoURI:'https://dex.marswap.exchange/images/tokens/MSWAP.png', }, { chainId:25, address:'0xaad00d36dbc8343c3505ba51418a43d3622d2964', symbol:'CLMRS', name:'Crolon Mars', decimals:18, buyTokenOrSellTokenHasFees:true, logoURI:'https://assets.coingecko.com/coins/images/26385/standard/resized-image-Promo-removebg-preview.png?1696525462', }, ], useMarswapTokenList:true//Set false to only use the token list above.})
Default Tokens
OPTIONAL
Specify the default sell (TokenIn) and buy (TokenOut) tokens in the below format for each chain. If you do not specify a token, then the default tokens from the Marswap Aggregator will be used.