Events
What you can listen for, and error codes.
Events are optional. Most sites only need these three:
ts
widget.on("orderCreated", ({ orderId }) => save(orderId));
widget.on("orderCompleted", ({ orderId, outcome }) => console.log(orderId, outcome)); // filled | partial | unfilled
widget.on("error", ({ code, message }) => console.warn(code, message));widget.on(name, handler) returns a function that removes the handler. A listener that throws does not break the others. Payloads carry ids, states, tokens and amounts, never keys or signatures. Amounts are in the token's smallest unit, and a token or side is { chainId, token, symbol, decimals, amount }.
All events
Error codes
On
READY_TIMEOUT and PROTOCOL_MISMATCH the widget itself shows a short message in your container (with a "Try again" button for a timeout), so you do not have to handle them. widget.reload() does the same as that button.Recovering an order
Local storage inside a third-party frame can be partitioned or blocked. A host that wants recovery keeps the id from orderCreated and initializes again with config.orderId; the page then opens that order's tracking view.