In addition to the SDK, we offer a user-friendly UI interface for seamless wallet integration. If your DApp operates within Telegram, users can choose to:
- Open the mobile App Wallet
- Stay in Telegram and launch the OKX Mini Wallet
Installation and Initialization
Ensure the OKX App is updated to version 6.92.0 or later for full functionality.
Integration Steps:
Use npm to integrate OKX Connect into your DApp:
npm install okx-connect
- Create a UI interface object to handle wallet connections and transactions.
Request Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| dappMetaData
| Object | App metadata (name, icon URL) |
| actionsConfiguration
| Object | Modal display settings and return strategies |
| uiPreferences
| Object | Theme (dark/light/system) and language (default: en_US
) |
Example:
const ui = new OKXUniversalConnectUI({
dappMetaData: {
name: "My DApp",
icon: "https://example.com/icon.png"
},
actionsConfiguration: {
modals: ['before', 'success'],
returnStrategy: 'tg://resolve'
},
uiPreferences: {
theme: 'SYSTEM',
language: 'en_US'
}
});
Connecting to a Wallet
Request Parameters:
| Parameter | Description |
|-----------|-------------|
| namespaces
| Required chains (e.g., eip155
for EVM, aptos
for Aptos) |
| optionalNamespaces
| Optional chains for fallback support |
| sessionConfig
| Redirect URL post-connection (e.g., tg://resolve
for Telegram) |
Return Value:
topic
: Session IDaccounts
: Wallet addressesmethods
: Supported wallet methods
Example:
const session = await ui.connect({
namespaces: {
aptos: { chains: ['aptos:1'], defaultChain: 'aptos:1' }
},
sessionConfig: { redirect: 'tg://resolve' }
});
Wallet Signing
Methods:
Sign Message:
const signedMessage = await provider.signMessage({ message: "Hello, Aptos!", nonce: "12345" }, 'aptos:1');
Sign Transaction:
const txHash = await provider.signAndSubmitTransaction(txData, 'aptos:1');
Key Parameters:
chain
: Specify the blockchain (mandatory for multi-chain connections).
FAQ
How do I check if a wallet is connected?
const isConnected = provider.isConnected();
How do I disconnect a wallet?
provider.disconnect();
What are common error codes?
| Code | Description |
|------|-------------|
| UNKNOWN_ERROR
| Unexpected issue |
| USER_REJECTS_ERROR
| User declined the request |
| CHAIN_NOT_SUPPORTED
| Unsupported blockchain |
๐ Explore more about Aptos integration
Event Handling and Error Codes
Events:
connect_signResponse
: Callback for signature results.
Error Handling:
try {
await provider.signTransaction(txData);
} catch (error) {
console.error("Error:", error.code);
}
Best Practices
- Use natural keyword integration (e.g., "Aptos wallet," "DEX API").
- Avoid keyword stuffing.
- Prioritize user experience with clear headings and concise language.
๐ Get started with OKX Wallet