@cordystackx/cordy_minikit 2.0.11 โ†’ 3.0.0

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.
Files changed (58) hide show
  1. package/README.md +53 -753
  2. package/dist/client/jwt.d.ts +32 -0
  3. package/dist/client/jwt.d.ts.map +1 -0
  4. package/dist/client/jwt.js +84 -0
  5. package/dist/client/transfer.d.ts +104 -0
  6. package/dist/client/transfer.d.ts.map +1 -0
  7. package/dist/client/transfer.js +613 -0
  8. package/dist/client.d.ts +5 -0
  9. package/dist/client.d.ts.map +1 -0
  10. package/dist/client.js +2 -0
  11. package/dist/client__provider.d.ts +3 -1
  12. package/dist/client__provider.d.ts.map +1 -1
  13. package/dist/client__provider.js +29 -2
  14. package/dist/components/Connect_wallet_bt.d.ts +9 -3
  15. package/dist/components/Connect_wallet_bt.d.ts.map +1 -1
  16. package/dist/components/Connect_wallet_bt.js +63 -47
  17. package/dist/components/UI_Comp.d.ts.map +1 -1
  18. package/dist/components/UI_Comp.js +51 -60
  19. package/dist/config/Image.json +2 -2
  20. package/dist/config/walletConfig.d.ts +3 -0
  21. package/dist/config/walletConfig.d.ts.map +1 -1
  22. package/dist/config/walletConfig.js +43 -2
  23. package/dist/controllers/Get_Balance.d.ts +22 -0
  24. package/dist/controllers/Get_Balance.d.ts.map +1 -1
  25. package/dist/controllers/Get_Balance.js +90 -28
  26. package/dist/controllers/StellarButton.d.ts.map +1 -1
  27. package/dist/controllers/StellarButton.js +4 -0
  28. package/dist/controllers/WagmiButton.d.ts +2 -1
  29. package/dist/controllers/WagmiButton.d.ts.map +1 -1
  30. package/dist/controllers/WagmiButton.js +32 -32
  31. package/dist/controllers/loadStellarBalance.d.ts +23 -1
  32. package/dist/controllers/loadStellarBalance.d.ts.map +1 -1
  33. package/dist/controllers/loadStellarBalance.js +47 -14
  34. package/dist/css/UI_Comp/styles.module.css +121 -314
  35. package/dist/demo/next.config.d.ts +4 -0
  36. package/dist/demo/next.config.d.ts.map +1 -0
  37. package/dist/demo/next.config.js +12 -0
  38. package/dist/demo/src/app/layout.d.ts +5 -0
  39. package/dist/demo/src/app/layout.d.ts.map +1 -0
  40. package/dist/demo/src/app/layout.js +9 -0
  41. package/dist/demo/src/app/page.d.ts +2 -0
  42. package/dist/demo/src/app/page.d.ts.map +1 -0
  43. package/dist/demo/src/app/page.js +9 -0
  44. package/dist/index.d.ts +4 -0
  45. package/dist/index.d.ts.map +1 -1
  46. package/dist/index.js +3 -0
  47. package/dist/package.json +28 -14
  48. package/dist/server/jwt.d.ts +18 -0
  49. package/dist/server/jwt.d.ts.map +1 -0
  50. package/dist/server/jwt.js +35 -0
  51. package/dist/server.d.ts +3 -0
  52. package/dist/server.d.ts.map +1 -0
  53. package/dist/server.js +1 -0
  54. package/dist/tsconfig.tsbuildinfo +1 -1
  55. package/dist/wagmi__providers.d.ts +7 -2
  56. package/dist/wagmi__providers.d.ts.map +1 -1
  57. package/dist/wagmi__providers.js +24 -5
  58. package/package.json +28 -14
