Integrating a Bitcoin-compatible chain into your decentralized application (DApp) has never been easier. With OKX Connect, developers can seamlessly link their apps to secure wallet solutions—whether through a full mobile App Wallet or the lightweight OKX Mini Wallet within Telegram. This guide walks you through the complete integration process using the OKX Universal Connect UI, offering step-by-step instructions for connection, transaction signing, account management, and more.
Whether you're building on Bitcoin, Fractal, or other BTC-ecosystem chains, this documentation ensures smooth interoperability while maintaining user experience and security.
Installation and Initialization
To begin integrating OKX Connect into your DApp, ensure that users have the OKX App version 6.92.0 or higher installed. This is required to access the latest features of the Universal Connect UI.
You can install the SDK via npm:
npm install @okxweb3/connectBefore initiating any wallet interaction, create an instance of OKXUniversalConnectUI. This object provides the necessary interface for connecting wallets, sending transactions, and managing user sessions.
Request Parameters
dappMetaData – Object
name(string): Your DApp’s display name. Not used as a unique identifier.icon(string): URL to your app icon in PNG or ICO format (SVG not supported). Recommended size: 180x180px.
actionsConfiguration – Object
modals:'before' | 'success' | 'error' | 'all'— Controls when alerts appear during transactions. Default:'before'.returnStrategy:'none' | {custom-scheme}://{host}'— Defines deep link behavior after signing (e.g.,tg://resolvefor Telegram).tmaReturnUrl:'back' | 'none' | {custom-scheme}'— Return policy for Telegram Mini App; default is'back'.
uiPreferences – Object
theme:THEME.DARK,THEME.LIGHT, or'SYSTEM'language: Supported locales include'en_US','zh_CN','es_ES','fr_FR', and more. Defaults to'en_US'.
Return Value
OKXUniversalConnectUI— The initialized UI interface object used for all subsequent operations.
👉 Discover how to set up seamless wallet connections in minutes
Connecting to the OKX Wallet
Establishing a wallet connection allows your DApp to retrieve the user's address and obtain permission to sign transactions securely.
Request Parameters
connectParams – ConnectParams
namespaces:{ [namespace: string]: ConnectNamespace }- Use
'eip155'for EVM chains or'btc'for Bitcoin-compatible chains. - If any requested chain isn't supported, the wallet will reject the connection.
- Use
chains: string[] — List of chain IDs (e.g.,["btc:mainnet"]).defaultChain?: string — Preferred chain for initial session.optionalNamespaces: Optional fallback namespaces; connection proceeds even if these aren't supported.sessionConfig:redirect: string — Deep link to redirect post-connection (usetg://resolvefor Telegram Mini Apps).
Return Value
A Promise resolving to:
topic: Session identifiernamespaces: Connected namespace detailschains: Active chain listaccounts: Wallet addresses involvedmethods: Supported signing methodsdefaultChain: Current default chaindappInfo: Name and icon of your DApp
Connect and Sign in One Step
This method combines wallet connection with immediate data signing—ideal for authentication flows. The result triggers the 'connect_signResponse' event.
Additional Parameters
signRequest – RequestParams[] (max one method at a time)
method: e.g.,'btc_signMessage'chainId: Must match one from the requested namespacesparams: Method-specific parameters (e.g., message to sign)
Returns the same session data as standard connection, plus signed output via event callback.
Check Wallet Connection Status
Determine whether a wallet is currently connected.
Return Value
- boolean:
trueif connected, otherwisefalse
Use this before attempting transactions or fetching account data.
Prepare for Trading Operations
After establishing a session, instantiate an OKXBtcProvider object using the initialized okxUniversalConnectUI. This provider enables Bitcoin-specific actions like sending BTC or signing PSBTs.
const btcProvider = new OKXBtcProvider(okxUniversalConnectUI);Retrieve Wallet Account Information
Fetch public wallet details such as address and public key.
Request Parameters
chainId: e.g.,'btc:mainnet','fractal:mainnet'
Return Value
Object
address: User’s wallet addresspublicKey: Associated public key
Ideal for displaying user identity or preparing transaction inputs.
👉 Learn how to integrate Bitcoin wallet functionality effortlessly
Sign a Message
Securely sign arbitrary messages—commonly used for login authentication.
Parameters
chain: Target chain (e.g.,'btc:mainnet')signStr: Message string to signtype?: Signing standard —'ecdsa'(default) or'bip322-simple'
Return Value
- Promise
: Signature in hex format
Supports both legacy and Taproot-based addresses.
Send Bitcoin Transactions
Enable users to transfer BTC directly from your DApp.
Parameters
chainId: Chain identifier (required)toAddress: Recipient addresssatoshis: Amount in satoshisoptions?:feeRate: Custom fee rate in sat/vB
Return Value
- Promise
: Transaction hash ( txid)
Perfect for peer-to-peer transfers, payments, or withdrawals.
Sign PSBT (Partially Signed Bitcoin Transaction)
Sign pre-built transactions without broadcasting—giving full control over transaction flow.
Parameters
chain: e.g.,'btc:mainnet'psbtHex: Hex-encoded PSBToptions:autoFinalized: Finalize PSBT after signing (default:true)toSignInputs[]: Specify which inputs to sign with:index,address,publicKey, optionalsighashTypes, anddisableTweakSignerfor Taproot
Return Value
- Promise
: Signed PSBT in hex
Useful for multi-sig setups or advanced DeFi interactions.
Sign Multiple PSBTs
Batch-sign several PSBTs in one request.
Parameters
chainId: Target chainpsbtHexs: Array of PSBT hex stringsoptions[]: Per-PSBT signing options (same structure as above)
Return Value
- Promise<string[]>: Array of signed PSBTs
Efficient for batch operations like NFT mints or portfolio rebalancing.
Sign and Broadcast PSBT
Signs the transaction and automatically pushes it to the network.
Requires OKX App version 6.93.0 or later
Parameters
Same as signPsbt, with automatic broadcast upon completion.
Return Value
Promise:
txhash: Transaction ID on blockchainsignature: Hex string of signed PSBT
Ideal for fire-and-forget transactions where confirmation is critical.
Disconnect Wallet
Terminate the active session and disconnect the wallet.
await okxUniversalConnectUI.disconnect();Always call this when switching accounts or logging out to maintain security hygiene.
Event Handling
Listen to real-time events such as:
'connect_signResponse'— After successful sign+connect request'session_update'— Chain or account changes'disconnect'— Session ended
Implementing event listeners enhances UX by reflecting state changes instantly.
Error Codes Reference
Handle exceptions gracefully using standardized error codes:
OKX_CONNECT_ERROR_CODES.UNKNOWN_ERROR– Unexpected failureALREADY_CONNECTED_ERROR– Prevent duplicate connectionsNOT_CONNECTED_ERROR– No active session foundUSER_REJECTS_ERROR– User denied requestMETHOD_NOT_SUPPORTED– Unsupported operation on chainCHAIN_NOT_SUPPORTED– Chain not available in walletCONNECTION_ERROR– Network or handshake failure
Log these for debugging and inform users clearly.
Frequently Asked Questions
Can I use OKX Connect in Telegram Mini Apps?
Yes! Users can stay within Telegram and use the OKX Mini Wallet. Just configure the redirect URL with tg://resolve in session settings.
What Bitcoin chains are supported?
Currently supports Bitcoin Mainnet, Testnet, and Fractal Bitcoin. Ensure correct chain IDs like btc:mainnet.
Is SVG icon supported during initialization?
No. Only PNG or ICO formats are accepted for the DApp icon. Use a 180x180px image for best display.
How do I handle user rejection during signing?
Catch the error with code USER_REJECTS_ERROR. Display a gentle prompt encouraging retry without disrupting flow.
Can I customize the modal appearance?
Yes. Set theme in uiPreferences to 'DARK', 'LIGHT', or 'SYSTEM'. Modals adapt to user preferences automatically.
Does OKX support BIP322 signing?
Yes. Use { type: 'bip322-simple' } in signMessage() to enable upgraded message signing compatible with modern wallets.
👉 Start integrating today—unlock powerful Bitcoin capabilities