Skip to main content
The modal emits every state transition through a single onLifecycle callback. You switch on event.type to update your UI, trigger backend processes, or log analytics. New event variants can be added without changing the prop surface.

Deposit lifecycle

  1. The modal initializes and fires onReady
  2. If the user funds from a wallet, "connected" fires with the EOA address and the smartAccount the deposit lands on
  3. The user selects a source chain, token, and amount, then confirms
  4. The modal submits the transaction on the source chain and emits "submitted"
  5. The bridge routes funds to the target chain. Once they arrive, the modal emits "complete"
If the bridge fails after submission, "failed" is emitted instead of "complete".
"connected" fires only for wallet funding. QR transfer, fiat on-ramp and exchange connect involve no wallet, so it never fires — use onReady if you need a “flow started” signal.

onLifecycle

onLifecycle receives a discriminated union — DepositLifecycleEvent on <DepositModal>, WithdrawLifecycleEvent on <WithdrawModal>. The two are similar but not identical; see withdraw events for the differences.

Deposit events

amount is in the source token’s base units — divide by sourceDecimals to display it. sourceDecimals is omitted when the token isn’t recognised, which happens for a QR deposit of an unlisted token. amountUsd is the USD value as entered in the modal. It is omitted for flows with no amount input: QR transfer, fiat on-ramp, and exchange connect.
sourceChain: "unknown" is deposit-only. When a webhook-detected deposit arrives without chain or token information, sourceChain is "unknown" and sourceToken is undefined — handle this branch so you don’t pick the wrong explorer URL.

Withdraw events

WithdrawLifecycleEvent carries the same type values minus "balance-changed" and "smart-account-changed". Its txHash is Hex, sourceChain is always a number, sourceToken / targetToken are Address, and "submitted" adds an accountAddress: Address field. "connected" means the deposit account for the chosen target is registered and fundable, not that a wallet connected.

Claim events

ClaimLifecycleEvent is a separate union — lookup, refund_requested, complete, failed. See claim modal.

onReady

Fires once when the modal is initialized and ready for interaction. No payload.

onError

Fires on errors at any stage — wallet connection, transaction signing, bridge setup — that prevent the deposit from being submitted. Distinct from the "failed" lifecycle event, which covers failures after the source transaction confirms.

Codes

Errors without a code carry only message. For bridge-level codes, see deposit processing error codes.

Error handling

After the source chain transaction confirms, the deposit service may retry automatically before the "failed" event fires.

Analytics

The onEvent callback fires on granular user interactions for your analytics pipeline. Its payload type is DepositAnalyticsEvent, WithdrawAnalyticsEvent, or ClaimAnalyticsEvent.
Events include modal views (*_open) and CTA clicks (*_cta_click) at each step of the flow, with contextual properties like selected token, chain, and amount.