OKX Wallet SDK: EVM-Compatible Chain Integration Guide

·

Installation and Initialization

Ensure your OKX App is updated to version 6.88.0 or later for seamless integration.

To integrate OKX Connect into your DApp, use npm:

npm install @okx/web3-connect

Before connecting, initialize the provider:

OKXUniversalProvider.init({
  DAppMetaData: {
    name: "YourAppName",  // Non-unique identifier
    icon: "https://your-app-icon.png"  // 180x180px PNG recommended
  }
});

Parameters:

Returns:


Connect to Wallet

Use connect() to retrieve the wallet address for transaction signing:

okxUniversalProvider.connect(connectParams: ConnectParams);

Parameters:

Returns:


Check Wallet Connection Status

Verify connectivity with:

const isConnected = okxUniversalProvider.isConnected();

Returns:


Send Transactions and Signatures

Call wallet methods like personal_sign or eth_sendTransaction:

okxUniversalProvider.request({
  method: "personal_sign",
  params: [message, account],
  chain: "eip155:1"
});

Supported Methods:


Custom RPC Configuration

Configure RPC endpoints in connectParams.rpcMap for advanced EVM requests:

rpcMap: {
  "eip155:1": "https://mainnet-rpc.com",
  "eip155:137": "https://polygon-rpc.com"
}

Set Default Network

Specify a default chain for operations:

defaultChain: "eip155:1"  // Ethereum Mainnet

Disconnect Wallet

Terminate the session:

okxUniversalProvider.disconnect();

Error Handling

| Error Code | Description |
|------------|-------------|
| UNKNOWN_ERROR | Unexpected issue. |
| USER_REJECTS_ERROR | User declined the request. |
| CHAIN_NOT_SUPPORTED | Unsupported chain ID. |


FAQs

1. How do I handle unsupported chains?

Add the chain to optionalNamespaces or use wallet_addEthereumChain to prompt the user.

2. Can SVG icons be used for DApp metadata?

No. Use PNG/ICO formats (180x180px recommended).

3. What’s the difference between eth_accounts and eth_requestAccounts?

Both return addresses, but eth_requestAccounts triggers a wallet connection prompt if not already connected.

👉 Explore more OKX Web3 features


This guide ensures EVM-compatible wallet integration with OKX SDK, optimized for DEX APIs and Mini App connectivity. For advanced use cases, refer to our official documentation.


**Key Improvements**:  
1. **SEO**: Added keywords like *EVM-compatible chain*, *DEX API*, and *Wallet Integration* naturally.  
2. **Structure**: Used Markdown headings, code blocks, and tables for clarity.  
3. **FAQs**: Included 3 critical Q&A pairs.  
4. **Anchor Text**: Added a clickable CTA linking to OKX.  
5. **Error Handling**: Tabulated for quick reference.