Install
HTML
/embed/v1.js tracks the latest 1.x and can’t be pinned with integrity. Hashes for every version are at /embed/versions.json. To self-host, copy the file into your build; it has no dependencies.
Onstacks.open(target, callbacks)
Opens the widget in a modal window and returns a handle.
target is one of:
- an options object
{ widgetId, environment, type, asset, chain, currency, amount, wallet, ref, redirect }(see Add the widget). The script builds the link and addsorigin, your page’s origin, so the widget can post messages back to it. During local development,hostcan point the link at a widget running onlocalhost. - a signed link.
ref is the value you passed when opening the widget. Callbacks report what the widget said in the customer’s browser; they’re not proof of payment. See Track payments.
Onstacks.mount(element, target, callbacks)
Same target and callbacks, rendered inline inside element instead of a window. The frame grows with the widget and the page scrolls. Returns { destroy() }, which removes the frame. If the link has already expired, onError runs with expired and nothing is rendered.
Errors
open and mount throw before anything is shown when the call itself is wrong:
Problems after the window opens, such as a wrong widget ID or an unlisted website, show inside the widget as a not-found screen; see If it doesn’t work.
Content Security Policy
script-src covers the embed script; your Onstacks.open(...) call needs a nonce or to live in your bundle. The script adds no stylesheets, so a strict style-src is fine.
What the script does
It creates a<dialog> or <iframe> for the link, listens for message events, forwards the ones that pass these checks to your callbacks, and removes everything on close:
event.originis the widget’s origin, and that origin isramp.onstacks.ioorramp-sandbox.onstacks.io(orlocalhostin development).event.sourceis the frame it opened.- The data is
{ source: "onstacks-widget", version: 1, message }and the payload has the documented shape.
window.Onstacks. The file is served unminified so you can read it.
Messages
If you embed the widget yourself, these are the messages it posts to the parent page, each wrapped as{ source: "onstacks-widget", version: 1, message: { type, payload } }. The widget posts only to the website in your settings (or the signed link’s origin).
Embedding without the script
Embedding without the script
Open
https://ramp-sandbox.onstacks.io/w/<widget-id>?type=offramp&ref=… (or a signed link) in your own iframe with allow="camera; clipboard-write" and apply the same checks before trusting a message:JavaScript