UI | Cosmos | Connect to App or Mini Wallet | Wallet Integration | DEX API Guide

·

Integrating a secure and seamless wallet connection into your decentralized application (DApp) is essential for delivering a superior user experience. With the OKX Connect SDK, developers can easily implement wallet connectivity for both standalone apps and Telegram Mini Wallets, supporting multiple blockchain ecosystems including Cosmos and EVM-compatible chains.

This comprehensive guide walks you through the complete integration process—from initialization to transaction signing—with clear examples, best practices, and critical error handling insights.


Installation and Initialization

To begin integrating OKX Connect, ensure the OKX App is updated to version 6.94.0 or later. Integration can be performed using npm:

npm install okx-connect

Before establishing a wallet connection, initialize the OKXUniversalConnectUI object. This object enables UI rendering for key actions such as connecting wallets and signing transactions.

Request Parameters

👉 Discover how to seamlessly embed wallet connectivity into your DApp today.

Return Value


Connect to a Wallet

Establish a secure connection to retrieve the user’s wallet address and enable transaction signing capabilities.

Request Parameters

Return Value

Returns a Promise resolving to:


Connect and Sign in One Step

Streamline user onboarding by connecting the wallet and requesting a signature simultaneously—ideal for authentication flows.

Request Parameters

Includes all parameters from Connect to Wallet, plus:

The result is delivered via the 'connect_signResponse' event.

Return Value

Same as standard connection, with added assurance that signing was initiated during handshake.

👉 Learn how one-click sign-in boosts user retention in Web3 apps.


Check Wallet Connection Status

Determine whether a wallet is currently connected.

Return Value

Use this to conditionally render UI elements like "Connect Wallet" buttons or balance displays.


Prepare Transactions with OKXCosmosProvider

Before sending transactions, instantiate the OKXCosmosProvider using the initialized OKXUniversalConnectUI:

const provider = new OKXCosmosProvider(okxConnectUI);

This provider enables interaction with Cosmos-based blockchains, including querying balances, building transactions, and submitting them.


Retrieve Account Information

Fetch public wallet details for a specific Cosmos chain.

Request Parameters

Return Value

Returns an object containing:

This data is essential for constructing signed transactions or verifying ownership.


Sign Arbitrary Messages

Authenticate users by signing plaintext messages—commonly used for login systems.

Request Parameters

Return Value

Promise resolving to:

Use this for secure off-chain authentication without exposing private keys.


Sign Using Amino Encoding

Sign transactions using the legacy Amino encoding format, widely used across Cosmos SDK chains.

Request Parameters

⚠️ Note: The signDoc must follow strict Amino formatting rules.

Return Value

Ideal for compatibility with older Cosmos clients and exchanges.


Sign Using Direct Mode (Protobuf)

Leverage modern Protobuf-based signing for improved efficiency and security.

Request Parameters

Return Value

Same as Amino: signed transaction and signature object.

Direct mode reduces parsing overhead and is recommended for new DApps.


Disconnect Wallet

Terminate the active session and disconnect the wallet.

await okxConnectUI.disconnect();

Always disconnect before attempting to reconnect or switch accounts—this ensures clean session management and avoids conflicts.


Event Handling

Monitor key events during the connection lifecycle:

Proper event listening enhances UX by providing real-time feedback.


Error Codes and Troubleshooting

Handle exceptions gracefully using standardized error codes:

Error CodeMeaning
OKX_CONNECT_ERROR_CODES.UNKNOWN_ERRORUnexpected internal error
OKX_CONNECT_ERROR_CODES.ALREADY_CONNECTED_ERRORAttempt to connect while active session exists
OKX_CONNECT_ERROR_CODES.NOT_CONNECTED_ERRORAction requires connection but none exists
OKX_CONNECT_ERROR_CODES.USER_REJECTS_ERRORUser denied request
OKX_CONNECT_ERROR_CODES.METHOD_NOT_SUPPORTEDRequested method not available
OKX_CONNECT_ERROR_CODES.CHAIN_NOT_SUPPORTEDChain not supported by wallet
OKX_CONNECT_ERROR_CODES.WALLET_NOT_SUPPORTEDIncompatible wallet type
OKX_CONNECT_ERROR_CODES.CONNECTION_ERRORNetwork or handshake failure

Log these errors for debugging and display user-friendly messages in your UI.


Frequently Asked Questions

How do I support multiple languages in my DApp?

Set the language field during initialization. Supported values include 'en_US', 'zh_CN', 'es_ES', and others. The SDK will render prompts in the selected language.

Can I use SVG icons for my app?

No. Only PNG and ICO formats are supported. Use a 180x180px PNG for optimal display quality.

What is the difference between Amino and Direct signing?

Amino uses JSON-based encoding and is widely compatible. Direct mode uses Protobuf for smaller payloads and better performance—preferred for modern apps.

Is Telegram Mini Wallet supported?

Yes. Use the tmaReturnUrl parameter to control navigation after signing. Set to 'back' to return to the chat, or 'none' to stay in place.

How do I handle unsupported chains?

Use optionalNamespaces for non-critical chains. If those aren’t supported, the connection still proceeds—unlike with required namespaces.

Can I connect to non-Cosmos chains?

Yes. Use 'eip155' namespace for Ethereum and EVM-compatible chains like BSC, Polygon, etc.

👉 Start building with full Cosmos and EVM support now—explore OKX Connect.