@cordystackx/cordy_minikit 0.9.5 → 0.9.7
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
|
@@ -4,6 +4,10 @@ Licensed under the MIT License.
|
|
|
4
4
|
Unauthorized removal of this notice violates the license terms.
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
+
# Github Official Repo
|
|
8
|
+
```bash
|
|
9
|
+
https://github.com/cordyStackX/cordy_minikit_official.git
|
|
10
|
+
```
|
|
7
11
|
|
|
8
12
|
# 🧩 cordy_minikit — Web3 Mini Kit by cordyStackX
|
|
9
13
|
|
|
@@ -17,7 +21,7 @@ Built with **Wagmi**, **Viem**, **Ethers** and **TypeScript** (compiled to JS fo
|
|
|
17
21
|
- 🔗 **Wallet Connect / Disconnect**
|
|
18
22
|
Simple connect button and hooks for EVM-based wallets.
|
|
19
23
|
- 🧰 **Prebuilt UI Components**
|
|
20
|
-
Reusable components like `ConnectWalletBT`, `
|
|
24
|
+
Reusable components like `ConnectWalletBT`, `CordyStackTrans`.
|
|
21
25
|
- ⚙️ **Controllers**
|
|
22
26
|
Manage wallet actions, balances, and transactions.
|
|
23
27
|
- 🎨 **CSS Modules + CSS Variables**
|
|
@@ -62,8 +66,16 @@ root
|
|
|
62
66
|
|
|
63
67
|
|
|
64
68
|
|
|
65
|
-
|
|
66
|
-
|
|
69
|
+
# Get Started
|
|
70
|
+
|
|
71
|
+
## Setup
|
|
72
|
+
|
|
73
|
+
1. Install the NPM Packages
|
|
74
|
+
```bash
|
|
75
|
+
npm i @cordystackx/cordy_minikit@latest
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
2. Create env file
|
|
67
79
|
```bash
|
|
68
80
|
NEXT_PUBLIC_RPC_ENDPOINT=
|
|
69
81
|
NEXT_PUBLIC_TOKENADDRESS=
|
|
@@ -71,28 +83,89 @@ NEXT_PUBLIC_PLATFORM_ADDRESS=
|
|
|
71
83
|
NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID=
|
|
72
84
|
```
|
|
73
85
|
|
|
74
|
-
|
|
75
|
-
|
|
86
|
+
3. Create folder of /services/minikit/providers.ts
|
|
87
|
+
|
|
88
|
+
> Note: Make sure you install @tanstack/react-query for QueryClient and QueryClientProviders
|
|
89
|
+
|
|
90
|
+
```ts
|
|
91
|
+
"use client";
|
|
92
|
+
import { ReactNode } from "react";
|
|
76
93
|
import { ProvidersClientWrapper } from "@cordystackx/cordy_minikit";
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
94
|
+
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
95
|
+
|
|
96
|
+
const queryClient = new QueryClient();
|
|
97
|
+
|
|
98
|
+
export default function Providers({ children }: { children: ReactNode }) {
|
|
99
|
+
|
|
100
|
+
return(
|
|
101
|
+
<QueryClientProvider client={queryClient}>
|
|
102
|
+
<ProvidersClientWrapper>
|
|
103
|
+
{children}
|
|
104
|
+
</ProvidersClientWrapper>
|
|
105
|
+
</QueryClientProvider>
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
}
|
|
109
|
+
```
|
|
81
110
|
|
|
111
|
+
4. then import it both CSS Module into the /app/layout.tsx
|
|
112
|
+
```ts
|
|
113
|
+
|
|
114
|
+
import {
|
|
115
|
+
Providers
|
|
116
|
+
} from "@/app/services/minikit/providers";
|
|
117
|
+
import '@cordystackx/cordy_minikit/dist/css/UI_Comp/styles.module.css';
|
|
118
|
+
import '@cordystackx/cordy_minikit/dist/css/Buttons/styles.module.css';
|
|
119
|
+
|
|
120
|
+
export default function RootLayout({
|
|
121
|
+
children,
|
|
122
|
+
}: Readonly<{
|
|
123
|
+
children: React.ReactNode;
|
|
124
|
+
}>) {
|
|
125
|
+
return (
|
|
126
|
+
<html lang="en">
|
|
127
|
+
<body className={`${geistSans.variable} ${geistMono.variable}`}>
|
|
128
|
+
<Providers>
|
|
129
|
+
{children}
|
|
130
|
+
</Providers>
|
|
131
|
+
</body>
|
|
132
|
+
</html>
|
|
133
|
+
);
|
|
134
|
+
}
|
|
82
135
|
```
|
|
83
|
-
3. Use of Connect Buttons
|
|
84
|
-
```bash
|
|
85
|
-
import { ConnectWalletBT } from "@cordystackx/cordy_minikit";
|
|
86
|
-
|
|
87
|
-
<ConnectWalletBT/>
|
|
88
136
|
|
|
137
|
+
## Usage
|
|
138
|
+
|
|
139
|
+
1. Connect Buttons — ConnectWalletBT
|
|
140
|
+
The ConnectWalletBT component provides a plug-and-play wallet connection button for any Web3 application.
|
|
141
|
+
It automatically handles connecting, disconnecting, and managing wallet sessions using Wagmi and Viem under the hood.
|
|
142
|
+
|
|
143
|
+
```ts
|
|
144
|
+
import {
|
|
145
|
+
ConnectWalletBT
|
|
146
|
+
} from "@cordystackx/cordy_minikit";
|
|
147
|
+
|
|
148
|
+
<ConnectWalletBT />
|
|
89
149
|
```
|
|
90
|
-
|
|
91
|
-
|
|
150
|
+
|
|
151
|
+
2. Button Transactions - CordyStackTrans
|
|
152
|
+
|
|
153
|
+
The CordyStackTrans function provides a simple and reusable transaction handler for EVM-based networks.
|
|
154
|
+
It allows developers to trigger ERC20 or native token transfers directly from UI components with minimal setup.
|
|
155
|
+
|
|
156
|
+
```ts
|
|
92
157
|
import { CordyStackTrans } from "@cordystackx/cordy_minikit";
|
|
93
|
-
|
|
94
|
-
CordyStackTrans(address: string, cost: number | string);
|
|
95
158
|
|
|
159
|
+
// Example Usage
|
|
160
|
+
CordyStackTrans(address: string, cost: number);
|
|
161
|
+
|
|
162
|
+
const trans = CordyStackTrans();
|
|
163
|
+
|
|
164
|
+
if (trans) {
|
|
165
|
+
return true; // Transaction successfull
|
|
166
|
+
} else {
|
|
167
|
+
return false; // Transaction failed or rejected
|
|
168
|
+
}
|
|
96
169
|
```
|
|
97
170
|
|
|
98
171
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export default function CordyStackTrans(address: string, cost: number): Promise<
|
|
1
|
+
export default function CordyStackTrans(address: string, cost: number): Promise<boolean>;
|
|
2
2
|
//# sourceMappingURL=Transactions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Transactions.d.ts","sourceRoot":"","sources":["../../controllers/Transactions.tsx"],"names":[],"mappings":"AAMA,wBAA8B,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"Transactions.d.ts","sourceRoot":"","sources":["../../controllers/Transactions.tsx"],"names":[],"mappings":"AAMA,wBAA8B,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,oBAmC1E"}
|
|
@@ -3,8 +3,10 @@ import tokenAbi from '../config/ERC20_ABI.json';
|
|
|
3
3
|
const tokenAddress = process.env.NEXT_PUBLIC_TOKENADDRESS || "";
|
|
4
4
|
const platformAddress = process.env.NEXT_PUBLIC_PLATFORM_ADDRESS || "";
|
|
5
5
|
export default async function CordyStackTrans(address, cost) {
|
|
6
|
-
if (!address)
|
|
7
|
-
|
|
6
|
+
if (!address) {
|
|
7
|
+
console.error("Address Not Found");
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
8
10
|
try {
|
|
9
11
|
const provider = new ethers.BrowserProvider(window.ethereum);
|
|
10
12
|
const signer = await provider.getSigner();
|
|
@@ -13,19 +15,23 @@ export default async function CordyStackTrans(address, cost) {
|
|
|
13
15
|
const amount = parseUnits(String(cost), decimals);
|
|
14
16
|
const balance = await tokenContract.balanceOf(await signer.getAddress());
|
|
15
17
|
if (balance < amount) {
|
|
16
|
-
|
|
18
|
+
console.log("Insuficient Funds");
|
|
19
|
+
return false;
|
|
17
20
|
}
|
|
18
21
|
const tx = await tokenContract.transfer(platformAddress, amount);
|
|
19
22
|
const receipt = await tx.wait();
|
|
20
23
|
if (receipt) {
|
|
21
|
-
|
|
24
|
+
console.log("Transaction Complete TX hash", receipt);
|
|
25
|
+
return true;
|
|
22
26
|
}
|
|
23
27
|
else {
|
|
24
|
-
|
|
28
|
+
console.log("Transaction Failed", receipt);
|
|
29
|
+
return false;
|
|
25
30
|
}
|
|
26
31
|
}
|
|
27
32
|
catch (err) {
|
|
28
33
|
console.error(err);
|
|
34
|
+
return false;
|
|
29
35
|
}
|
|
30
36
|
}
|
|
31
37
|
;
|