@dogeos/dogeos-sdk 3.0.8 → 3.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,220 +1,418 @@
1
- # dogeos-sdk
1
+ # Wallet Connect Kit
2
2
 
3
- A lightweight React SDK for integrating crypto wallet connections into your app. It ships with a configurable wallet list modal and basic account actions. Currently focused on EVM chains, built on top of `@tomo-inc/wallet-adaptor-base`, and supports custom wallets and chain configuration.
3
+ A lightweight React SDK for integrating crypto wallet connection functionality into your applications. It provides a configurable wallet list modal and basic account operations.
4
4
 
5
- ## On This Page
5
+ ## Requirements
6
6
 
7
- - [Installation](#installation)
8
- - [Setup Provider](#setup-provider)
9
- - [Displaying the Modal](#displaying-the-modal)
10
- - [Account Actions](#account-actions)
11
- - [Additional Reference](#additional-reference)
12
-
13
- ---
7
+ - React 18 or higher
8
+ - TypeScript 5 or higher (recommended)
14
9
 
15
10
  ## Installation
16
11
 
12
+ Install Wallet Connect Kit using your preferred package manager:
13
+
17
14
  ```bash
18
15
  npm install @dogeos/dogeos-sdk
19
-
20
16
  ```
21
17
 
22
- Or using yarn:
18
+ ```bash
19
+ pnpm add @dogeos/dogeos-sdk
20
+ ```
23
21
 
24
22
  ```bash
25
23
  yarn add @dogeos/dogeos-sdk
26
-
27
24
  ```
28
25
 
29
- Or using pnpm:
26
+ ### Dependencies
30
27
 
31
- ```bash
32
- pnpm add @dogeos/dogeos-sdk
28
+ Wallet Connect Kit requires the following peer dependencies:
33
29
 
34
- ```
30
+ - `react >= 18`
31
+ - `react-dom >= 18`
32
+ - `wagmi >= 2.0.0` (optional, if using WagmiProvider)
35
33
 
36
- ---
34
+ ## Quick Start
37
35
 
38
- ## Setup Provider
36
+ ### 0. Prerequisites
39
37
 
40
- ### Use React
38
+ This guide assumes you have already installed Wallet Connect Kit. If you haven't, please refer to the installation steps above.
41
39
 
42
- Wrap your app with `WalletConnectProvider` at the root component.
40
+ ### 1. Setup Provider
41
+
42
+ First, wrap your app root component with `WalletConnectProvider`:
43
43
 
44
44
  ```tsx
45
45
  // App.tsx
46
46
  import React from "react";
47
47
  import { WalletConnectProvider } from "@dogeos/dogeos-sdk";
48
- import type { WalletConfig, WalletConnectKitConfig, WalletConnectProtocolConfig, clientId } from "@dogeos/dogeos-sdk"
49
48
 
50
- const config = {
51
- connectors?: WalletConfig[];
52
- // Supported chains (for EVM, compatible with viem/Chain)
53
- chains?: Partial<Record<ChainType, EvmChain[] | any[]>>;
54
- walletConnectConfig?: WalletConnectProtocolConfig;
55
- clientId?: string;
56
- } as WalletConnectConfig;
49
+ const dogeConfig = {
50
+ ...config,
51
+ clientId: 'your-client-id'
52
+ }
57
53
 
58
54
  export default function App() {
59
55
  return (
60
- <WalletConnectProvider config={config}>
56
+ <WalletConnectProvider config={dogeConfig}>
61
57
  <YourApp />
62
58
  </WalletConnectProvider>
63
59
  );
64
60
  }
65
61
  ```
66
62
 
67
- Embedded Wallet Evm Provider Method
63
+ ### 2. Connect Wallet
68
64
 
69
- support:
65
+ Use the `useWalletConnect` hook to open the wallet connection modal and manage connection state:
70
66
 
71
- ```
72
- // methods
73
- connect;
74
- disconnect;
75
- getChainId;
76
- switchChain;
77
- signMessage(siweSign);
78
- signTypedData;
79
- eth_signTransaction;
80
- sendTransaction;
81
- ```
67
+ ```tsx
68
+ // ConnectButton.tsx
69
+ import React from "react";
70
+ import { useWalletConnect } from "@dogeos/dogeos-sdk";
82
71
 
83
- -[MateMask Provider Doc](#https://docs.metamask.io/wallet/reference/provider-api/)
72
+ export function ConnectButton() {
73
+ const { openModal, isConnected, disconnect, isConnecting } =
74
+ useWalletConnect();
84
75
 
85
- ---
76
+ if (isConnecting) {
77
+ return <button disabled>Connecting...</button>;
78
+ }
86
79
 
87
- ## Displaying the Modal
80
+ return (
81
+ <button onClick={() => (isConnected ? disconnect() : openModal())}>
82
+ {isConnected ? "Disconnect" : "Connect Wallet"}
83
+ </button>
84
+ );
85
+ }
86
+ ```
88
87
 
89
- To display the modal for wallet connection, you can use the hooks provided by **dogeos-sdk**.
88
+ ### 3. Read Account Information
90
89
 
91
- ### Example Code
90
+ Use the `useAccount` hook to get the currently connected account information:
92
91
 
93
92
  ```tsx
93
+ // AccountInfo.tsx
94
94
  import React from "react";
95
- import { useWalletConnect } from "@dogeos/dogeos-sdk";
95
+ import { useAccount } from "@dogeos/dogeos-sdk";
96
+
97
+ export function AccountInfo() {
98
+ const { address, chainId, chainType, currentWallet } = useAccount();
96
99
 
97
- const ConnectButton = () => {
98
- const { openModal, isConnected, disconnect } = useWalletConnect();
100
+ if (!address) {
101
+ return <div>No wallet connected</div>;
102
+ }
99
103
 
100
104
  return (
101
- <button onClick={() => (isConnected ? disconnect() : openModal())}>
102
- {isConnected ? "Disconnect" : "Connect Wallet"}
103
- </button>
105
+ <div>
106
+ <div>Address: {address}</div>
107
+ <div>Chain ID: {chainId}</div>
108
+ <div>Chain Type: {chainType}</div>
109
+ <div>Wallet: {currentWallet?.info?.name}</div>
110
+ </div>
104
111
  );
105
- };
106
-
107
- export default ConnectButton;
112
+ }
108
113
  ```
109
114
 
110
- ### MyDoge Social Login Experience
115
+ ### 4. Sign Message
111
116
 
112
- When using the MyDoge theme, the modal will first display the social login interface, supporting:
117
+ Use the `signMessage` method from the `useAccount` hook to sign messages:
113
118
 
114
- - **Twitter Login** - Quick login with Twitter/X account
115
- - **Google Login** - Quick login with Google account
116
- - **Email Login** - Login with email address
119
+ ```tsx
120
+ // SignMessageButton.tsx
121
+ import React from "react";
122
+ import { useAccount } from "@dogeos/dogeos-sdk";
117
123
 
118
- Users can also select "Or connect a wallet" to directly connect traditional crypto wallets.
124
+ export function SignMessageButton() {
125
+ const { signMessage, address } = useAccount();
126
+
127
+ const handleSignMessage = async () => {
128
+ if (!signMessage) {
129
+ console.error("Signing functionality not available");
130
+ return;
131
+ }
132
+
133
+ try {
134
+ const signature = await signMessage({
135
+ message: "Hello Tomo Wallet",
136
+ });
137
+ console.log("Signature result:", signature);
138
+ } catch (error) {
139
+ console.error("Signing failed:", error);
140
+ }
141
+ };
119
142
 
120
- ---
143
+ if (!address) {
144
+ return null;
145
+ }
121
146
 
122
- ## Account Actions
147
+ return <button onClick={handleSignMessage}>Sign Message</button>;
148
+ }
149
+ ```
123
150
 
124
- ### Reading Account Info and Signing
151
+ ### 5. Sign In with Wallet (SIW)
125
152
 
126
- After connecting a wallet, you can use the `useAccount` hook to access account information and perform signing operations.
153
+ Use the `signInWithWallet` method to sign in with wallet and obtain an authentication token:
127
154
 
128
155
  ```tsx
156
+ // SignInButton.tsx
129
157
  import React from "react";
130
158
  import { useAccount } from "@dogeos/dogeos-sdk";
131
159
 
132
- export function AccountInfo() {
133
- const { address, chainId, signMessage, signInWithWallet } = useAccount();
134
-
135
- const onSignMessage = async () => {
136
- // Message signing for verification
137
- const sig = await signMessage?.({ message: "Hello MyDoge" });
138
- console.log("signature:", sig);
160
+ export function SignInButton() {
161
+ const { signInWithWallet, address } = useAccount();
162
+
163
+ const handleSignIn = async () => {
164
+ try {
165
+ const token = await signInWithWallet();
166
+ console.log("Authentication token:", token);
167
+ // Save token to localStorage or send to backend
168
+ } catch (error) {
169
+ console.error("Sign in failed:", error);
170
+ }
139
171
  };
140
172
 
141
- const onSignin = async () => {
142
- // Sign in with wallet to get a token
143
- const token = await signInWithWallet();
144
- console.log("token:", token);
145
- };
173
+ if (!address) {
174
+ return null;
175
+ }
176
+
177
+ return <button onClick={handleSignIn}>Sign In with Wallet</button>;
178
+ }
179
+ ```
146
180
 
181
+ ## Configuration
182
+
183
+ `WalletConnectProvider` accepts an optional `config` prop to customize the SDK's behavior.
184
+
185
+ ### Basic Configuration
186
+
187
+ ```tsx
188
+ import { WalletConnectProvider } from "@dogeos/dogeos-sdk";
189
+ import type { WalletConnectKitConfig } from "@dogeos/dogeos-sdk";
190
+
191
+ const dogeConfig: WalletConnectKitConfig = {
192
+ // WalletConnect project ID (obtain from https://cloud.walletconnect.com)
193
+ walletConnectProjectId: "your-project-id",
194
+
195
+ clientId: "your-client-id",
196
+ // Application metadata
197
+ metadata: {
198
+ name: "My DApp",
199
+ description: "My decentralized application",
200
+ url: "https://myapp.com",
201
+ icons: ["https://myapp.com/icon.png"],
202
+ },
203
+ };
204
+
205
+ export function App() {
147
206
  return (
148
- <div>
149
- <div>Address: {address}</div>
150
- <div>Chain ID: {chainId}</div>
151
- <button onClick={onSignMessage}>Sign Message</button>
152
- <button onClick={onSignin}>Sign In With Wallet</button>
153
- </div>
207
+ <WalletConnectProvider config={dogeConfig}>
208
+ <YourApp />
209
+ </WalletConnectProvider>
154
210
  );
155
211
  }
156
212
  ```
157
213
 
158
- ### Available Account Actions
214
+ ### Configure Supported Chains
159
215
 
160
- - **address** - Current connected wallet address
161
- - **chainId** - Current connected chain ID
162
- - **balance** - Account balance
163
- - **chainType** - Chain type (e.g., "evm")
164
- - **currentWallet** - Current wallet information
165
- - **currentProvider** - Current wallet provider
166
- - **switchChain** - Switch network
167
- - **signMessage** - Sign message
168
- - **signInWithWallet** - Sign in with wallet
216
+ Chains are automatically loaded by default. If you need to customize chains, use the `getChains()` method:
169
217
 
170
- ---
218
+ ```tsx
219
+ import { WalletConnectProvider, getChains } from "@dogeos/dogeos-sdk";
220
+ import { useEffect, useState } from "react";
171
221
 
172
- ## Additional Reference
222
+ export function App() {
223
+ const [chains, setChains] = useState<
224
+ Awaited<ReturnType<typeof getChains>> | undefined
225
+ >(undefined);
173
226
 
174
- ### SDK Exports
227
+ useEffect(() => {
228
+ getChains().then(setChains);
229
+ }, []);
175
230
 
176
- The SDK provides the following main exports:
231
+ return (
232
+ <WalletConnectProvider config={{ chains, clientId: "your-client-id", }}>
233
+ <YourApp />
234
+ </WalletConnectProvider>
235
+ );
236
+ }
237
+ ```
177
238
 
178
- - **WalletConnectProvider** - Main provider component with optional `config` prop
179
- - **useWalletConnect** - Hook for modal control and connection state
180
- - `{ isOpenModal, openModal, closeModal, isConnected, isConnecting, error, connect, disconnect }`
181
- - **useAccount** - Hook for account info and actions
182
- - `{ address, balance, chainType, chainId, currentWallet, currentProvider, switchChain, signMessage, signInWithWallet }`
183
- - **Type Definitions**: `WalletConnectConfig`, `Chain`, `WalletProvider`, `UseAccount`, `UseWalletConnect`, `ChainType`, `ModalView`
239
+ ### Configure Custom Wallets
184
240
 
185
- ### Complete Example
241
+ Connectors are automatically loaded by default. If you need to customize connectors, use the `getConnectors()` method:
186
242
 
187
243
  ```tsx
188
- import React from "react";
189
- import {
190
- WalletConnectProvider,
191
- useWalletConnect,
192
- useAccount,
193
- } from "@dogeos/dogeos-sdk";
244
+ import { WalletConnectProvider, getConnectors } from "@dogeos/dogeos-sdk";
245
+ import { useEffect, useState } from "react";
194
246
 
195
- // Connect Button Component
196
- function ConnectButton() {
197
- const { openModal, isConnected, disconnect } = useWalletConnect();
198
- const { address } = useAccount();
247
+ export function App() {
248
+ const [connectors, setConnectors] = useState<
249
+ Awaited<ReturnType<typeof getConnectors>> | undefined
250
+ >(undefined);
199
251
 
200
- if (isConnected && address) {
201
- return (
202
- <div>
203
- <p>
204
- Connected: {address.slice(0, 6)}...{address.slice(-4)}
205
- </p>
206
- <button onClick={disconnect}>Disconnect</button>
207
- </div>
208
- );
209
- }
252
+ useEffect(() => {
253
+ getConnectors().then(setConnectors);
254
+ }, []);
255
+
256
+ return (
257
+ <WalletConnectProvider config={{ connectors , clientId: "your-client-id" }}>
258
+ <YourApp />
259
+ </WalletConnectProvider>
260
+ );
261
+ }
262
+ ```
263
+
264
+ ### Configure Login Options
265
+
266
+ You can configure supported login methods, including basic logins (email, external wallets) and social logins (Google, X/Twitter):
267
+
268
+ ```tsx
269
+ import { WalletConnectProvider } from "@dogeos/dogeos-sdk";
270
+
271
+ const config = {
272
+ login: {
273
+ // Basic login methods
274
+ basicLogins: ["email", "externalWallets"], // or ["email"] or ["externalWallets"]
275
+
276
+ // Social login methods
277
+ socialLogins: [
278
+ {
279
+ type: "google",
280
+ },
281
+ {
282
+ type: "x",
283
+ },
284
+ ],
285
+ },
286
+ clientId: "your-client-id",
287
+ };
288
+
289
+ export function App() {
290
+ return (
291
+ <WalletConnectProvider config={config}>
292
+ <YourApp />
293
+ </WalletConnectProvider>
294
+ );
295
+ }
296
+ ```
297
+
298
+ ### Configure Theme
299
+
300
+ You can customize the UI theme:
301
+
302
+ ```tsx
303
+ import { WalletConnectProvider } from "@dogeos/dogeos-sdk";
304
+ import type { ThemeConfig } from "@dogeos/dogeos-sdk";
305
+
306
+ const config = {
307
+ theme: {
308
+ themes: {
309
+ light: {
310
+ colors: {
311
+ primary: {
312
+ DEFAULT: "#FCD436",
313
+ foreground: "#FFF",
314
+ },
315
+ background: "#FFFFFF",
316
+ foreground: "#000000",
317
+ },
318
+ },
319
+ dark: {
320
+ colors: {
321
+ primary: {
322
+ DEFAULT: "#FF5CB8",
323
+ foreground: "#FFF",
324
+ },
325
+ background: "#000000",
326
+ foreground: "#FFFFFF",
327
+ },
328
+ },
329
+ },
330
+ } as ThemeConfig,
331
+ clientId: "your-client-id"
332
+ };
210
333
 
211
- return <button onClick={openModal}>Connect Wallet</button>;
334
+ export function App() {
335
+ return (
336
+ <WalletConnectProvider config={config}>
337
+ <YourApp />
338
+ </WalletConnectProvider>
339
+ );
212
340
  }
341
+ ```
342
+
343
+ ### Complete Configuration Example
213
344
 
214
- // App Component
215
- function App() {
216
- // Configuration
217
- const config = {};
345
+ ```tsx
346
+ import {
347
+ WalletConnectProvider,
348
+ getChains,
349
+ getConnectors,
350
+ } from "@dogeos/dogeos-sdk";
351
+ import type { WalletConnectKitConfig } from "@dogeos/dogeos-sdk";
352
+ import { useEffect, useState } from "react";
353
+
354
+ export function App() {
355
+ const [chains, setChains] = useState<
356
+ Awaited<ReturnType<typeof getChains>> | undefined
357
+ >(undefined);
358
+ const [connectors, setConnectors] = useState<
359
+ Awaited<ReturnType<typeof getConnectors>> | undefined
360
+ >(undefined);
361
+
362
+ useEffect(() => {
363
+ const loadConfig = async () => {
364
+ const [loadedChains, loadedConnectors] = await Promise.all([
365
+ getChains(),
366
+ getConnectors(),
367
+ ]);
368
+ setChains(loadedChains);
369
+ setConnectors(loadedConnectors);
370
+ };
371
+ loadConfig();
372
+ }, []);
373
+
374
+ const config: WalletConnectKitConfig = {
375
+ // WalletConnect configuration
376
+ walletConnectProjectId: "your-project-id",
377
+ clientId: "your-client-id",
378
+ // DApp application metadata
379
+ metadata: {
380
+ name: "My DApp",
381
+ description: "My decentralized application",
382
+ url: "https://myapp.com",
383
+ icons: ["https://myapp.com/icon.png"],
384
+ },
385
+
386
+ // Supported chains (must use getChains)
387
+ chains,
388
+
389
+ // Custom wallets (must use getConnectors)
390
+ connectors,
391
+
392
+ // Login configuration
393
+ login: {
394
+ basicLogins: ["email", "externalWallets"],
395
+ socialLogins: [{ type: "google" }, { type: "x" }],
396
+ },
397
+
398
+ // Theme configuration
399
+ theme: {
400
+ themes: {
401
+ light: {
402
+ colors: {
403
+ primary: {
404
+ DEFAULT: "#FCD436",
405
+ foreground: "#FFF",
406
+ },
407
+ },
408
+ },
409
+ },
410
+ },
411
+ };
412
+
413
+ if (!chains || !connectors) {
414
+ return <div>Loading configuration...</div>;
415
+ }
218
416
 
219
417
  return (
220
418
  <WalletConnectProvider config={config}>
@@ -225,36 +423,358 @@ function App() {
225
423
  </WalletConnectProvider>
226
424
  );
227
425
  }
426
+ ```
427
+
428
+ ## API Reference
429
+
430
+ ### WalletConnectProvider
431
+
432
+ Main Provider component for wrapping your application.
433
+
434
+ **Props:**
435
+
436
+ ```tsx
437
+ interface WalletConnectProviderProps {
438
+ children: React.ReactNode;
439
+ config?: WalletConnectKitConfig;
440
+ }
441
+ ```
442
+
443
+ ### useWalletConnect
444
+
445
+ Hook for controlling the wallet connection modal and managing connection state.
446
+
447
+ **Returns:**
448
+
449
+ ```tsx
450
+ interface UseWalletConnect {
451
+ // Modal control
452
+ isOpenModal: boolean;
453
+ openModal: () => void;
454
+ closeModal: () => void;
455
+
456
+ // Connection state
457
+ isConnected: boolean;
458
+ isConnecting: boolean;
459
+ error: Error | null;
460
+
461
+ // Connection operations
462
+ connect: (variables?: ConnectVariables) => Promise<ConnectData>;
463
+ disconnect: () => Promise<void>;
464
+ }
465
+ ```
228
466
 
229
- export default App;
467
+ **Example:**
468
+
469
+ ```tsx
470
+ const {
471
+ isOpenModal,
472
+ openModal,
473
+ closeModal,
474
+ isConnected,
475
+ isConnecting,
476
+ connect,
477
+ disconnect,
478
+ } = useWalletConnect();
230
479
  ```
231
480
 
232
- ---
481
+ ### useAccount
233
482
 
234
- ## Support
483
+ Hook for getting the currently connected account information and performing account-related operations.
235
484
 
236
- For more help or if you encounter issues, please visit:
485
+ **Returns:**
237
486
 
238
- - [GitHub Issues](https://github.com/DogeOS69/mydoge-sdk)
239
- - [Support](support@dogeos.com)
240
- - [Documentation](https://docs.dogeos.com)
487
+ ```tsx
488
+ interface UseAccount {
489
+ // Account information
490
+ address: string;
491
+ balance?: string;
492
+ chainType?: ChainType;
493
+ chainId?: string;
494
+ currentWallet?: Connector | null;
495
+ currentProvider?: any;
496
+
497
+ // Operations
498
+ switchChain: (options: SwitchChainOptions) => Promise<boolean>;
499
+ signMessage?: (params: {
500
+ message: string;
501
+ nonce?: string;
502
+ }) => Promise<string | Uint8Array>;
503
+ signInWithWallet: (params?: SignInParams) => Promise<string | Uint8Array>;
504
+ }
505
+ ```
241
506
 
242
- ---
507
+ **Example:**
508
+
509
+ ```tsx
510
+ const {
511
+ address,
512
+ chainId,
513
+ chainType,
514
+ signMessage,
515
+ signInWithWallet,
516
+ switchChain,
517
+ } = useAccount();
518
+ ```
519
+
520
+ ### getChains
521
+
522
+ Utility function to get all available chains. Automatically fetches chains from the backend API and returns them in the config format.
523
+
524
+ **Signature:**
525
+
526
+ ```tsx
527
+ function getChains(): Promise<Partial<Record<ChainType, EvmChain[] | any[]>>>;
528
+ ```
529
+
530
+ **Returns:**
531
+
532
+ - A Promise that resolves to a chain configuration object containing all available chains
533
+ - Automatically includes EVM, Solana, Aptos, and Dogecoin chains
534
+ - Falls back to default chains if the API request fails
535
+
536
+ **Example:**
537
+
538
+ ```tsx
539
+ import { getChains } from "@dogeos/dogeos-sdk";
540
+ import { useEffect, useState } from "react";
541
+
542
+ export function MyComponent() {
543
+ const [chains, setChains] = useState<
544
+ Awaited<ReturnType<typeof getChains>> | undefined
545
+ >(undefined);
546
+
547
+ useEffect(() => {
548
+ const loadChains = async () => {
549
+ const allChains = await getChains();
550
+ setChains(allChains);
551
+ };
552
+ loadChains();
553
+ }, []);
554
+
555
+ // Use chains in your config
556
+ const config = { chains };
557
+ }
558
+ ```
559
+
560
+ ## Advanced Usage
561
+
562
+ ### Switch Chain
563
+
564
+ Use the `switchChain` method from the `useAccount` hook to switch chains:
565
+
566
+ ```tsx
567
+ import { useAccount } from "@dogeos/dogeos-sdk";
568
+ import type { Chain } from "@dogeos/dogeos-sdk";
569
+
570
+ export function SwitchChainButton() {
571
+ const { switchChain, chainId } = useAccount();
572
+
573
+ const handleSwitchChain = async () => {
574
+ const targetChain: Chain = {
575
+ id: 137,
576
+ name: "Polygon",
577
+ nativeCurrency: {
578
+ name: "MATIC",
579
+ symbol: "MATIC",
580
+ decimals: 18,
581
+ },
582
+ rpcUrls: {
583
+ default: {
584
+ http: ["https://polygon-rpc.com"],
585
+ },
586
+ },
587
+ blockExplorers: {
588
+ default: {
589
+ name: "PolygonScan",
590
+ url: "https://polygonscan.com",
591
+ },
592
+ },
593
+ };
594
+
595
+ try {
596
+ const success = await switchChain({
597
+ chainType: "evm",
598
+ chainInfo: targetChain,
599
+ });
600
+
601
+ if (success) {
602
+ console.log("Chain switched successfully");
603
+ }
604
+ } catch (error) {
605
+ console.error("Chain switch failed:", error);
606
+ }
607
+ };
608
+
609
+ return <button onClick={handleSwitchChain}>Switch to Polygon</button>;
610
+ }
611
+ ```
612
+
613
+ ### Integration with Wagmi
614
+
615
+ Wallet Connect Kit can seamlessly integrate with Wagmi. If you're already using `WagmiProvider`, Wallet Connect Kit will automatically detect and use Wagmi's configuration:
616
+
617
+ ```tsx
618
+ import { WagmiProvider } from "wagmi";
619
+ import { WalletConnectProvider } from "@dogeos/dogeos-sdk";
620
+ import { config } from "./wagmi-config";
621
+
622
+ export function App() {
623
+ return (
624
+ <WagmiProvider config={config}>
625
+ <WalletConnectProvider>
626
+ <YourApp />
627
+ </WalletConnectProvider>
628
+ </WagmiProvider>
629
+ );
630
+ }
631
+ ```
632
+
633
+ ### Error Handling
634
+
635
+ Always handle errors in connections and operations:
636
+
637
+ ```tsx
638
+ import { useWalletConnect, useAccount } from "@dogeos/dogeos-sdk";
639
+
640
+ export function WalletComponent() {
641
+ const { error, isConnecting } = useWalletConnect();
642
+ const { signMessage } = useAccount();
643
+
644
+ const handleSign = async () => {
645
+ try {
646
+ if (!signMessage) {
647
+ throw new Error("Signing functionality not available");
648
+ }
649
+
650
+ const signature = await signMessage({ message: "Hello" });
651
+ console.log("Signing successful:", signature);
652
+ } catch (error) {
653
+ console.error("Signing failed:", error);
654
+ // Display error message to user
655
+ }
656
+ };
657
+
658
+ if (error) {
659
+ return <div>Error: {error.message}</div>;
660
+ }
661
+
662
+ if (isConnecting) {
663
+ return <div>Connecting...</div>;
664
+ }
665
+
666
+ return <button onClick={handleSign}>Sign</button>;
667
+ }
668
+ ```
669
+
670
+ ## Type Definitions
671
+
672
+ ### WalletConnectKitConfig
673
+
674
+ ````tsx
675
+ interface WalletConnectKitConfig {
676
+ connectors?: WalletConfig[];
677
+ chains?: Partial<Record<ChainType, EvmChain[] | any[]>>;
678
+ walletConnectProjectId?: string;
679
+ /**
680
+ * Default connect chain
681
+ * @default undefined
682
+ * @example
683
+ * ```tsx
684
+ * import { WalletConnectProvider } from "@tomo-inc/wallet-connect-kit";
685
+ * const config: WalletConnectKitConfig = {
686
+ * defaultConnectChain: 'evm',
687
+ * };
688
+ */
689
+ defaultConnectChain?: ChainType;
690
+ metadata?: {
691
+ name: string;
692
+ description: string;
693
+ url: string;
694
+ icons: string[];
695
+ };
696
+ theme?: ThemeConfig;
697
+ login?: UserLoginConfig;
698
+ }
699
+ ````
700
+
701
+ ### Chain
702
+
703
+ ```tsx
704
+ interface Chain {
705
+ id: number;
706
+ name: string;
707
+ nativeCurrency: {
708
+ name: string;
709
+ symbol: string;
710
+ decimals: number;
711
+ };
712
+ rpcUrls: {
713
+ default: {
714
+ http: string[];
715
+ };
716
+ };
717
+ blockExplorers?: {
718
+ default: {
719
+ name: string;
720
+ url: string;
721
+ };
722
+ };
723
+ testnet?: boolean;
724
+ }
725
+ ```
726
+
727
+ ### ChainType
728
+
729
+ ```tsx
730
+ type ChainType = "evm" | "solana" | "aptos" | "dogecoin";
731
+ ```
732
+
733
+ ## Exports
734
+
735
+ - `WalletConnectProvider` - Main Provider component
736
+ - `useAccount` - Account information Hook
737
+ - `useWalletConnect` - Connect Hook
738
+ - `getChains` - Utility function to configure chains (can wrap backend API chains)
739
+ - Types: `WalletConnectKitConfig`, `Chain`, `WalletConfig`, `UseAccount`, `ChainType`, `ModalView`, `ThemeConfig`, `UserLoginConfig`
243
740
 
244
741
  ## FAQ
245
742
 
246
- 1. How to use with Next.js?
743
+ ### How to use with Next.js?
247
744
 
248
745
  ```js
249
746
  "use client"; // add "use client" at your index router page
250
747
  ```
251
748
 
252
- 2. Supported Next.js version
749
+ ### Supported Next.js version
253
750
 
254
751
  - Next.js 14/15 version had supported
255
752
 
256
- ---
753
+ ### How to get WalletConnect Project ID?
754
+
755
+ 1. Visit [WalletConnect Cloud](https://cloud.walletconnect.com)
756
+ 2. Create a new project or select an existing project
757
+ 3. Copy the Project ID and use it in your configuration
758
+
759
+ ### How to customize chains and connectors?
760
+
761
+ You can use `getChains()` and `getConnectors()` methods to customize chains and connectors:
762
+
763
+ ```tsx
764
+ import { getChains, getConnectors } from "@dogeos/dogeos-sdk";
765
+
766
+ // Get all available chains
767
+ const chains = await getChains();
768
+
769
+ // Get all available connectors
770
+ const connectors = await getConnectors();
771
+
772
+ // Use in config
773
+ const config = { chains, connectors };
774
+ ```
775
+
776
+ The `getChains()` method automatically fetches chains from the backend API and includes EVM, Solana, Aptos, and Dogecoin chains. The `getConnectors()` method loads all available connectors including EIP6963, Wallet Standard, and WalletConnect wallets.
257
777
 
258
- ## License
778
+ ### What chain types are supported?
259
779
 
260
- Please check the project's LICENSE file for details.
780
+ Currently, EVM chains are primarily supported, along with Solana, Aptos, and Dogecoin chains.