Try the Halliday Payments SDK Widget
Following this guide, or the Payments Hello World guide will result in an onramp experience like the following. Try out onramping to an external wallet with this button:Installation
Install the Payments SDK, which is available on NPM.- npm
- yarn
copy
Initialization Options
TheopenHallidayPayments function opens the Halliday Payments widget and accepts the following configuration options:
| Name | Type | Description |
|---|---|---|
apiKey | string | Your API key for authorization. |
destinationAddress | string | The address of the destination wallet for onramps and swaps. |
inputs (optional) | Asset[] | The input assets for the widget. |
outputs | Asset[] | The output assets for the widget. |
customStyles (optional) | object (CustomStyles) | A list of custom styles to show in the widget. See customizing styles. |
targetElementId (optional) | string | The ID of the DOM element where the widget should be embedded if modal mode is not desired. |
onStatus (optional) | OnStatus | Callback to receive status events. |
onConnectUserWallet (optional) | () => void | Callback invoked when the user requests to connect their wallet. |
onReady (optional) | () => void | Callback invoked when the widget is fully preloaded and ready. |
onError (optional) | OnError | Callback invoked when the widget fails to load or another error occurs. |
userWallet (optional) | UserWallet | User wallet configuration with signing functions. This wallet address is the sole controller of the payment. If this is not provided, the user will be prompted to sign-in with an embedded wallet. |
funder (optional) | FunderRole | Funder wallet configuration with signing functions. If funder is not provided, the “pay with wallet” option will not be available to the user. |
funders (optional) | FunderRole[] | Additional funding sources available to the user at the time of a payment. See the Multiple Funders section below. |
fontName (optional) | FontName | Font for the widget. Default is ‘haffer’. ‘wudoo-mono’ or ‘inter’ available. |
headerTitle (optional) | string | Custom title for the widget header. |
Type Definitions
Usage Patterns
Using the wallet connector
Halliday can prompt users to choose a wallet to connect to the app. The wallet connector provides many options including MetaMask, Coinbase Wallet, Rainbow, or Wallet Connect. Clicking the button will trigger the connect-wallet prompt. If the application already prompts the user to connect a wallet, see using a connected wallet.copy
Using a connected wallet
The Halliday SDK can accept an existing wallet connection object that an app has already established. With this flow, users do not need to reconnect their wallet using the Halliday external wallet modal, creating an optimal user experience for Web3 applications. If the application does not already have a connected wallet, see using the wallet connector. Support for existing Viem, Wagmi, and Ethers.js wallet connections are available to Halliday SDK developers. These functions also allow the widget to utilize the proper account if the user switches the address or network in their wallet extension.copy
Viem
copy
Wagmi
copy
Ethers.js
copy
Dynamic
The following code example is a demonstration of passing a Dynamic embedded wallet provider to the Halliday SDK in a full React app which is available in the SDK example apps section.Privy
In addition to the following code example, a demonstration of passing a connected Privy wallet to the Halliday SDK in a full React app is available in the SDK example apps section.Turnkey
Turnkey embedded wallet signatures can be integrated with the Halliday SDK using the@turnkey/react-wallet-kit and @turnkey/viem SDKs with viem and @halliday-sdk/payments. The developer is required to create an interface for the Turnkey SDK. A full React.js code example is available here: Halliday SDK Turnkey React.js Example.
Preloading the Widget
For the best user experience, the widget can be preloaded so it appears instantly when shown. TheinitializeClient call should be done in the initial loading phase of the app.
Later, the openHallidayPayments call can be executed once the widget user interface is ready to be shown to the user.
If an initializeClient call is made with all of the necessary parameters passed to it, the subsequent call to openHallidayPayments can be done without including any parameters.
copy
Withdraw Widget
For apps that define an account for the user, like an embedded wallet or smart contract wallet, the withdraw widget allows the user to move assets out of their account. The destination of a withdrawal can be any valid address like the user’s EOA or a centralized exchange account deposit address. The destination also can be a different asset on a different chain from the origin. E.g. withdraw pUSD from a user’s prediction market account on Polygon to an EOA on MegaETH as USDC, executed in one user interaction. In practice, the withdraw widget (openWithdraw) is opened by a different button in the app user interface than the standard deposit widget defined earlier (openHallidayPayments).
It is required that the initializeClient method is called before openWithdraw.
| Name | Type | Description |
|---|---|---|
withdrawInputs (optional) | Asset[] | Assets that are able to be withdrawn from the account. If initializeClient or openHallidayPayments was called prior, and withdrawInputs is not passed, the prior outputs value will be used. |
withdrawFunder (required) | FunderRole | Funder wallet configuration with signing functions. |
withdrawDestinationAddress (optional) | string | Target address for the withdraw. If not defined, the withdrawFunder address is used as the destination of the withdrawal. |
copy
Show Account History
To show the past Halliday payment activity of the account in the widget, the user can click or tap the icon at the top right of the widget. This opens the Transactions & activity page of the widget. To directly open this screen in the widget, use theopenActivity method. In order to open this, a userWallet must be connected beforehand.
This example connects a wallet beforehand with the initializeClient method.
copy
openHallidayPayments method.
copy
Multiple Funders
In the scenario that a developer chooses to show multiple possible funding sources for the user, an array of funder objects can be passed toinitializeClient or openHallidayPayments.
Funders can be any address that is expected to fund a payment. The SDK widget will take account of token balances at the time of a payment so the user can select a possible input token and amount.
Naming Each Funder
To differentiate funders in the UI, a name string can be supplied that will be shown to the user. Pass walletName as a member of each funder object.
copy

Embedding the SDK Widget
By default, the Payments Widget opens as a modal overlaying the web page. Another option is to embed it within a page. This can be done by providing one option:targetElementId.
copy
Customizing styles
Halliday supports setting custom styles on the Payments Widget in order to match an application’s existing user interface.copy



