@reactmore/crypto-wallet-sdk 1.2.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.
- package/LICENSE +21 -0
- package/README.md +255 -0
- package/dist/api/dex.d.ts +7 -0
- package/dist/client/index.d.ts +14 -0
- package/dist/crypto-wallet-sdk.cjs.development.js +1962 -0
- package/dist/crypto-wallet-sdk.cjs.development.js.map +1 -0
- package/dist/crypto-wallet-sdk.cjs.production.min.js +2 -0
- package/dist/crypto-wallet-sdk.cjs.production.min.js.map +1 -0
- package/dist/crypto-wallet-sdk.esm.js +1950 -0
- package/dist/crypto-wallet-sdk.esm.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +8 -0
- package/dist/services/base/index.d.ts +1 -0
- package/dist/services/base/wallet.d.ts +10 -0
- package/dist/services/btc/index.d.ts +1 -0
- package/dist/services/btc/wallet.d.ts +8 -0
- package/dist/services/evm/index.d.ts +2 -0
- package/dist/services/evm/types.d.ts +69 -0
- package/dist/services/evm/wallet.d.ts +24 -0
- package/dist/services/index.d.ts +4 -0
- package/dist/services/sol/index.d.ts +2 -0
- package/dist/services/sol/types.d.ts +21 -0
- package/dist/services/sol/wallet.d.ts +19 -0
- package/dist/services/wallet-registry.d.ts +7 -0
- package/dist/types/index.d.ts +35 -0
- package/dist/utils/amount.d.ts +10 -0
- package/dist/utils/btcUnits.d.ts +4 -0
- package/dist/utils/evmUnits.d.ts +6 -0
- package/dist/utils/index.d.ts +5 -0
- package/dist/utils/response.d.ts +2 -0
- package/dist/utils/solUnits.d.ts +4 -0
- package/package.json +72 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 reactmore-tech
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
# Crypto Wallet SDK
|
|
2
|
+
|
|
3
|
+
A multi-chain crypto wallet SDK focused on EVM first. This SDK is designed for building bots, services, and backends that can **generate wallets, check balances, send transactions, estimate gas, and interact with smart contracts**.
|
|
4
|
+
|
|
5
|
+
> โ ๏ธ This project is under active development. APIs may change.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## โจ Features
|
|
10
|
+
|
|
11
|
+
- ๐ Generate wallets (mnemonic / private key)
|
|
12
|
+
- ๐ฐ Get balance (native coin & token)
|
|
13
|
+
- ๐ Transfer native coin or token
|
|
14
|
+
- ๐งพ Send transaction
|
|
15
|
+
- โฝ Gas estimation (Legacy & EIP-1559)
|
|
16
|
+
- ๐ Smart contract call (read & write)
|
|
17
|
+
- ๐ Get transaction & receipt
|
|
18
|
+
- ๐งฑ Modular architecture (ready for multi-chain)
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## โ๏ธ Supported Chains
|
|
23
|
+
|
|
24
|
+
| Chain | Network Type | Status | Notes |
|
|
25
|
+
|-------------|--------------|---------------|-------------------------------|
|
|
26
|
+
| Ethereum | EVM | โ
Supported | Mainnet, Sepolia, etc |
|
|
27
|
+
| BSC | EVM | โ
Supported | Compatible with EVM adapter |
|
|
28
|
+
| Arbitrum | EVM | ๐ก Tested | Compatible with EVM adapter |
|
|
29
|
+
| Optimism | EVM | ๐ก Tested | Compatible with EVM adapter |
|
|
30
|
+
| Base | EVM | ๐ก Tested | Compatible with EVM adapter |
|
|
31
|
+
| Polygon | EVM | ๐ก Tested | Compatible with EVM adapter |
|
|
32
|
+
| Solana | Non-EVM | ๐ก Planned | Separate adapter |
|
|
33
|
+
| Bitcoin | Non-EVM | ๐ก Planned | Separate adapter |
|
|
34
|
+
| Tron | Non-EVM | ๐ก Planned | Separate adapter |
|
|
35
|
+
| Doge / LTC | Non-EVM | ๐ก Planned | UTXO-based chains |
|
|
36
|
+
|
|
37
|
+
Legend:
|
|
38
|
+
- โ
Supported = Already implemented / usable
|
|
39
|
+
- ๐ก Planned = In roadmap
|
|
40
|
+
- ๐ด Not supported = Not in scope (yet)
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## ๐ฆ Installation
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
npm install
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
or if published later:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
npm i @reactmore/crypto-wallet-sdk
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## ๐ Quick Start
|
|
59
|
+
|
|
60
|
+
```ts
|
|
61
|
+
import { CryptoClientSdk } from "@reactmore/crypto-wallet-sdk";
|
|
62
|
+
|
|
63
|
+
const client = new CryptoClientSdk({
|
|
64
|
+
network: "EVM",
|
|
65
|
+
chainId: "11155111", // Sepolia
|
|
66
|
+
rpcUrl: "https://ethereum-sepolia-rpc.publicnode.com",
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
const wallet = client.getWallet();
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## ๐ Generate Wallet
|
|
75
|
+
|
|
76
|
+
```ts
|
|
77
|
+
const res = await wallet.generateWallet({});
|
|
78
|
+
console.log(res);
|
|
79
|
+
// { address, publicKey, privateKey }
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
## ๐ฐ Get Balance
|
|
85
|
+
|
|
86
|
+
### Native Coin
|
|
87
|
+
|
|
88
|
+
```ts
|
|
89
|
+
const res = await wallet.getBalance({
|
|
90
|
+
address: "0xYourAddressHere",
|
|
91
|
+
});
|
|
92
|
+
console.log(res);
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### ERC20 Token
|
|
96
|
+
|
|
97
|
+
```ts
|
|
98
|
+
const res = await wallet.getBalance({
|
|
99
|
+
address: "0xYourAddressHere",
|
|
100
|
+
contractAddress: "0xTokenContractAddress",
|
|
101
|
+
});
|
|
102
|
+
console.log(res);
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
## ๐ Transfer (Native / ERC20)
|
|
108
|
+
|
|
109
|
+
### Native Transfer
|
|
110
|
+
|
|
111
|
+
```ts
|
|
112
|
+
const res = await wallet.transfer({
|
|
113
|
+
recipientAddress: "0xRecipient",
|
|
114
|
+
privateKey: "0xYourPrivateKey",
|
|
115
|
+
amount: 0.01,
|
|
116
|
+
});
|
|
117
|
+
console.log(res);
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### With Custom Memo (data)
|
|
121
|
+
|
|
122
|
+
```ts
|
|
123
|
+
const res = await wallet.transfer({
|
|
124
|
+
recipientAddress: "0xRecipient",
|
|
125
|
+
privateKey: "0xYourPrivateKey",
|
|
126
|
+
amount: 0.005,
|
|
127
|
+
gasPrice: "20", // gwei (legacy example)
|
|
128
|
+
data: "Payment for services",
|
|
129
|
+
});
|
|
130
|
+
console.log(res);
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### ERC20 Transfer
|
|
134
|
+
|
|
135
|
+
```ts
|
|
136
|
+
const res = await wallet.transfer({
|
|
137
|
+
recipientAddress: "0xRecipient",
|
|
138
|
+
privateKey: "0xYourPrivateKey",
|
|
139
|
+
amount: 10,
|
|
140
|
+
contractAddress: "0xTokenContract",
|
|
141
|
+
});
|
|
142
|
+
console.log(res);
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
## โฝ Estimate Gas
|
|
148
|
+
|
|
149
|
+
```ts
|
|
150
|
+
const res = await wallet.estimateGas({
|
|
151
|
+
recipientAddress: "0xRecipient",
|
|
152
|
+
amount: "0.01",
|
|
153
|
+
data: "optional memo",
|
|
154
|
+
});
|
|
155
|
+
console.log(res);
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
Supports:
|
|
159
|
+
- Legacy gas model
|
|
160
|
+
- EIP-1559 (maxFeePerGas & maxPriorityFeePerGas)
|
|
161
|
+
|
|
162
|
+
---
|
|
163
|
+
|
|
164
|
+
## ๐ Smart Contract Call
|
|
165
|
+
|
|
166
|
+
### Read
|
|
167
|
+
|
|
168
|
+
```ts
|
|
169
|
+
const res = await wallet.smartContractCall({
|
|
170
|
+
rpcUrl: "https://ethereum-sepolia-rpc.publicnode.com",
|
|
171
|
+
contractAddress: "0xContract",
|
|
172
|
+
method: "balanceOf",
|
|
173
|
+
methodType: "read",
|
|
174
|
+
params: ["0xAddress"],
|
|
175
|
+
contractAbi: [...],
|
|
176
|
+
});
|
|
177
|
+
console.log(res);
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### Write
|
|
181
|
+
|
|
182
|
+
```ts
|
|
183
|
+
const res = await wallet.smartContractCall({
|
|
184
|
+
rpcUrl: "https://ethereum-sepolia-rpc.publicnode.com",
|
|
185
|
+
contractAddress: "0xContract",
|
|
186
|
+
method: "transfer",
|
|
187
|
+
methodType: "write",
|
|
188
|
+
params: ["0xTo", "1000000"],
|
|
189
|
+
contractAbi: [...],
|
|
190
|
+
privateKey: "0xYourPrivateKey",
|
|
191
|
+
});
|
|
192
|
+
console.log(res);
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
---
|
|
196
|
+
|
|
197
|
+
## ๐ Get Transaction
|
|
198
|
+
|
|
199
|
+
```ts
|
|
200
|
+
const res = await wallet.getTransaction({
|
|
201
|
+
hash: "0xTxHash",
|
|
202
|
+
withReceipt: true,
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
console.log(res);
|
|
206
|
+
// {
|
|
207
|
+
// transaction,
|
|
208
|
+
// receipt,
|
|
209
|
+
// memo
|
|
210
|
+
// }
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
If the transaction contains `data`, `memo` will be automatically decoded (UTF-8).
|
|
214
|
+
|
|
215
|
+
---
|
|
216
|
+
|
|
217
|
+
## ๐งฉ Architecture
|
|
218
|
+
|
|
219
|
+
- `BaseWallet` โ Common wallet interface
|
|
220
|
+
- `EvmWallet` โ EVM implementation (Ethereum, BSC, Arbitrum, etc)
|
|
221
|
+
- `utils` โ Unit conversion (parseEther, formatEther, parseGwei, etc)
|
|
222
|
+
- Future chains will live in their own adapters:
|
|
223
|
+
- `SolanaWallet`
|
|
224
|
+
- `BitcoinWallet`
|
|
225
|
+
- `TronWallet`
|
|
226
|
+
- etc.
|
|
227
|
+
|
|
228
|
+
---
|
|
229
|
+
|
|
230
|
+
## ๐ฃ๏ธ Roadmap
|
|
231
|
+
|
|
232
|
+
- [ ] EVM: Event listener / incoming transfer watcher
|
|
233
|
+
- [ ] EVM: Token transfer history helper
|
|
234
|
+
- [ ] Solana adapter
|
|
235
|
+
- [ ] Bitcoin adapter (UTXO)
|
|
236
|
+
- [ ] Webhook / hook integration
|
|
237
|
+
- [ ] Better typings & docs
|
|
238
|
+
|
|
239
|
+
---
|
|
240
|
+
|
|
241
|
+
## โ ๏ธ Disclaimer
|
|
242
|
+
|
|
243
|
+
This SDK does **NOT** manage private key security for you.
|
|
244
|
+
You are responsible for:
|
|
245
|
+
- Storing private keys securely
|
|
246
|
+
- Managing RPC reliability
|
|
247
|
+
- Handling reorgs, retries, and confirmations
|
|
248
|
+
|
|
249
|
+
Use at your own risk in production.
|
|
250
|
+
|
|
251
|
+
---
|
|
252
|
+
|
|
253
|
+
## ๐ License
|
|
254
|
+
|
|
255
|
+
MIT
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { WalletRegistry, WalletTypes } from "../services/wallet-registry";
|
|
2
|
+
interface ClientConfig<T extends WalletTypes> {
|
|
3
|
+
network: T;
|
|
4
|
+
chainId?: string;
|
|
5
|
+
rpcUrl?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare class CryptoClientSdk<T extends WalletTypes> {
|
|
8
|
+
private network;
|
|
9
|
+
private chainId?;
|
|
10
|
+
private rpcUrl?;
|
|
11
|
+
constructor({ network, chainId, rpcUrl }: ClientConfig<T>);
|
|
12
|
+
getWallet(): InstanceType<(typeof WalletRegistry)[T]>;
|
|
13
|
+
}
|
|
14
|
+
export {};
|