API reference for the Deposit class. The core SDK entry point.
The Deposit class is the main entry point for the SDK. It manages the signer call, iframe lifecycle, and completion handling.
import { Deposit } from '@swype-org/deposit';
Constructor
new Deposit(config: DepositConfig)
Creates a new Deposit instance. Throws a DepositError with code INVALID_REQUEST if config.signer is missing or not a string/function.
DepositConfig
Property
Type
Default
Description
signer
string | SignerFunction
required
URL string for the signer endpoint, or a custom async function. When a string, the SDK sends a POST with a JSON SignerRequest body. When a function, the SDK calls it with a SignerRequest and expects a Promise<SignerResponse>.
environment
'production' | 'sandbox'
'production'
Blink environment to target. 'sandbox' points the hosted flow at the testnet sandbox (https://pay-sandbox.blink.cash). An explicit webviewBaseUrl takes precedence.
webviewBaseUrl
string
'https://pay.blink.cash'
Base URL of the hosted payment webview app. The SDK appends merchantId, payload, and signature as query parameters. Overrides environment when set.
hostedFlowOrigin
string
Derived from webviewBaseUrl
Origin for postMessage validation.
containerElement
HTMLElement
document.body
DOM mount point. Required for embedded presentation, where it must remain a stable, rendered element for the life of the instance.
presentation
'overlay' | 'embedded'
'overlay'
Present the hosted flow as Blink’s standard overlay or inline inside containerElement. Embedded resolves to overlay on mobile. See Embed Blink in an aggregator.
embedMaxHeightPx
number
90% of host viewport
Embedded only. Caps the inline iframe height and provides the layout budget used by Blink’s internal screens.
signerTimeoutMs
number
15000
Maximum milliseconds to wait for the signer to respond.
flowTimeoutMs
number
undefined (no limit)
Maximum milliseconds for the entire flow (signer + user completion).
enableFullWidget
boolean
true
Whether the hosted flow may show the full widget — the deposit options entry screen offering deposit addresses (pay from an exchange or any wallet) alongside Blink one tap. The full widget appears only when this is trueand it is enabled on your Blink merchant account. Set to false to send users straight to the Blink one-tap flow.
Color scheme, optional brand colors, and deposit title visibility for the hosted UI. hideDepositTitle defaults to false; set it to true when your container supplies the heading. More and other navigation titles remain visible. variables accepts colorPrimary, colorBackground, colorText, colorDanger, and colorBorder as opaque hex. See Dark and light mode.
preload
boolean
true
Warm a hidden hosted flow after construction so it can appear faster. Set to false to defer or disable the background page load.
merchantId
string
undefined
Optional preload performance hint used to prefetch merchant configuration. Authorization always comes from the signed signer response.
debug
boolean
false
Log lifecycle events to console.debug with the [BlinkDeposit] prefix.
appearance is read when the instance builds its hosted-flow URLs, including the warm-up iframe created at construction. To change the theme, call destroy() and construct a new Deposit.
Methods
preload
deposit.preload(): void
Warm the hosted flow before the user starts a deposit. The SDK calls this automatically after construction unless preload: false. Call it manually when you want to control the timing, such as when a payment widget opens or the user hovers the Blink option.It is a no-op when a warm iframe already exists or a deposit flow is active.
Opens the hosted deposit flow for the given deposit. The returned Promise resolves when the user completes the payment and rejects with a DepositError on failure.If a flow is already active, calling requestDeposit again cancels the previous flow and starts a new one.Throws DepositError with code INVALID_REQUEST if the instance has been destroyed.Pass minimumDeposit in the request to raise the minimum deposit in USD. It never lowers Blink’s route minimum. See Minimum deposit for validation and examples, and Types for the full DepositRequest and DepositResult definitions.
on
deposit.on(event: EventName, handler: EventHandler): this
Register an event listener. Returns this for chaining. See Events.
off
deposit.off(event: EventName, handler: EventHandler): this
Remove a previously registered event listener. Returns this for chaining.
close
deposit.close(): void
Close the transfer iframe without waiting for completion. If a flow is active, its requestDeposit() promise rejects with DEPOSIT_DISMISSED. The method resets status to idle and fires the close event.
destroy
deposit.destroy(): void
Tear down the instance and release all resources. Closes the iframe, removes all event listeners, and marks the instance as destroyed. Subsequent calls to requestDeposit will reject with INVALID_REQUEST.Call this on component unmount or page unload.
focus
deposit.focus(): void
No-op. Retained for API compatibility.
Properties
presentation
deposit.presentation: 'overlay' | 'embedded'
The resolved presentation for this instance. It can differ from the requested config because embedded presentation resolves to the overlay on mobile. No resize event fires when this value is 'overlay'.
status
deposit.status: DepositStatus
Current phase of the deposit flow. One of 'idle', 'signer-loading', 'iframe-active', 'completed', or 'error'.
result
deposit.result: DepositResult | null
Last successful DepositResult, available when status === 'completed'.
error
deposit.error: DepositError | null
Last DepositError, available when status === 'error'.
isActive
deposit.isActive: boolean
true when a deposit flow is in progress (status is 'signer-loading' or 'iframe-active').
Assistant
Responses are generated using AI and may contain mistakes.