The Trustware SDK emits typed events as users move through the deposit flow. You can subscribe to these events to track progress, update your own UI state, or send analytics without polling or manual state management.
The TrustwareEvent type
All events share a discriminated union type called TrustwareEvent. Each variant has a type string field you can use to narrow the event in a handler.
Event types
token_page_loaded, token_page_error, balance_stream_chunk, and balance_stream_fallback are gated by the tokensPagination and balanceStreaming feature flags. tokensPagination is enabled by default, so set it to false in features to suppress its events. balanceStreaming is enabled by default from SDK 1.1.12 (off by default on 1.1.11 and earlier), but it permits streaming rather than forcing it: balance_stream_chunk fires only for scans that actually stream, so the widget’s balance fetches and Trustware.getBalancesByAddressStream emit chunks while a buffered Trustware.getBalancesByAddress call emits none. Set the flag to false to suppress both events and use the buffered request everywhere. swap_route_changed fires only when the widget runs in swap mode.
How to subscribe
Pass an onEvent callback in your TrustwareConfigOptions. This works whether you are using TrustwareProvider or calling Trustware.init() directly in the headless core.
TypeScript narrows event to the correct shape inside each if branch, so accessing event.txHash is fully type-safe.
The onSuccess shortcut
For the common case of reacting to a completed deposit, you can use onSuccess instead of filtering inside onEvent. It receives the Transaction object directly.
onSuccess and onEvent are independent; you can use both at the same time.
Example: tracking deposit completion
The following example shows how to use onEvent to display a success notification when a deposit completes, and log any errors to an external service.