Embed in 5 minutes
Works today · The snippet works today against the local devnet relay. The hosted relay it points at below comes with M1 hosting.
Nothing to build: the relay serves the swap page and a small script that frames it on your page. Your app id travels with every quote, so the flow is attributed to you and you receive the channel share, 30% of the protocol fee on the flow you bring (the integration guide has the terms).
The snippet
Section titled “The snippet”<div id="swap"></div>
<script src="https://preprod-app.fondaco.network/swap/embed.js" data-app-id="your-app" data-target="#swap"></script>
On mainnet the host is app.fondaco.network.
data-app-id: your app id, as the operator registered it. Letters, digits,.,_and-, up to 64 characters. Without a valid one the swap still works but quotes as the operator, and nothing is attributed to you.data-target: a CSS selector for the element to fill. Without it, the frame goes right after the script tag.data-ref(optional): a referring app id.
The script inserts an iframe of the swap's compact layout, full width up to the card's width, and resizes it to the page's height as the swap reports it (by postMessage, accepted only from the relay's origin and from that frame). The user connects their own wallet inside the frame; your page never sees the wallet or the trade. Load it with a plain <script src> tag: as a module script it cannot find itself and does nothing.
No app key goes in the snippet. A key cannot be kept secret in a browser, so embeds are attributed by app id instead; an app that wants its own app fee integrates the wallet SDK under its key.
If your page has a Content Security Policy
Section titled “If your page has a Content Security Policy”Allow the relay's origin for the script and the frame:
script-src 'self' https://preprod-app.fondaco.network; frame-src https://preprod-app.fondaco.network
(With app.fondaco.network on mainnet.) The script sizes the frame through the DOM, not with inline styles, so it needs no 'unsafe-inline'.
Try it locally
Section titled “Try it locally”With the devnet stack running (step 1 of the wallet quickstart), serve this from any page on localhost; partner-wallet is the app the devnet registers:
<div id="swap"></div>
<script src="http://localhost:4000/swap/embed.js" data-app-id="partner-wallet" data-target="#swap"></script>
The framed swap is the same page as http://localhost:4000, with the devnet wallet in it.
What your users should know
Section titled “What your users should know”The swap tells the user what the chain will show before the wallet signs: the USDM side is hidden; the NIGHT side is public, address and amount. Your page does not need to repeat it, but should not contradict it.