@cordystackx/cordy_minikit 2.0.11 β 3.0.1
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 +58 -752
- package/dist/client/jwt.d.ts +32 -0
- package/dist/client/jwt.d.ts.map +1 -0
- package/dist/client/jwt.js +84 -0
- package/dist/client/transfer.d.ts +104 -0
- package/dist/client/transfer.d.ts.map +1 -0
- package/dist/client/transfer.js +613 -0
- package/dist/client.d.ts +5 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +2 -0
- package/dist/client__provider.d.ts +3 -1
- package/dist/client__provider.d.ts.map +1 -1
- package/dist/client__provider.js +29 -2
- package/dist/components/Connect_wallet_bt.d.ts +9 -3
- package/dist/components/Connect_wallet_bt.d.ts.map +1 -1
- package/dist/components/Connect_wallet_bt.js +63 -47
- package/dist/components/UI_Comp.d.ts.map +1 -1
- package/dist/components/UI_Comp.js +51 -60
- package/dist/config/Image.json +2 -2
- package/dist/config/walletConfig.d.ts +3 -0
- package/dist/config/walletConfig.d.ts.map +1 -1
- package/dist/config/walletConfig.js +43 -2
- package/dist/controllers/Get_Balance.d.ts +22 -0
- package/dist/controllers/Get_Balance.d.ts.map +1 -1
- package/dist/controllers/Get_Balance.js +90 -28
- package/dist/controllers/StellarButton.d.ts.map +1 -1
- package/dist/controllers/StellarButton.js +4 -0
- package/dist/controllers/Transactions.d.ts +2 -0
- package/dist/controllers/Transactions.d.ts.map +1 -1
- package/dist/controllers/Transactions.js +2 -0
- package/dist/controllers/WagmiButton.d.ts +2 -1
- package/dist/controllers/WagmiButton.d.ts.map +1 -1
- package/dist/controllers/WagmiButton.js +32 -32
- package/dist/controllers/index.d.ts +0 -1
- package/dist/controllers/index.d.ts.map +1 -1
- package/dist/controllers/index.js +0 -1
- package/dist/controllers/loadStellarBalance.d.ts +23 -1
- package/dist/controllers/loadStellarBalance.d.ts.map +1 -1
- package/dist/controllers/loadStellarBalance.js +47 -14
- package/dist/css/UI_Comp/styles.module.css +121 -314
- package/dist/demo/next.config.d.ts +4 -0
- package/dist/demo/next.config.d.ts.map +1 -0
- package/dist/demo/next.config.js +12 -0
- package/dist/demo/src/app/layout.d.ts +5 -0
- package/dist/demo/src/app/layout.d.ts.map +1 -0
- package/dist/demo/src/app/layout.js +9 -0
- package/dist/demo/src/app/page.d.ts +2 -0
- package/dist/demo/src/app/page.d.ts.map +1 -0
- package/dist/demo/src/app/page.js +9 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/package.json +28 -14
- package/dist/server/jwt.d.ts +18 -0
- package/dist/server/jwt.d.ts.map +1 -0
- package/dist/server/jwt.js +35 -0
- package/dist/server.d.ts +3 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/wagmi__providers.d.ts +7 -2
- package/dist/wagmi__providers.d.ts.map +1 -1
- package/dist/wagmi__providers.js +24 -5
- package/package.json +28 -14
- package/dist/controllers/AirDrop_Faucet.d.ts +0 -2
- package/dist/controllers/AirDrop_Faucet.d.ts.map +0 -1
- package/dist/controllers/AirDrop_Faucet.js +0 -93
package/README.md
CHANGED
|
@@ -1,779 +1,85 @@
|
|
|
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
|
-
[](https://www.npmjs.com/package/@cordystackx/cordy_minikit)
|
|
10
|
-
[](https://opensource.org/licenses/MIT)
|
|
11
|
-
[](https://badge.socket.dev/npm/package/@cordystackx/cordy_minikit/1.4.8)
|
|
12
1
|
|
|
13
|
-
|
|
14
|
-
|
|
2
|
+
<div align="center">
|
|
3
|
+
<img src="https://raw.githubusercontent.com/cordyStackX/cordy_minikit_official/21cb17b5569b79b29545da80da33d82625e26c7b/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
|
-
|
|
8
|
+
<p align="center">
|
|
9
|
+
<a href="https://badge.socket.dev/npm/package/@cordystackx/cordy_minikit/3.0.0">
|
|
10
|
+
<img src="https://badge.socket.dev/npm/package/@cordystackx/cordy_minikit/3.0.0" alt="Socket Badge" />
|
|
11
|
+
</a>
|
|
12
|
+
</p>
|
|
17
13
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
14
|
+
<div align="center">
|
|
15
|
+
<img src="https://raw.githubusercontent.com/cordyStackX/cordy_minikit_official/refs/heads/main/assets/demo1.png" alt="Cordy Minikit wallet connection interface" width="31%" />
|
|
16
|
+
<img src="https://raw.githubusercontent.com/cordyStackX/cordy_minikit_official/refs/heads/main/assets/demo2.png" alt="Cordy Minikit EVM wallet interface" width="31%" />
|
|
17
|
+
<img src="https://raw.githubusercontent.com/cordyStackX/cordy_minikit_official/refs/heads/main/assets/demo3.png" alt="Cordy Minikit Stellar wallet interface" width="31%" />
|
|
18
|
+
</div>
|
|
21
19
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
<p align="center">
|
|
21
|
+
<a href="https://www.npmjs.com/package/@cordystackx/cordy_minikit">NPM</a>
|
|
22
|
+
Β·
|
|
23
|
+
<a href="https://github.com/cordyStackX/cordy_minikit_official">GitHub</a>
|
|
24
|
+
Β·
|
|
25
|
+
<a href="https://github.com/cordyStackX/cordy_minikit_official/blob/main/docs/README.md">Documentation</a>
|
|
26
|
+
</p>
|
|
25
27
|
|
|
26
28
|
---
|
|
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`
|
|
29
|
+
Β© 2025 Cordy StackX (@cordystackx) Β· Licensed under the MIT License.
|
|
41
30
|
---
|
|
42
31
|
|
|
43
|
-
##
|
|
32
|
+
## Install
|
|
44
33
|
|
|
45
34
|
```bash
|
|
46
|
-
npm install @cordystackx/cordy_minikit
|
|
35
|
+
npm install @cordystackx/cordy_minikit
|
|
47
36
|
# or
|
|
48
|
-
pnpm add @cordystackx/cordy_minikit
|
|
49
|
-
# 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
|
-
}
|
|
37
|
+
pnpm add @cordystackx/cordy_minikit
|
|
162
38
|
```
|
|
163
39
|
|
|
164
|
-
|
|
165
|
-
- Automatically shows "Connect Wallet" when disconnected
|
|
166
|
-
- Displays wallet address when connected
|
|
167
|
-
- Fully customizable with `className` prop
|
|
168
|
-
|
|
169
|
-
---
|
|
40
|
+
## 3.0.0 documentation
|
|
170
41
|
|
|
171
|
-
|
|
42
|
+
Read the complete documentation in the [`docs/` folder](./docs/README.md):
|
|
172
43
|
|
|
173
|
-
|
|
44
|
+
- [Documentation index](https://github.com/cordyStackX/cordy_minikit_official/blob/main/docs/README.md)
|
|
45
|
+
- [Environment configuration](https://github.com/cordyStackX/cordy_minikit_official/blob/main/docs/environment.md)
|
|
46
|
+
- [3.0.0 API reference](https://github.com/cordyStackX/cordy_minikit_official/blob/main/docs/api.md)
|
|
47
|
+
- [3.0.0 migration guide](https://github.com/cordyStackX/cordy_minikit_official/blob/main/docs/migration-3.0.0.md)
|
|
48
|
+
- [Provider and wallet UI setup](https://github.com/cordyStackX/cordy_minikit_official/blob/main/docs/setup.md)
|
|
49
|
+
- [Server session endpoint examples](https://github.com/cordyStackX/cordy_minikit_official/blob/main/docs/server-endpoints.md)
|
|
174
50
|
|
|
175
|
-
|
|
176
|
-
import { useWalletModal } from "@cordystackx/cordy_minikit";
|
|
51
|
+
## Current API
|
|
177
52
|
|
|
178
|
-
|
|
179
|
-
|
|
53
|
+
```ts
|
|
54
|
+
import { cordy } from "@cordystackx/cordy_minikit";
|
|
180
55
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
);
|
|
186
|
-
}
|
|
56
|
+
const session = await cordy.jwt_verify();
|
|
57
|
+
const balance = await cordy.balance();
|
|
58
|
+
const transfer = await cordy.transfer("1", recipient);
|
|
59
|
+
await cordy.jwt_disconnect();
|
|
187
60
|
```
|
|
188
61
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
### 3. Transaction Handler
|
|
192
|
-
|
|
193
|
-
The `CordyStackTrans` function handles ERC20 transfers:
|
|
62
|
+
The current 3.0.0 API is:
|
|
194
63
|
|
|
195
|
-
|
|
196
|
-
|
|
64
|
+
- `cordy.configure({ assets })`
|
|
65
|
+
- `cordy.jwt_verify()`
|
|
66
|
+
- `cordy.jwt_disconnect()`
|
|
67
|
+
- `cordy.transfer()`
|
|
68
|
+
- `cordy.balance()`
|
|
69
|
+
- `cordy.swap(amount, from, to)`
|
|
197
70
|
|
|
198
|
-
|
|
199
|
-
const recipientAddress = "0x...";
|
|
200
|
-
const amount = 10; // Token amount
|
|
71
|
+
`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.
|
|
201
72
|
|
|
202
|
-
|
|
73
|
+
## Experimental API
|
|
203
74
|
|
|
204
|
-
|
|
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
|
-
```
|
|
75
|
+
`cordy.bridge()` is experimental in 3.0.0 and currently supports test USDT between BOT Chain Testnet and Ethereum Sepolia only. See the [bridge API example](./docs/api.md#cordybridgeamount-from-to-recipient).
|
|
230
76
|
|
|
231
|
-
|
|
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.
|
|
77
|
+
`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.
|
|
373
78
|
|
|
374
|
-
|
|
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.
|
|
79
|
+
## Links
|
|
499
80
|
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
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 />
|
|
657
|
-
```
|
|
658
|
-
- Props: `className` (optional) - Custom CSS class
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
### Hooks
|
|
662
|
-
|
|
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
|
|
688
|
-
|
|
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.
|
|
710
|
-
|
|
711
|
-
---
|
|
712
|
-
|
|
713
|
-
## π¨ Customization
|
|
714
|
-
|
|
715
|
-
### Custom Styling
|
|
716
|
-
|
|
717
|
-
```tsx
|
|
718
|
-
<ConnectWalletBT className="my-custom-button" />
|
|
719
|
-
```
|
|
720
|
-
|
|
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
|
-
}
|
|
728
|
-
```
|
|
729
|
-
|
|
730
|
-
---
|
|
731
|
-
|
|
732
|
-
## π Requirements
|
|
733
|
-
|
|
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
|
|
740
|
-
|
|
741
|
-
---
|
|
742
|
-
|
|
743
|
-
## π€ Contributing
|
|
744
|
-
|
|
745
|
-
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
746
|
-
|
|
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
|
|
752
|
-
|
|
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
|
-
---
|
|
81
|
+
- [NPM package](https://www.npmjs.com/package/@cordystackx/cordy_minikit)
|
|
82
|
+
- [GitHub repository](https://github.com/cordyStackX/cordy_minikit_official)
|
|
83
|
+
- [Changelog](https://github.com/cordyStackX/cordy_minikit_official/blob/main/CHANGELOG.md)
|
|
84
|
+
- [Contributing guide](https://github.com/cordyStackX/cordy_minikit_official/blob/main/CONTRIBUTING.md)
|
|
85
|
+
- [Security policy](https://github.com/cordyStackX/cordy_minikit_official/blob/main/SECURITY.md)
|