package/README.md CHANGED
@@ -1,779 +1,79 @@
1
- ---
2
- ยฉ 2025 Cordy StackX (@cordystackx)
3
- Licensed under the MIT License.
4
- Unauthorized removal of this notice violates the license terms.
5
- ---
6
-
7
- # ๐Ÿงฉ Cordy MiniKit โ€” Web3 Toolkit by CordyStackX
8
-
9
- [![npm version](https://img.shields.io/npm/v/@cordystackx/cordy_minikit.svg)](https://www.npmjs.com/package/@cordystackx/cordy_minikit)
10
- [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
11
- [![Socket Badge](https://badge.socket.dev/npm/package/@cordystackx/cordy_minikit/1.4.8)](https://badge.socket.dev/npm/package/@cordystackx/cordy_minikit/1.4.8)
12
1
 
13
- A lightweight, production-ready Web3 toolkit for building wallet UIs, controllers, and provider wrappers โ€” designed for modern frameworks like **Next.js** and **Vite**.
14
- Built with **Wagmi**, **Viem**, **Ethers**, and **TypeScript**.
2
+ <div align="center">
3
+ <img src="./assets/cordy-logo.svg" alt="Cordy Minikit logo" width="160" />
4
+ <h1>Cordy Minikit</h1>
5
+ <p>Typed Web3 toolkit for EVM and Stellar/Soroban wallet connections, balances, transfers, and session helpers.</p>
6
+ </div>
15
7
 
16
- **๐Ÿ“ฆ [NPM Package](https://www.npmjs.com/package/@cordystackx/cordy_minikit)** | **๐Ÿ“‚ [GitHub Repository](https://github.com/cordyStackX/cordy_minikit_official)**
8
+ <div align="center">
9
+ <img src="./assets/demo1.png" alt="Cordy Minikit wallet connection interface" width="31%" />
10
+ <img src="./assets/demo2.png" alt="Cordy Minikit EVM wallet interface" width="31%" />
11
+ <img src="./assets/demo3.png" alt="Cordy Minikit Stellar wallet interface" width="31%" />
12
+ </div>
17
13
 
18
- ---
19
-
20
- ## ๐Ÿ–ผ๏ธ Demo
21
-
22
- | Demo 1 | Demo 2 | Demo 3 |
23
- |---|---|---|
24
- | ![Demo 1](https://raw.githubusercontent.com/cordyStackX/cordy_minikit_official/refs/heads/main/assets/demo1.png) | ![Demo 2](https://raw.githubusercontent.com/cordyStackX/cordy_minikit_official/refs/heads/main/assets/demo2.png) | ![Demo 3](https://raw.githubusercontent.com/cordyStackX/cordy_minikit_official/refs/heads/main/assets/demo3.png) |
14
+ <p align="center">
15
+ <a href="https://www.npmjs.com/package/@cordystackx/cordy_minikit">NPM</a>
16
+ ยท
17
+ <a href="https://github.com/cordyStackX/cordy_minikit_official">GitHub</a>
18
+ ยท
19
+ <a href="./docs/README.md">Documentation</a>
20
+ </p>
25
21
 
26
22
  ---
27
-
28
- ## ๐Ÿš€ Features
29
-
30
- - ๐Ÿ”— **Wallet Connect/Disconnect** โ€” Simple hooks and buttons for EVM-based wallets
31
- - ๐Ÿงฐ **Prebuilt UI Components** โ€” Ready-to-use `ConnectWalletBT`, `UI_Comp`, and more
32
- - โš™๏ธ **Smart Controllers** โ€” Manage wallet actions, balances, and transactions effortlessly
33
- - ๐Ÿ’ธ **Transaction Helpers** โ€” Built-in ERC20 and native token transfer functions
34
- - ๐ŸŽจ **Themeable CSS** โ€” CSS Modules with variables for easy dark/light mode support
35
- - ๐Ÿ“ฆ **Tree-shakable & Typed** โ€” Optimized bundle size with full TypeScript definitions
36
- - ๐Ÿงฉ **Framework-Agnostic** โ€” Works seamlessly with Next.js, Vite, and more
37
- - ๐ŸŒ **Multi-Chain Support** โ€” Custom chain configuration support
38
- - ๐ŸŒŒ **Non-EVM Wallet Support** โ€” Stellar / Soroban wallet support through Freighter
39
- - โญ **Stellar Balance & Transfers** โ€” Read XLM balances and send native Stellar payments
40
- - ๐Ÿง  **Wallet Context Detection** โ€” Detect `EVM`, `Non-EVM`, `MULTI`, or `NONE`
23
+ ยฉ 2025 Cordy StackX (@cordystackx) ยท Licensed under the MIT License.
41
24
  ---
42
25
 
43
- ## ๐Ÿ“ฆ Installation
26
+ ## Install
44
27
 
45
28
  ```bash
46
- npm install @cordystackx/cordy_minikit@latest
47
- # or
48
- pnpm add @cordystackx/cordy_minikit@latest
29
+ npm install @cordystackx/cordy_minikit
49
30
  # or
50
- yarn add @cordystackx/cordy_minikit@latest
51
- ```
52
-
53
- ---
54
-
55
- ## ๐Ÿ“ข New: Non-EVM Wallet Support
56
-
57
- Cordy MiniKit now supports **Non-EVM wallets**, starting with **Stellar / Soroban** integration.
58
-
59
- You can now connect Stellar wallets through **Freighter**, read Stellar account balances, detect wallet context,
60
- and send native Stellar payments using the built-in `CordyStackTransStellar` helper.
61
-
62
- Supported wallet contexts now include:
63
-
64
- - `EVM` โ€” Wagmi / EVM wallet connected
65
- - `Non-EVM` โ€” Stellar / Non-EVM wallet connected
66
- - `MULTI` โ€” Both EVM and Non-EVM wallets connected
67
- - `NONE` โ€” No wallet connected
68
-
69
- This makes Cordy MiniKit ready for multi-chain apps that need both EVM and Stellar support.
70
-
71
- ## ๐Ÿ› ๏ธ Quick Start
72
-
73
- ### 1. Environment Setup
74
-
75
- Create a `.env.local` file in your project root:
76
-
77
- ```bash
78
- # Wagmi EVM
79
- NEXT_PUBLIC_RPC_ENDPOINT=https://your-rpc-endpoint.com
80
- NEXT_PUBLIC_TOKENADDRESS=0x...
81
- NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID=your_project_id
82
-
83
- # Stellar / Soroban Non-EVM
84
- NEXT_PUBLIC_STELLAR_HORIZON=https://horizon-testnet.stellar.org
85
- NEXT_PUBLIC_STELLAR_CONTRACT_ID=CCXI.....
86
- NEXT_PUBLIC_STELLAR_NETWORK_PASSPHRASE=Test SDF Network ; September 2015 //Optional
87
- ```
88
-
89
- For Stellar, `NEXT_PUBLIC_STELLAR_CONTRACT_ID` is the Soroban equivalent of an EVM token address. Use `NEXT_PUBLIC_STELLAR_HORIZON` for native account balance lookups through Horizon.
90
-
91
- ### 2. Provider Setup
92
-
93
- Create a providers file at `/app/providers.tsx` or `/services/minikit/providers.tsx`:
94
-
95
- ```tsx
96
- "use client";
97
- import { ReactNode } from "react";
98
- import { ProvidersClientWrapper } from "@cordystackx/cordy_minikit";
99
- import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
100
-
101
- const queryClient = new QueryClient();
102
-
103
- export default function Providers({ children }: { children: ReactNode }) {
104
- return (
105
- <QueryClientProvider client={queryClient}>
106
- <ProvidersClientWrapper>
107
- {children}
108
- </ProvidersClientWrapper>
109
- </QueryClientProvider>
110
- );
111
- }
112
- ```
113
-
114
- > **Note:** Install `@tanstack/react-query` as a peer dependency:
115
- > ```bash
116
- > npm install @tanstack/react-query
117
- > ```
118
-
119
- ### 3. Layout Integration
120
-
121
- Import the providers and CSS in your `/app/layout.tsx`:
122
-
123
- ```tsx
124
- import Providers from "@/app/providers";
125
- import "@cordystackx/cordy_minikit/dist/css/UI_Comp/styles.module.css";
126
-
127
- export default function RootLayout({
128
- children,
129
- }: {
130
- children: React.ReactNode;
131
- }) {
132
- return (
133
- <html lang="en">
134
- <body>
135
- <Providers>
136
- {children}
137
- </Providers>
138
- </body>
139
- </html>
140
- );
141
- }
142
- ```
143
-
144
- ---
145
-
146
- ## ๐Ÿ“š Usage Examples
147
-
148
- ### 1. Connect Wallet Button
149
-
150
- The `ConnectWalletBT` component provides a plug-and-play wallet connection button.
151
-
152
- ```tsx
153
- import { ConnectWalletBT } from "@cordystackx/cordy_minikit";
154
-
155
- export default function Header() {
156
- return (
157
- <nav>
158
- <ConnectWalletBT className="your-custom-class" />
159
- </nav>
160
- );
161
- }
162
- ```
163
-
164
- **Features:**
165
- - Automatically shows "Connect Wallet" when disconnected
166
- - Displays wallet address when connected
167
- - Fully customizable with `className` prop
168
-
169
- ---
170
-
171
- ### 2. Wallet Modal Hook
172
-
173
- Use the `useWalletModal` hook to trigger the wallet modal programmatically:
174
-
175
- ```tsx
176
- import { useWalletModal } from "@cordystackx/cordy_minikit";
177
-
178
- function CustomButton() {
179
- const { openModal, closeModal } = useWalletModal();
180
-
181
- return (
182
- <button onClick={openModal}>
183
- Open Wallet
184
- </button>
185
- );
186
- }
187
- ```
188
-
189
- ---
190
-
191
- ### 3. Transaction Handler
192
-
193
- The `CordyStackTrans` function handles ERC20 transfers:
194
-
195
- ```tsx
196
- import { CordyStackTrans } from "@cordystackx/cordy_minikit";
197
-
198
- async function handlePayment() {
199
- const recipientAddress = "0x...";
200
- const amount = 10; // Token amount
201
-
202
- const success = await CordyStackTrans(recipientAddress, amount);
203
-
204
- if (success) {
205
- console.log("Transaction successful!");
206
- } else {
207
- console.log("Transaction failed or rejected");
208
- }
209
- }
210
- ```
211
- Conditions enforced by the helper:
212
-
213
- - Runs only in the browser
214
- - Requires an active EVM wallet connection
215
- - Requires a valid recipient EVM address
216
- - Requires `amount > 0`
217
- - Requires the configured token contract address from `NEXT_PUBLIC_TOKENADDRESS`
218
- - Requires the active wallet/network to support the configured token contract
219
- - Requires the user to approve/sign the transaction in their wallet
220
- - Returns `true` when the transaction is submitted successfully
221
- - Returns `false` when the transaction is rejected, invalid, or fails
222
-
223
-
224
- Optional extra note if your helper supports native transfers too:
225
-
226
- ```md
227
- > Note: `CordyStackTrans` is intended for ERC20 token transfers. For native Stellar/XLM payments, use
228
- `CordyStackTransStellar`.
229
- ```
230
-
231
- ### 3.1 Stellar Transfer Helper
232
-
233
- Use `CordyStackTransStellar` for native Stellar payments through Freighter.
234
-
235
- ```tsx
236
- import { CordyStackTransStellar } from "@cordystackx/cordy_minikit";
237
-
238
- async function sendXLM() {
239
- const success = await CordyStackTransStellar("G...", 10, {
240
- memo: "Sample payment",
241
- });
242
-
243
- if (success) {
244
- console.log("Stellar transfer successful!");
245
- }
246
- }
247
- ```
248
-
249
- Conditions enforced by the helper:
250
- - Runs only in the browser
251
- - Requires Freighter access
252
- - Requires a valid destination address
253
- - Requires `amount > 0`
254
- - Requires the active Freighter network to match `NEXT_PUBLIC_STELLAR_NETWORK_PASSPHRASE` when that env var is set
255
-
256
- ---
257
-
258
- ### 4. Custom Chain Support
259
-
260
- Configure custom chains for your dApp:
261
-
262
- ```tsx
263
- import { getConfig, ProvidersClientWrapper } from "@cordystackx/cordy_minikit";
264
- import { defineChain } from "viem";
265
-
266
- // Define your custom chain
267
- const myCustomChain = defineChain({
268
- id: 1114,
269
- name: "Core Blockchain Testnet",
270
- network: "core-testnet",
271
- nativeCurrency: { name: "tCORE", symbol: "tCORE", decimals: 18 },
272
- rpcUrls: {
273
- default: { http: ["https://rpc.test.btcs.network"] },
274
- public: { http: ["https://rpc.test.btcs.network"] },
275
- },
276
- blockExplorers: {
277
- default: { name: "Core Scan", url: "https://scan.test.btcs.network" },
278
- },
279
- });
280
-
281
- // Get config with custom chain
282
- const customConfig = getConfig({ myCustomChain });
283
-
284
- // Use in provider
285
- export default function Providers({ children }: { children: ReactNode }) {
286
- return (
287
- <ProvidersClientWrapper config={customConfig}>
288
- {children}
289
- </ProvidersClientWrapper>
290
- );
291
- }
292
- ```
293
-
294
- ### 5. Disconnect Wallets
295
-
296
- Custom hook for disconnecting EVM, Stellar, or all connected wallets.
297
-
298
- ```tsx
299
- import { useDisconnectWallets } from "@cordystackx/cordy_minikit";
300
-
301
- export default function WalletControls() {
302
- const {
303
- disconnectEVM,
304
- disconnectStellar,
305
- disconnectAll,
306
- } = useDisconnectWallets();
307
-
308
- return (
309
- <div>
310
- <button onClick={disconnectEVM}>
311
- Disconnect EVM
312
- </button>
313
-
314
- <button onClick={disconnectStellar}>
315
- Disconnect Stellar
316
- </button>
317
-
318
- <button onClick={disconnectAll}>
319
- Disconnect All
320
- </button>
321
- </div>
322
- );
323
- }
324
- ```
325
-
326
- Returns:
327
-
328
- ```ts
329
- {
330
- disconnectEVM: () => Promise<boolean>;
331
- disconnectStellar: () => Promise<boolean>;
332
- disconnectAll: () => Promise<boolean>;
333
- }
334
- ```
335
-
336
- โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
337
- โ”‚ Function โ”‚ Description โ”‚
338
- โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
339
- โ”‚ disconnectEVM() โ”‚ Disconnects the active Wagmi/EVM wallet โ”‚
340
- โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
341
- โ”‚ disconnectStellar() โ”‚ Clears the active Stellar/Freighter wallet session โ”‚
342
- โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
343
- โ”‚ disconnectAll() โ”‚ Disconnects both EVM and Stellar wallet sessions โ”‚
344
- โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
345
-
346
- Each function returns:
347
-
348
- ```ts
349
- Promise<boolean>
350
- ```
351
-
352
- - true โ€” disconnect succeeded
353
- - false โ€” disconnect failed
354
-
355
- Example with success handling:
356
-
357
- ```tsx
358
- const { disconnectAll } = useDisconnectWallets();
359
-
360
- async function handleDisconnect() {
361
- const success = await disconnectAll();
362
-
363
- if (success) {
364
- console.log("Wallets disconnected");
365
- } else {
366
- console.log("Failed to disconnect wallets");
367
- }
368
- }
369
- ```
370
-
371
- โ”‚ Note: useDisconnectWallets() is a React hook. Call it only at the top level of a client component or another hook.
372
- โ”‚ Do not call it inside onClick, loops, conditions, or normal functions.
373
-
374
- ### 6. WalletStatus
375
-
376
- Custom hook for reading wallet status, balances, wallet context, refresh helpers, and disconnect functions for both
377
- EVM and Non-EVM wallets.
378
-
379
- ```tsx
380
- import { useWalletStatus } from "@cordystackx/cordy_minikit";
381
-
382
- export default function WalletInfo() {
383
- const {
384
- context,
385
- evm,
386
- stellar,
387
- refreshBalances,
388
- refreshEvmBalance,
389
- refreshStellarBalance,
390
- disconnectEVM,
391
- disconnectStellar,
392
- disconnectAll,
393
- } = useWalletStatus();
394
-
395
- return (
396
- <div>
397
- <p>Wallet Context: {context}</p>
398
-
399
- {context === "EVM" && (
400
- <p>EVM Address: {evm.address}</p>
401
- )}
402
-
403
- {context === "Non-EVM" && (
404
- <p>Stellar Address: {stellar.address}</p>
405
- )}
406
-
407
- {context === "MULTI" && (
408
- <>
409
- <p>EVM Address: {evm.address}</p>
410
- <p>Stellar Address: {stellar.address}</p>
411
- </>
412
- )}
413
-
414
- <button onClick={refreshBalances}>
415
- Refresh Balances
416
- </button>
417
-
418
- <button onClick={disconnectAll}>
419
- Disconnect All
420
- </button>
421
- </div>
422
- );
423
- }
424
- ```
425
-
426
- Returns:
427
-
428
- ```ts
429
- {
430
- context: "EVM" | "Non-EVM" | "MULTI" | "NONE";
431
-
432
- evm: {
433
- isConnected: boolean;
434
- address?: string;
435
- chain?: unknown;
436
- balance: string;
437
- symbol: string;
438
- error?: string;
439
- };
440
-
441
- stellar: {
442
- isConnected: boolean;
443
- address?: string;
444
- network?: string;
445
- balance?: string;
446
- error?: string;
447
- };
448
-
449
- refreshEvmBalance: () => Promise<boolean>;
450
- refreshStellarBalance: (accountId?: string) => Promise<boolean>;
451
- refreshBalances: () => Promise<boolean>;
452
-
453
- disconnectEVM: () => Promise<boolean>;
454
- disconnectStellar: () => Promise<boolean>;
455
- disconnectAll: () => Promise<boolean>;
456
- }
457
- ```
458
-
459
- Wallet context values:
460
-
461
- โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
462
- โ”‚ Context โ”‚ Description โ”‚
463
- โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
464
- โ”‚ EVM โ”‚ Wagmi / EVM wallet connected โ”‚
465
- โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
466
- โ”‚ Non-EVM โ”‚ Stellar / Freighter wallet connected โ”‚
467
- โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
468
- โ”‚ MULTI โ”‚ Both EVM and Stellar wallets connected โ”‚
469
- โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
470
- โ”‚ NONE โ”‚ No wallet connected โ”‚
471
- โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
472
-
473
- Example: close wallet modal after successful connection:
474
-
475
- ```tsx
476
- "use client";
477
-
478
- import { useEffect } from "react";
479
- import {
480
- useWalletStatus,
481
- useWalletModal,
482
- } from "@cordystackx/cordy_minikit";
483
-
484
- export default function AutoCloseWalletModal() {
485
- const { context } = useWalletStatus();
486
- const { closeModal } = useWalletModal();
487
-
488
- useEffect(() => {
489
- if (context !== "NONE") {
490
- closeModal();
491
- }
492
- }, [context, closeModal]);
493
-
494
- return null;
495
- }
496
- ```
497
-
498
- โ”‚ Note: useWalletStatus() is a React hook. Call it only at the top level of a client component or another hook.
499
-
500
- ### 7. Wallet Connection Components
501
-
502
- #### `WalletButton`
503
-
504
- Low-level EVM wallet connector button list powered by Wagmi.
505
-
506
- `WalletButton` renders all configured Wagmi connectors and handles EVM wallet connection state internally.
507
-
508
- ```tsx
509
- import { WalletButton } from "@cordystackx/cordy_minikit";
510
-
511
- export default function EVMConnect() {
512
- return (
513
- <WalletButton
514
- onStatusChange={({ isPending, error }) => {
515
- console.log("Connecting:", isPending);
516
- console.log("Error:", error);
517
- }}
518
- />
519
- );
520
- }
521
- ```
522
-
523
- Props:
524
-
525
- ```ts
526
- {
527
- onStatusChange?: (status: {
528
- isPending: boolean;
529
- error?: string;
530
- }) => void;
531
- }
532
- ```
533
-
534
- Behavior:
535
-
536
- - Lists available Wagmi connectors
537
- - Detects whether injected wallets are installed
538
- - Supports WalletConnect and Trust Wallet display handling
539
- - Shows Connecting... while connection is pending
540
- - Stores the active wallet session as evm
541
- - Reports pending/error state through onStatusChange
542
-
543
- โ”‚ Note: WalletButton is usually used internally by UI_Comp, but it can also be imported directly for custom wallet
544
- โ”‚ UIs.
545
-
546
- โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
547
-
548
- #### StellarWalletButton
549
-
550
- Low-level Stellar / Freighter wallet connector button.
551
-
552
- StellarWalletButton connects to Freighter, returns the Stellar public key, and reports the active Stellar network.
553
-
554
- ```tsx
555
- import { StellarWalletButton } from "@cordystackx/cordy_minikit";
556
-
557
- export default function StellarConnect() {
558
- return (
559
- <StellarWalletButton
560
- onConnect={(address) => {
561
- console.log("Connected Stellar address:", address);
562
- }}
563
- onStatusChange={({ isPending, error, address, network }) => {
564
- console.log("Connecting:", isPending);
565
- console.log("Error:", error);
566
- console.log("Address:", address);
567
- console.log("Network:", network);
568
- }}
569
- />
570
- );
571
- }
572
- ```
573
-
574
- Props:
575
-
576
- ```ts
577
- {
578
- onConnect?: (address: string) => void;
579
-
580
- onStatusChange?: (status: {
581
- isPending: boolean;
582
- error?: string;
583
- address?: string;
584
- network?: string;
585
- }) => void;
586
- }
587
- ```
588
-
589
- Behavior:
590
-
591
- - Requests Freighter wallet access
592
- - Returns the connected Stellar public key
593
- - Reads active Freighter network details
594
- - Shows connected address preview
595
- - Reports pending/error/address/network through onStatusChange
596
-
597
- Conditions:
598
-
599
- - Runs only in the browser
600
- - Requires Freighter wallet extension/app access
601
- - Requires user approval in Freighter
602
- - For testnet apps, Freighter should be set to the matching testnet network
603
-
604
- Small improvement for `WalletButton`: after successful connect, you may want to notify parent explicitly:
605
-
606
- ```ts
607
- onStatusChange?.({ isPending: false });
608
- ```
609
-
610
- right after:
611
-
612
- ```ts
613
- await connectAsync({ connector });
614
- ```
615
-
616
- `Not required, but cleaner.`
617
-
618
- ---
619
-
620
- ## ๐Ÿ—๏ธ Architecture Overview
621
-
622
- ### Project Structure
623
-
624
- ```
625
- cordy_minikit/
626
- โ”œโ”€โ”€ assets/ # Image Sources for logo
627
- โ”œโ”€โ”€ components/ # UI components (ConnectWalletBT, UI_Comp)
628
- โ”œโ”€โ”€ controllers/ # Transaction logic and wallet operations
629
- โ”œโ”€โ”€ config/ # ABIs and static configurations
630
- โ”œโ”€โ”€ css/ # CSS Modules and theming
631
- โ”œโ”€โ”€ dist/ # Compiled output (published to npm)
632
- โ”œโ”€โ”€ index.ts # Main export entry point
633
- โ””โ”€โ”€ package.json
634
- ```
635
-
636
- ### Key Files
637
-
638
- | File/Folder | Description |
639
- |-------------|-------------|
640
- | `assets/` | Image Sources for logo |
641
- | `client__provider.tsx` | React provider wrapper for Wagmi/Viem |
642
- | `components/` | Reusable UI components for wallet interactions |
643
- | `controllers/` | Business logic for Web3 operations |
644
- | `config/` | ERC20 ABI and configuration files |
645
- | `css/` | Scoped CSS Modules with theming support |
646
- | `dist/` | Compiled JavaScript + TypeScript declarations |
647
-
648
- ---
649
-
650
- ## ๐Ÿ”ง API Reference
651
-
652
- ### Components
653
-
654
- #### `ConnectWalletBT`
655
- ```tsx
656
- <ConnectWalletBT className?: string />
31
+ pnpm add @cordystackx/cordy_minikit
657
32
  ```
658
- - Props: `className` (optional) - Custom CSS class
659
33
 
34
+ ## 3.0.0 documentation
660
35
 
661
- ### Hooks
36
+ Read the complete documentation in the [`docs/` folder](./docs/README.md):
662
37
 
663
- #### `useWalletModal()`
664
- ```tsx
665
- const { openModal, closeModal } = useWalletModal();
666
- ```
667
- - Returns: `{ openModal: () => void, closeModal: () => void }`
668
-
669
- ### Functions
670
-
671
- #### `CordyStackTrans(address, amount)`
672
- ```tsx
673
- const success = await CordyStackTrans(recipientAddress: string, amount: number);
674
- ```
675
- - Returns: `Promise<boolean>` - Transaction success status
676
-
677
- #### `CordyStackTransStellar(address, amount, options?)`
678
- ```tsx
679
- const success = await CordyStackTransStellar(recipientAddress: string, amount: number, options?: { memo?: string; source?: string });
680
- ```
681
- - Returns: `Promise<boolean>` - Stellar transaction success status
682
-
683
- #### `getConfig(customChains?)`
684
- ```tsx
685
- const config = getConfig({ myChain: customChainDefinition });
686
- ```
687
- - Returns: Wagmi configuration with custom chains
38
+ - [Documentation index](./docs/README.md)
39
+ - [Environment configuration](./docs/environment.md)
40
+ - [3.0.0 API reference](./docs/api.md)
41
+ - [3.0.0 migration guide](./docs/migration-3.0.0.md)
42
+ - [Provider and wallet UI setup](./docs/setup.md)
43
+ - [Server session endpoint examples](./docs/server-endpoints.md)
688
44
 
689
- #### `useWalletStatus()`
690
-
691
- ```tsx
692
- const {
693
- context,
694
- evm,
695
- stellar,
696
- refreshBalances,
697
- disconnectEVM,
698
- disconnectStellar,
699
- disconnectAll,
700
- } = useWalletStatus();
701
- ```
702
-
703
- Returns wallet status for both EVM and Non-EVM wallets.
704
-
705
- ```ts
706
- context: "EVM" | "Non-EVM" | "MULTI" | "NONE"
707
- ```
708
-
709
- Useful for detecting whether the connected wallet is Wagmi/EVM, Stellar/Non-EVM, both, or none.
45
+ ## Current API
710
46
 
711
- ---
712
-
713
- ## ๐ŸŽจ Customization
714
-
715
- ### Custom Styling
716
-
717
- ```tsx
718
- <ConnectWalletBT className="my-custom-button" />
719
- ```
47
+ ```ts
48
+ import { cordy } from "@cordystackx/cordy_minikit";
720
49
 
721
- ```css
722
- .my-custom-button {
723
- background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
724
- border-radius: 8px;
725
- padding: 12px 24px;
726
- font-weight: 600;
727
- }
50
+ const session = await cordy.jwt_verify();
51
+ const balance = await cordy.balance();
52
+ const transfer = await cordy.transfer("1", recipient);
53
+ await cordy.jwt_disconnect();
728
54
  ```
729
55
 
730
- ---
56
+ The current 3.0.0 API is:
731
57
 
732
- ## ๐Ÿ“‹ Requirements
58
+ - `cordy.jwt_verify()`
59
+ - `cordy.jwt_disconnect()`
60
+ - `cordy.transfer()`
61
+ - `cordy.balance()`
62
+ - `cordy.swap(amount, from, to)`
733
63
 
734
- - **React**: ^18.3.1
735
- - **Next.js**: ^14.2.33 (for Next.js projects)
736
- - **@tanstack/react-query**: ^5.90.3
737
- - **wagmi**: ^2.18.1
738
- - **viem**: Latest version
739
- - **ethers**: ^6.15.0
64
+ `cordy.jwt_confirm()` remains available as a deprecated compatibility alias for `cordy.jwt_verify()`. Legacy controller helpers remain available for compatibility, but new integrations should use the `cordy.*` API.
740
65
 
741
- ---
66
+ ## Planned APIs
742
67
 
743
- ## ๐Ÿค Contributing
68
+ **Experimental in 3.0.0:** `cordy.bridge()` currently supports test USDT between BOT Chain Testnet and Ethereum Sepolia only. See the [bridge API example](./docs/api.md#cordybridgeamount-from-to-recipient).
744
69
 
745
- Contributions are welcome! Please feel free to submit a Pull Request.
70
+ `cordy.swap(amount, from, to)` is available for configured EVM and Stellar assets. EVM networks need a Uniswap V2-compatible `swapRouterAddress`; native EVM swaps also need `wrappedNativeTokenAddress`. Stellar swaps use Horizon strict-send path payments and require a live liquidity path. Both use 1% minimum-output tolerance.
746
71
 
747
- 1. Fork the repository
748
- 2. Create your feature branch (`git checkout -b feature/AmazingFeature`)
749
- 3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)
750
- 4. Push to the branch (`git push origin feature/AmazingFeature`)
751
- 5. Open a Pull Request
72
+ ## Links
752
73
 
753
- ---
754
-
755
- ## ๐Ÿ“„ License
756
-
757
- This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
758
-
759
- ---
760
-
761
- ## ๐Ÿ”— Links
762
-
763
- - **NPM Package**: https://www.npmjs.com/package/@cordystackx/cordy_minikit
764
- - **GitHub Repository**: https://github.com/cordyStackX/cordy_minikit_official
765
- - **Official Website**: https://cordy-stack-x.vercel.app/
766
-
767
- ---
768
-
769
- ## ๐Ÿ’ฌ Support
770
-
771
- For issues, questions, or feature requests:
772
- - Open an issue on [GitHub](https://github.com/cordyStackX/cordy_minikit_official/issues)
773
- - Visit our [website](https://cordy-stack-x.vercel.app/)
774
-
775
- ---
776
-
777
- **Built with โค๏ธ by [CordyStackX](https://cordy-stack-x.vercel.app/)**
778
-
779
- ---
74
+ - [NPM package](https://www.npmjs.com/package/@cordystackx/cordy_minikit)
75
+ - [GitHub repository](https://github.com/cordyStackX/cordy_minikit_official)
76
+ - [Demo](./demo/README.md)
77
+ - [Changelog](./CHANGELOG.md)
78
+ - [Contributing guide](./CONTRIBUTING.md)
79
+ - [Security policy](./SECURITY.md)