Configuration
The widget is configured with attributes on the <treasures-swap> element. All of them are optional. An unknown or invalid value is ignored, never an error: the widget falls back to its default for that option.
Attributes
| Attribute | Value | What it does |
|---|---|---|
integrator | intg_… | Your integrator ID. It credits trades to your organisation and charges your widget fee if you set one. Left out, the widget still works, credited to no one. See Integrator ID and Fees |
stock | A ticker, such as AAPL | The stock the widget opens on |
side | buy (default) or sell | The side the widget opens on |
amount | A number, such as 100 | An amount to start with: dollars on a buy, shares on a sell. An amount under 0.00001 is ignored |
stocks | Tickers, comma-separated, such as AAPL,TSLA,NVDA | Offer only these stocks. A stock outside the list opens on the list's first |
lock | Any of stock, side, amount, comma-separated | What the user can't change. See Locks |
chains | Any of sol, eth, base, arbitrum, robinhood, bnb, comma-separated | Trade only on these chains |
connect | evm or solana | The only wallet type your users can connect. See Connecting Wallets. Left out, users can connect both |
wallet | host | Use the wallets your page already connected instead of the widget's own connect. See Use your page's wallet |
theme | light or dark | The widget's theme. Left out, it follows the user's system. See Customization |
palette | JSON | Your colours, corners, font and shadow. See Customization |
height | Pixels, such as 700 | A fixed height: the box stays that size and scrolls inside when its content is taller. At least 510. Left out, the box grows to fit its content |
Locks
lock takes away the controls for what you have already decided, so you can build a focused box such as "Buy Tesla":
| Lock | Effect | Needs |
|---|---|---|
stock | No stock picker | stock set |
side | No Buy/Sell switch | Nothing: without side it holds the box on buy |
amount | The amount is fixed | amount set. It holds the side too, since the amount is dollars on a buy and shares on a sell |
A lock whose option is not set is ignored. A locked stock that can't be traded right now says so, instead of offering another stock.
<!-- A "Buy Tesla" box: $100 to start, stock and side fixed. -->
<treasures-swap stock="TSLA" side="buy" amount="100" lock="stock,side"></treasures-swap>
Changing options at runtime
Change an attribute and the widget follows. Most options change in place; a few reload the widget.
| Options | When you change one |
|---|---|
stock, side, amount, stocks, lock | Applied in place, keeping what the user typed. A new side clears the amount, since dollars become shares. A change made while the user is reviewing a trade waits until they close the review |
theme, palette | Applied in place, at once |
height | Applied at once |
integrator, wallet, chains, connect | The widget reloads, because they shape quotes and the wallet connection |
Setting the same values again does nothing, so re-rendering the element from React or Vue is safe.
// Your page's own stock list drives the widget, keeping what the user typed:
document.querySelector('treasures-swap').setAttribute('stock', 'NVDA');