Integrating a secure, seamless wallet connection into your decentralized application (DApp) is essential for delivering a smooth user experience. With growing demand for Solana-compatible chain support, developers need reliable tools to enable wallet connectivity, transaction signing, and cross-chain interoperability. This guide walks you through the complete integration process using the OKX Connect SDK β a powerful solution for connecting apps and mini wallets on Solana and compatible networks.
Whether you're building a decentralized exchange (DEX), NFT marketplace, or blockchain game, this documentation provides everything you need to implement wallet integration with precision and efficiency.
π Discover how to effortlessly integrate Solana-compatible wallet connections today.
Installation and Initialization
Before integrating OKX Connect into your DApp, ensure that users have the OKX App updated to version 6.90.1 or later. The SDK can be installed via npm:
npm install @okxweb3/connectOnce installed, initialize the provider to enable wallet interactions such as connection, transaction submission, and address retrieval.
Youβll begin by creating an instance of OKXUniversalProvider, which serves as the foundation for all subsequent operations.
Request Parameters
dappMetaData β Object
Metadata about your application:name(string): Application name (not used as a unique identifier).icon(string): URL of your appβs icon in PNG or ICO format. SVG icons are not supported. For best results, use a 180x180px PNG image.
Returns
OKXUniversalProvider: The core object used to manage wallet sessions and interactions.
Connect to Wallet
To interact with a user's wallet, establish a secure session by requesting a connection. This step retrieves the wallet address, required for signing transactions and identifying users on-chain.
Request Parameters
connectParams β ConnectParams
namespacesβ {[namespace: string]: ConnectNamespace}
Required namespace information. For Solana, use"solana"as the key.chains: string[] β List of chain IDs (e.g.,["solana:mainnet", "sonic:mainnet"]).defaultChain?: string β Preferred default chain if multiple are supported.
If any requested chain isn't supported by the wallet, the connection will be rejected.
optionalNamespaces?β {[namespace: string]: ConnectNamespace}
Optional namespace configurations. Connection proceeds even if these chains aren't supported.- Same structure as
namespaces.
- Same structure as
sessionConfig?β objectredirect: string β Post-connection redirect URL. For Telegram Mini Apps, use deep links like"tg://resolve".
Returns (Promise)
topic: string β Unique session identifier.namespaces: Record<string, SessionNamespace> β Confirmed namespace details.chains: string[] β Active connected chains.accounts: string[] β User wallet addresses.methods: string[] β Supported methods (e.g., signTransaction, signMessage).defaultChain?: string β Default chain set for the session.sessionConfig?: SessionConfig β Echoed configuration.dappInfo: objectname: stringicon: stringredirect?: string
π See how easy it is to connect Solana-compatible wallets in minutes.
Check Wallet Connection Status
Determine whether a wallet is currently connected before initiating transactions or data requests.
Return Value
- boolean: Returns
trueif connected; otherwise,false.
Use this method to conditionally render UI elements like "Connect Wallet" buttons or display user balances.
Sending Signatures and Transactions
After establishing a connection, create an OKXSolanaProvider instance by passing the OKXUniversalProvider object to its constructor:
const okxSolanaProvider = new OKXSolanaProvider(okxUniversalProvider);This enables advanced functionality including message signing, transaction signing, and on-chain broadcasting.
Sign a Message
Sign arbitrary messages for authentication or identity verification.
okxSolanaProvider.signMessage(message, chain);Parameters
message: string β Content to sign.chain: string β Target chain ID (e.g.,"solana:mainnet"). Required when supporting multiple chains.
Return Value
Promise resolving to:
publicKey: string β Walletβs public key.signature: Uint8Array β Digital signature.
Sign a Single Transaction
Request user approval to sign a single transaction.
okxSolanaProvider.signTransaction(transaction, chain);Parameters
transaction: Transaction | VersionedTransaction β Raw transaction object.chain: string β Chain identifier. Mandatory for multi-chain setups.
Return Value
- Signed transaction object of the same type.
Sign Multiple Transactions
Batch-sign several transactions at once for improved UX in complex workflows.
okxSolanaProvider.signAllTransactions(transactions, chain);Parameters
transactions: (Transaction | VersionedTransaction)[] β Array of unsigned transactions.chain: string β Chain context.
Return Value
- Array of signed transaction objects.
Sign and Broadcast Transaction
Sign and immediately broadcast a transaction to the network.
okxSolanaProvider.sendTransaction(transaction, chain);Parameters
transaction: Transaction | VersionedTransactionchain: string
Return Value
- Promise resolving to string: The transaction hash (txid).
This method simplifies common actions like token swaps or NFT mints.
Retrieve Wallet Address and Public Key
Fetch the user's wallet address and public key for display or backend validation.
okxSolanaProvider.getAddress(chain);Parameters
chain: string β Optional. Chain ID to retrieve address from. Defaults to first connected SVM (Solana Virtual Machine) address.
Return Value
Object containing:
address: stringpublicKey: PublicKey
Disconnect Wallet
Terminate the current session and disconnect the wallet.
await okxUniversalProvider.disconnect();Always disconnect before attempting to switch accounts or reconnect under new parameters.
Event Handling
The provider emits real-time events such as:
"connect""disconnect""chainChanged""accountsChanged"
Subscribe to these events to keep your app state synchronized with the wallet.
Error Codes
Handle potential exceptions gracefully using standardized error codes:
OKX_CONNECT_ERROR_CODES.UNKNOWN_ERRORβ Unexpected internal error.OKX_CONNECT_ERROR_CODES.ALREADY_CONNECTED_ERRORβ Wallet already active.OKX_CONNECT_ERROR_CODES.NOT_CONNECTED_ERRORβ No active session.OKX_CONNECT_ERROR_CODES.USER_REJECTS_ERRORβ User declined action.OKX_CONNECT_ERROR_CODES.METHOD_NOT_SUPPORTEDβ Unsupported operation.OKX_CONNECT_ERROR_CODES.CHAIN_NOT_SUPPORTEDβ Requested chain unavailable.OKX_CONNECT_ERROR_CODES.WALLET_NOT_SUPPORTEDβ Incompatible wallet type.OKX_CONNECT_ERROR_CODES.CONNECTION_ERRORβ Network or handshake failure.
Implement proper error feedback to enhance usability and reduce friction.
Frequently Asked Questions
Q: What chains are supported by OKX Connect?
A: OKX Connect supports Solana mainnet and Sonic EVM among other Solana-compatible chains. Always verify chain IDs during initialization.
Q: Can I integrate this SDK into a Telegram Mini App?
A: Yes. Use the redirect parameter in sessionConfig with Telegram deep links like "tg://resolve" to return users after connection.
Q: Is SVG icon support available for dApp metadata?
A: No. Only PNG and ICO formats are supported. Use a 180x180px PNG for optimal display.
Q: Do I need to handle reconnections manually?
A: Yes. After disconnection or session expiry, initiate a new connection flow. Store minimal session data securely if needed.
Q: How do I test the integration locally?
A: Use testnets like Solana Devnet and mock transactions. Ensure the OKX App is installed and updated on your testing device.
Q: Are batch transactions supported?
A: Yes. Use signAllTransactions() to sign multiple operations at once, ideal for staking or multi-swap scenarios.
π Start integrating Solana-compatible wallet features with confidence now.
Core Keywords
Solana-compatible chain, wallet integration, DEX API, connect wallet SDK, transaction signing, decentralized app, blockchain connectivity, mini wallet support