The Treasures swap widget: embed trading on your site in two lines
The Treasures swap is now an embeddable widget. Two lines of HTML put the swap box on any website, and your visitors buy and sell tokenized stocks from their own wallets without leaving your page. It needs no API key and no backend. An optional integrator ID credits the trades to your organisation and lets you charge your own fee. The docs have a new tab for it, For websites.
What changed
- A
<treasures-swap>element, loaded fromhttps://swap.treasures.io/widget/v1.js. See Swap Widget. - Configuration by attribute: the starting stock, side and amount, locks, stock and chain lists, a fixed height. Most attributes change in place at runtime. See Configuration.
- Wallets: the widget's own connect for EVM and Solana wallets,
connectto limit it to one type, andwallet="host"withsetWallet()to sign with the wallet your page already connected. See Connecting Wallets. - Customization: light or dark theme, and a palette of colours (per theme if you like), corners, font and shadow, as an attribute or through
setPalette(). See Customization. - Events:
treasures:*DOM events for loading, wallet connections, trades submitted, filled and failed, and bridges in flight. No event identifies the user. See Events. - Integrator ID and widget fee: an
intg_ID credits widget trades to your organisation. A widget fee of up to 1%, separate from your API integrator fee, is set with the Treasures team, shown to users as its own line, and paid out with your other integrator fees. Credited trades appear inGET /settlements. See Integrator ID and Fees.
What to do
Nothing changes for existing API integrations. To embed the widget, start at Swap Widget. To get an integrator ID or set a widget fee, write to hello@treasures.io.