UI Integration for EVM-Compatible Chains: Connect Your DApp or Mini Wallet

·

Integrating a seamless and secure wallet connection into your decentralized application (DApp) is essential for delivering a smooth user experience. With the OKX Connect SDK, developers can easily implement wallet connectivity for EVM-compatible blockchains, enabling users to sign transactions, manage assets, and interact with Web3 services across platforms—including mobile apps and Telegram Mini Wallets.

This guide walks you through the full integration process, from initialization to disconnecting sessions, with clear code examples and best practices. Whether you're building a DApp, a mini-app on Telegram, or integrating multi-chain support, this documentation ensures your project remains compatible, user-friendly, and efficient.


Installation via npm

To begin integrating OKX Connect into your project, install the SDK using npm:

npm install @okxweb3/connect

Ensure your environment supports modern JavaScript (ES6+) and that you're using a bundler like Webpack or Vite for frontend integration.

👉 Discover how to set up wallet connectivity in under 5 minutes


Initialize the SDK

Before connecting to any wallet, initialize the OKXUniversalConnectUI instance with configuration options tailored to your app’s needs.

Request Parameters

Return Value

Example

import { OKXUniversalConnectUI } from '@okxweb3/connect';

const okxConnect = new OKXUniversalConnectUI({
  dappMetaData: {
    name: 'My Web3 DApp',
    icon: 'https://example.com/icon.png'
  },
  actionsConfiguration: {
    modals: 'all',
    returnStrategy: 'myapp://return'
  },
  tmaReturnUrl: 'back',
  uiPreferences: {
    theme: 'SYSTEM',
    language: 'en_US'
  },
  restoreConnection: true
});

Connect to a Wallet

Establish a secure session by requesting access to the user’s wallet address and transaction signing capabilities.

Request Parameters

Return Value

A Promise resolving to:

Example

const session = await okxConnect.connect({
  namespaces: {
    eip155: {
      chains: ['eip155:1'],
      methods: ['personal_sign'],
      events: ['chainChanged', 'accountsChanged']
    }
  },
  rpcMap: {
    'eip155:1': 'https://mainnet.infura.io/v3/YOUR_KEY'
  }
});

👉 See real-world DApp integration examples now


Sign Data and Connect

Combine connection with immediate data signing, such as signing login messages.

Additional Parameter

The result triggers the 'connect_signResponse' event.


Check Connection Status

Verify whether a wallet is currently connected.

Return Value

Example

if (okxConnect.isConnected()) {
  console.log('Wallet is connected');
}

Prepare and Send Transactions

Send requests for signatures or blockchain transactions.

Parameters

Return Value

Same as standard EVM transaction response—supports all EIP-155 compliant chains.


Use Custom RPC Endpoints

For non-standard or private EVM networks, configure custom RPCs via rpcMap during connection:

rpcMap: {
  'eip155:99999': 'https://my-custom-chain-rpc.com'
}

Ensure the chain ID is listed in chains.


Manage Session Information

Retrieve details of the active session:

const sessionInfo = okxConnect.getSessionInfo();
console.log(sessionInfo.accounts);

Useful for UI updates and state management.


Update UI Settings Dynamically

Change theme or language post-initialization:

okxConnect.setTheme('DARK');
okxConnect.setLanguage('zh_CN');

Also configurable during initialization.


Set Default Chain

When supporting multiple chains, define the default:

okxConnect.setDefaultChain('eip155:137'); // Polygon

All unsigned actions will default to this chain unless specified otherwise.


Disconnect Wallet

Terminate the current session securely:

await okxConnect.disconnect();

Clears local session data and notifies the wallet.


Handle Events

Listen for real-time updates:

okxConnect.on('connect', (data) => console.log('Connected:', data));
okxConnect.on('disconnect', () => console.log('Disconnected'));
okxConnect.on('accountsChanged', (accounts) => updateUI(accounts));

Supported events: connect, disconnect, accountsChanged, chainChanged.


Error Handling

Common error codes during interactions:

Handle these gracefully in your UI to improve user experience.


Frequently Asked Questions

How do I support custom EVM networks?

Include your chain in optionalNamespaces and provide an RPC URL via rpcMap. If the wallet doesn’t recognize it, use wallet_addEthereumChain later.

Can I integrate with Telegram Mini Wallets?

Yes. Set tmaReturnUrl: 'back' and use Telegram-safe deep links. The SDK fully supports TMA (Telegram Mini App) environments.

What permissions does OKX Connect request?

Only basic account access and signing permissions. No private keys are exposed. Users approve each action.

Is SVG icon supported for DApp metadata?

No. Only PNG or ICO formats are accepted. Use a 180x180px PNG for best results.

How do I restore a previous session?

Enable restoreConnection: true during initialization. The SDK checks for valid sessions on load.

Which EVM chains are supported?

All EIP-155 compliant chains—including Ethereum, BSC, Polygon, Arbitrum, Optimism, and custom networks.


👉 Start integrating today—get full SDK access instantly