ethershell 0.1.0-alpha.8 → 0.1.0-beta.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 -55
- package/README.md +186 -37
- package/bin/cli.js +12 -3
- package/package.json +10 -3
- package/src/services/addContracts.js +38 -25
- package/src/services/build.js +111 -21
- package/src/services/config.js +15 -0
- package/src/services/files.js +3 -2
- package/src/services/network.js +8 -4
- package/src/services/wallet.js +102 -63
- package/src/utils/accounter.js +77 -7
- package/src/utils/builder.js +15 -0
- package/src/utils/configFileUpdate.js +7 -0
- package/src/utils/contractProxy.js +162 -0
- package/src/utils/serialize.js +17 -0
- package/src/utils/typeGenerator.js +247 -0
package/LICENSE
CHANGED
|
@@ -1,55 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
Effective on the Change Date, or the fourth anniversary of the first publicly
|
|
24
|
-
available distribution of a specific version of the Licensed Work under this
|
|
25
|
-
License, whichever comes first, the Licensor hereby grants you rights under
|
|
26
|
-
the terms of the Change License, and the rights granted in the paragraph
|
|
27
|
-
above terminate.
|
|
28
|
-
|
|
29
|
-
If your use of the Licensed Work does not comply with the requirements
|
|
30
|
-
currently in effect as described in this License, you must purchase a
|
|
31
|
-
commercial license from the Licensor, its affiliated entities, or authorized
|
|
32
|
-
resellers, or you must refrain from using the Licensed Work.
|
|
33
|
-
|
|
34
|
-
All copies of the original and modified Licensed Work, and derivative works
|
|
35
|
-
of the Licensed Work, are subject to this License. This License applies
|
|
36
|
-
separately for each version of the Licensed Work and the Change Date may vary
|
|
37
|
-
for each version of the Licensed Work released by Licensor.
|
|
38
|
-
|
|
39
|
-
You must conspicuously display this License on each original or modified copy
|
|
40
|
-
of the Licensed Work. If you receive the Licensed Work in original or
|
|
41
|
-
modified form from a third party, the terms and conditions set forth in this
|
|
42
|
-
License apply to your use of that work.
|
|
43
|
-
|
|
44
|
-
Any use of the Licensed Work in violation of this License will automatically
|
|
45
|
-
terminate your rights under this License for the current and all other
|
|
46
|
-
versions of the Licensed Work.
|
|
47
|
-
|
|
48
|
-
This License does not grant you any right in any trademark or logo of
|
|
49
|
-
Licensor or its affiliates (provided that you may use a trademark or logo of
|
|
50
|
-
Licensor as expressly required by this License).
|
|
51
|
-
|
|
52
|
-
TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
|
|
53
|
-
AN "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
|
|
54
|
-
EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
|
|
55
|
-
MERCHANTABILITY,
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Alireza Kiakojouri
|
|
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# 🔷 EtherShell - Interactive Ethereum Smart Contract Console
|
|
2
2
|
|
|
3
|
-
**⚠️ WARNING: This package is in
|
|
3
|
+
**⚠️ WARNING: This package is in BETA testing. NOT production ready!**
|
|
4
4
|
|
|
5
5
|
An interactive Node.js console for Ethereum smart contract development. Write, compile, deploy, and manage smart contracts directly from the shell with an intuitive, Solidity-focused developer experience.
|
|
6
6
|
|
|
@@ -13,34 +13,41 @@ An interactive Node.js console for Ethereum smart contract development. Write, c
|
|
|
13
13
|
|
|
14
14
|
## ✨ Features
|
|
15
15
|
|
|
16
|
-
- **Interactive Shell** - Built-in async support for all commands
|
|
17
|
-
- **Solidity Compilation** - Compile contracts with configurable optimization
|
|
16
|
+
- **Interactive REPL Shell** - Built-in async support for all commands with custom evaluation
|
|
17
|
+
- **Solidity Compilation** - Compile contracts with configurable optimization and viaIR mode
|
|
18
18
|
- **Smart Contract Deployment** - Deploy contracts to any EVM network
|
|
19
|
-
- **Wallet Management** - Create, import, and manage wallets (regular & HD wallets)
|
|
20
|
-
- **Multi-Network Support** - Switch between different blockchain networks
|
|
21
|
-
- **Contract
|
|
22
|
-
- **
|
|
19
|
+
- **Wallet Management** - Create, import, and manage wallets (regular & HD wallets, node-managed accounts)
|
|
20
|
+
- **Multi-Network Support** - Switch between different blockchain networks with persistent configuration
|
|
21
|
+
- **Contract Proxy Wrapper** - Enhanced contract interaction with flexible transaction options (from, value, gasLimit, maxFeePerGas, etc.)
|
|
22
|
+
- **Contract Interactions** - Call contract methods with advanced options directly from the shell
|
|
23
|
+
- **ABI & Bytecode Generation** - Organized artifact output with metadata
|
|
23
24
|
- **Node Signer Integration** - Connect to node-managed accounts (Ganache, Hardhat)
|
|
24
|
-
- **TypeScript
|
|
25
|
-
- **Gas Optimization** - Configure compiler optimization levels
|
|
25
|
+
- **TypeScript Code Generation** - Auto-generate TypeScript types from contract ABIs
|
|
26
|
+
- **Gas Optimization** - Configure compiler optimization levels and viaIR code generation
|
|
27
|
+
- **Persistent Configuration** - Save and restore network, compiler, and wallet settings
|
|
28
|
+
- **Comprehensive JSDoc** - Full IDE autocomplete and type hints
|
|
26
29
|
|
|
27
30
|
## 🚀 Quick Start
|
|
28
31
|
|
|
29
32
|
### Installation
|
|
30
33
|
|
|
31
34
|
```bash
|
|
32
|
-
# Install globally
|
|
35
|
+
# Install globally:
|
|
33
36
|
npm i -g ethershell
|
|
34
37
|
|
|
35
|
-
# Start EtherShell
|
|
36
|
-
|
|
38
|
+
# Start EtherShell:
|
|
39
|
+
ethershell
|
|
40
|
+
|
|
41
|
+
#or
|
|
42
|
+
|
|
43
|
+
npx ethershell
|
|
37
44
|
```
|
|
38
45
|
|
|
39
46
|
### Basic Usage
|
|
40
47
|
|
|
41
48
|
```bash
|
|
42
49
|
# Start the console
|
|
43
|
-
|
|
50
|
+
ethershell
|
|
44
51
|
|
|
45
52
|
# You should see:
|
|
46
53
|
# EtherShell>
|
|
@@ -54,7 +61,7 @@ First, connect to a blockchain network:
|
|
|
54
61
|
|
|
55
62
|
```javascript
|
|
56
63
|
// View current network
|
|
57
|
-
EtherShell>
|
|
64
|
+
EtherShell> chainInfo()
|
|
58
65
|
{ URL: 'http://127.0.0.1:8545', name: 'unknown', chainId: 1337n }
|
|
59
66
|
|
|
60
67
|
// Switch to a different network
|
|
@@ -160,6 +167,13 @@ EtherShell> walletInfo(0)
|
|
|
160
167
|
EtherShell> walletInfo('0x1234...5678')
|
|
161
168
|
// or multiple
|
|
162
169
|
EtherShell> walletInfo([0, 1, 2])
|
|
170
|
+
|
|
171
|
+
// Change default account
|
|
172
|
+
EtherShell> changeDefWallet(0)
|
|
173
|
+
// or by address
|
|
174
|
+
EtherShell> changeDefWallet('0x1234...5678')
|
|
175
|
+
// or import and set as default in one command
|
|
176
|
+
EtherShell> changeDefWallet('0xPrivateKeyHere')
|
|
163
177
|
```
|
|
164
178
|
|
|
165
179
|
#### Delete Wallets
|
|
@@ -194,7 +208,7 @@ EtherShell> compiler()
|
|
|
194
208
|
EtherShell> compUpdate('v0.8.19+commit.7dd6d404')
|
|
195
209
|
Loaded solc version: 0.8.19+commit.7dd6d404.Emscripten.clang
|
|
196
210
|
|
|
197
|
-
// Configure compilation options
|
|
211
|
+
// Configure compilation options (gasOptimizer, viaIR, optimizerRuns)
|
|
198
212
|
EtherShell> compOpts(true, false, 1000)
|
|
199
213
|
✓ Compiler options updated:
|
|
200
214
|
Gas Optimizer: Enabled
|
|
@@ -204,6 +218,27 @@ EtherShell> compOpts(true, false, 1000)
|
|
|
204
218
|
// Get current options
|
|
205
219
|
EtherShell> compInfo()
|
|
206
220
|
{ optimizer: true, optimizerRuns: 1000, viaIR: false }
|
|
221
|
+
|
|
222
|
+
// Get current config info
|
|
223
|
+
EtherShell> configInfo()
|
|
224
|
+
{
|
|
225
|
+
providerEndpoint: '...',
|
|
226
|
+
defaultWallet: { ... },
|
|
227
|
+
compiler: {
|
|
228
|
+
version: 'v0.8.29+commit.ab55807c',
|
|
229
|
+
optimizer: false,
|
|
230
|
+
viaIR: false,
|
|
231
|
+
optimizerRuns: 200,
|
|
232
|
+
compilePath: './build'
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// Get default wallet
|
|
237
|
+
EtherShell> defWallet()
|
|
238
|
+
{ address: '0x...', ... }
|
|
239
|
+
|
|
240
|
+
// Change build output path
|
|
241
|
+
EtherShell> compPath('./custom-build')
|
|
207
242
|
```
|
|
208
243
|
|
|
209
244
|
#### Compile Contracts
|
|
@@ -212,6 +247,7 @@ EtherShell> compInfo()
|
|
|
212
247
|
// Compile all .sol files in ./contracts directory
|
|
213
248
|
EtherShell> build()
|
|
214
249
|
Contracts compiled into /path/to/build
|
|
250
|
+
TypeScript types generated in /path/to/build/types
|
|
215
251
|
|
|
216
252
|
// Compile a specific contract file
|
|
217
253
|
EtherShell> build('./contracts/MyToken.sol')
|
|
@@ -232,7 +268,8 @@ build/
|
|
|
232
268
|
├── artifacts/ # Complete contract data with metadata
|
|
233
269
|
├── abis/ # Contract ABIs (.abi.json files)
|
|
234
270
|
├── bytecode/ # Contract bytecode (.bin files)
|
|
235
|
-
|
|
271
|
+
├── metadata/ # Contract metadata (.metadata.json files)
|
|
272
|
+
└── types/ # Auto-generated TypeScript types
|
|
236
273
|
```
|
|
237
274
|
|
|
238
275
|
### 4. Smart Contract Deployment
|
|
@@ -240,7 +277,35 @@ build/
|
|
|
240
277
|
#### Deploy New Contracts
|
|
241
278
|
|
|
242
279
|
```javascript
|
|
243
|
-
// Deploy
|
|
280
|
+
// Deploy contract without constructor args and with default wallet
|
|
281
|
+
// Arguments: contractName
|
|
282
|
+
EtherShell> deploy('contractName')
|
|
283
|
+
{
|
|
284
|
+
hash: '0x123abc...',
|
|
285
|
+
from: '0x1234...5678',
|
|
286
|
+
to: null,
|
|
287
|
+
address: '0xabcd...ef01',
|
|
288
|
+
name: 'contractName',
|
|
289
|
+
chain: 'sepolia',
|
|
290
|
+
chainId: 11155111n,
|
|
291
|
+
deployType: 'ethershell-deployed'
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
// Deploy MyToken contract with constructor args and default wallet
|
|
295
|
+
// Arguments: contractName, args[], walletIndex, [chainURL], [abiLocation], [bytecodeLocation]
|
|
296
|
+
EtherShell> deploy('MyToken', ['MyTokenName', 'MTK', 1000000])
|
|
297
|
+
{
|
|
298
|
+
hash: '0x123abc...',
|
|
299
|
+
from: '0x1234...5678',
|
|
300
|
+
to: null,
|
|
301
|
+
address: '0xabcd...ef01',
|
|
302
|
+
name: 'MyToken',
|
|
303
|
+
chain: 'sepolia',
|
|
304
|
+
chainId: 11155111n,
|
|
305
|
+
deployType: 'ethershell-deployed'
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
// Deploy MyToken contract with constructor args and a non-default wallet
|
|
244
309
|
// Arguments: contractName, args[], walletIndex, [chainURL], [abiLocation], [bytecodeLocation]
|
|
245
310
|
EtherShell> deploy('MyToken', ['MyTokenName', 'MTK', 1000000], 0)
|
|
246
311
|
{
|
|
@@ -250,13 +315,14 @@ EtherShell> deploy('MyToken', ['MyTokenName', 'MTK', 1000000], 0)
|
|
|
250
315
|
address: '0xabcd...ef01',
|
|
251
316
|
name: 'MyToken',
|
|
252
317
|
chain: 'sepolia',
|
|
318
|
+
chainId: 11155111n,
|
|
253
319
|
deployType: 'ethershell-deployed'
|
|
254
320
|
}
|
|
255
321
|
|
|
256
322
|
// Deploy with custom chain
|
|
257
323
|
EtherShell> deploy('MyContract', ['arg1', 'arg2'], 0, 'https://custom-rpc.url')
|
|
258
324
|
|
|
259
|
-
// The deployed contract is automatically added to console context
|
|
325
|
+
// The deployed contract is automatically added to console context as a proxy
|
|
260
326
|
EtherShell> MyToken
|
|
261
327
|
Contract {
|
|
262
328
|
target: '0xabcd...ef01',
|
|
@@ -300,16 +366,14 @@ EtherShell> contracts()
|
|
|
300
366
|
address: '0xabcd...ef01',
|
|
301
367
|
chain: 'sepolia',
|
|
302
368
|
chainId: 11155111n,
|
|
303
|
-
deployType: 'ethershell-deployed'
|
|
304
|
-
balance: 0n
|
|
369
|
+
deployType: 'ethershell-deployed'
|
|
305
370
|
},
|
|
306
371
|
{
|
|
307
372
|
index: 1,
|
|
308
373
|
name: 'USDT',
|
|
309
374
|
address: '0xdAC17F958D2ee523a2206206994597C13D831ec7',
|
|
310
375
|
chain: 'mainnet',
|
|
311
|
-
deployType: 'pre-deployed'
|
|
312
|
-
balance: 0n
|
|
376
|
+
deployType: 'pre-deployed'
|
|
313
377
|
}
|
|
314
378
|
]
|
|
315
379
|
|
|
@@ -341,11 +405,36 @@ EtherShell> MyToken.totalSupply()
|
|
|
341
405
|
EtherShell> MyToken.transfer('0xRecipientAddress', 100)
|
|
342
406
|
ContractTransactionResponse { ... }
|
|
343
407
|
|
|
408
|
+
// Call with advanced transaction options
|
|
409
|
+
EtherShell> MyToken.transfer('0xRecipientAddress', 100, {
|
|
410
|
+
from: '0xSenderAddress', // Switch signer
|
|
411
|
+
value: 10000000000000n, // Send ETH (for payable functions)
|
|
412
|
+
gasLimit: 500000, // Custom gas limit
|
|
413
|
+
maxFeePerGas: 100000000000n, // EIP-1559
|
|
414
|
+
maxPriorityFeePerGas: 2000000000n,
|
|
415
|
+
nonce: 42,
|
|
416
|
+
chainId: 1
|
|
417
|
+
})
|
|
418
|
+
|
|
344
419
|
// Check balance
|
|
345
420
|
EtherShell> MyToken.balanceOf('0x1234...5678')
|
|
346
421
|
100n
|
|
347
422
|
```
|
|
348
423
|
|
|
424
|
+
**Contract Proxy Options:**
|
|
425
|
+
The contract proxy wrapper supports these transaction options:
|
|
426
|
+
- `from`: Change the signer/sender for the transaction
|
|
427
|
+
- `value`: ETH amount to send (for payable functions)
|
|
428
|
+
- `gasLimit` / `gas`: Maximum gas to use
|
|
429
|
+
- `gasPrice`: Legacy transaction gas price
|
|
430
|
+
- `maxFeePerGas`: EIP-1559 max fee per gas
|
|
431
|
+
- `maxPriorityFeePerGas`: EIP-1559 priority fee per gas
|
|
432
|
+
- `nonce`: Transaction nonce for ordering
|
|
433
|
+
- `chainId`: Network chain ID
|
|
434
|
+
- `accessList`: EIP-2930 access list
|
|
435
|
+
- `type`: Transaction type (0, 1, 2, or 3)
|
|
436
|
+
- `customData`: Custom data for special networks (zkSync)
|
|
437
|
+
|
|
349
438
|
## 🎯 Complete Usage Example
|
|
350
439
|
|
|
351
440
|
Here's a full workflow example:
|
|
@@ -367,21 +456,22 @@ EtherShell> compOpts(true, false, 1000)
|
|
|
367
456
|
EtherShell> build()
|
|
368
457
|
|
|
369
458
|
// 6. Deploy contract
|
|
370
|
-
EtherShell> deploy('MyToken', ['TestToken', 'TEST', 1000000]
|
|
459
|
+
EtherShell> deploy('MyToken', ['TestToken', 'TEST', 1000000])
|
|
371
460
|
|
|
372
461
|
// 7. Interact with contract
|
|
373
462
|
EtherShell> MyToken.balanceOf('0x...')
|
|
463
|
+
1000000000000000000000000n
|
|
374
464
|
|
|
375
|
-
// 8. Transfer tokens
|
|
376
|
-
EtherShell> tx = MyToken.transfer('0x...', 100
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
465
|
+
// 8. Transfer tokens with custom options
|
|
466
|
+
EtherShell> tx = MyToken.transfer('0x...', 100, {
|
|
467
|
+
gasLimit: 100000,
|
|
468
|
+
maxFeePerGas: 50000000000n
|
|
469
|
+
})
|
|
380
470
|
|
|
381
|
-
//
|
|
471
|
+
// 9. Check balance again
|
|
382
472
|
EtherShell> MyToken.balanceOf('0x...')
|
|
383
473
|
|
|
384
|
-
//
|
|
474
|
+
// 10. View all contracts
|
|
385
475
|
EtherShell> contracts()
|
|
386
476
|
```
|
|
387
477
|
|
|
@@ -391,7 +481,7 @@ EtherShell> contracts()
|
|
|
391
481
|
| Command | Description |
|
|
392
482
|
|---------|-------------|
|
|
393
483
|
| `chain(url)` | Connect to blockchain network |
|
|
394
|
-
| `
|
|
484
|
+
| `chainInfo()` | Get current network info |
|
|
395
485
|
| `defaultChain()` | Get default network URL |
|
|
396
486
|
|
|
397
487
|
### Wallet Commands
|
|
@@ -406,6 +496,7 @@ EtherShell> contracts()
|
|
|
406
496
|
| `hdWallets()` | View HD accounts |
|
|
407
497
|
| `allWallets()` | View all accounts |
|
|
408
498
|
| `walletInfo(index\|address\|[indices])` | Get wallet details (balance, nonce) |
|
|
499
|
+
| `changeDefWallet(pointer)` | Set default account |
|
|
409
500
|
| `removeWallet(pointer)` | Delete account(s) |
|
|
410
501
|
|
|
411
502
|
### Compiler Commands
|
|
@@ -415,13 +506,16 @@ EtherShell> contracts()
|
|
|
415
506
|
| `compUpdate(version)` | Load specific Solidity version |
|
|
416
507
|
| `compOpts(gasOpt, viaIR, runs)` | Configure optimization |
|
|
417
508
|
| `compInfo()` | Get current compiler options |
|
|
509
|
+
| `configInfo()` | Get all configuration info |
|
|
510
|
+
| `defWallet()` | Get default account |
|
|
511
|
+
| `compPath(newPath)` | Change build output path |
|
|
418
512
|
| `build([path], [contracts], [output])` | Compile contracts |
|
|
419
513
|
| `clean([path])` | Delete build directory |
|
|
420
514
|
|
|
421
515
|
### Contract Commands
|
|
422
516
|
| Command | Description |
|
|
423
517
|
|---------|-------------|
|
|
424
|
-
| `deploy(name, args, index)` | Deploy new contract |
|
|
518
|
+
| `deploy(name, [args], [index], [chainURL], [abiLocation], [bytecodeLocation])` | Deploy new contract |
|
|
425
519
|
| `addContract(name, address, index, abiPath)` | Add existing contract |
|
|
426
520
|
| `contracts([pointer])` | List contracts or get specific one |
|
|
427
521
|
|
|
@@ -457,15 +551,22 @@ ethershell/
|
|
|
457
551
|
│ │ ├── wallet.js # Wallet management
|
|
458
552
|
│ │ ├── network.js # Network provider
|
|
459
553
|
│ │ ├── addContracts.js # Contract deployment
|
|
460
|
-
│ │
|
|
554
|
+
│ │ ├── contracts.js # Contract retrieval
|
|
555
|
+
│ │ ├── config.js # Configuration
|
|
556
|
+
│ │ └── files.js # File utilities
|
|
461
557
|
│ └── utils/
|
|
462
558
|
│ ├── builder.js # Compilation engine
|
|
463
559
|
│ ├── dir.js # Directory utilities
|
|
464
560
|
│ ├── accounter.js # Account utilities
|
|
561
|
+
│ ├── contractProxy.js # Contract proxy wrapper
|
|
465
562
|
│ ├── contractLister.js # Contract formatting
|
|
466
|
-
│
|
|
563
|
+
│ ├── typeGenerator.js # TypeScript type generation
|
|
564
|
+
│ ├── replHelper.js # REPL customization
|
|
565
|
+
│ ├── serialize.js # BigInt serialization
|
|
566
|
+
│ └── configFileUpdate.js # Config utilities
|
|
467
567
|
├── contracts/ # Your Solidity contracts
|
|
468
568
|
├── build/ # Compiled artifacts
|
|
569
|
+
├── localStorage/ # Persistent config and wallet storage
|
|
469
570
|
└── package.json
|
|
470
571
|
```
|
|
471
572
|
|
|
@@ -508,7 +609,7 @@ contract MyToken {
|
|
|
508
609
|
EtherShell> build('./contracts/MyToken.sol')
|
|
509
610
|
|
|
510
611
|
// 2. Deploy
|
|
511
|
-
EtherShell> deploy('MyToken'
|
|
612
|
+
EtherShell> deploy('MyToken')
|
|
512
613
|
|
|
513
614
|
// 3. Interact
|
|
514
615
|
EtherShell> MyToken.balanceOf('0x...')
|
|
@@ -520,7 +621,39 @@ EtherShell> MyToken.transfer('0x...', 100)
|
|
|
520
621
|
|
|
521
622
|
## ⚙️ Configuration
|
|
522
623
|
|
|
523
|
-
###
|
|
624
|
+
### Persistent Storage
|
|
625
|
+
|
|
626
|
+
EtherShell stores configuration in the `localStorage` directory:
|
|
627
|
+
|
|
628
|
+
```
|
|
629
|
+
localStorage/
|
|
630
|
+
├── config.json # Compiler and network settings
|
|
631
|
+
├── wallets.json # Imported/generated wallets
|
|
632
|
+
```
|
|
633
|
+
|
|
634
|
+
### Configuration File
|
|
635
|
+
|
|
636
|
+
The `config.json` file contains:
|
|
637
|
+
|
|
638
|
+
```json
|
|
639
|
+
{
|
|
640
|
+
"providerEndpoint": "http://127.0.0.1:8545",
|
|
641
|
+
"defaultWallet": {
|
|
642
|
+
"index": 0,
|
|
643
|
+
"address": "0x...",
|
|
644
|
+
"type": "user-generated"
|
|
645
|
+
},
|
|
646
|
+
"compiler": {
|
|
647
|
+
"version": "v0.8.20+commit.a1b79de6",
|
|
648
|
+
"optimizer": false,
|
|
649
|
+
"viaIR": false,
|
|
650
|
+
"optimizerRuns": 200,
|
|
651
|
+
"compilePath": "./build"
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
```
|
|
655
|
+
|
|
656
|
+
### Environment Variables (Optional)
|
|
524
657
|
|
|
525
658
|
Create a `.env` file (optional):
|
|
526
659
|
|
|
@@ -538,6 +671,7 @@ CONTRACTS_PATH=./contracts
|
|
|
538
671
|
COMPILER_VERSION=0.8.20+commit.a1b79de6
|
|
539
672
|
OPTIMIZER_ENABLED=true
|
|
540
673
|
OPTIMIZER_RUNS=200
|
|
674
|
+
VIAIR_ENABLED=false
|
|
541
675
|
```
|
|
542
676
|
|
|
543
677
|
## 🔒 Security Warnings
|
|
@@ -548,6 +682,7 @@ OPTIMIZER_RUNS=200
|
|
|
548
682
|
2. **Keep private keys safe** - Don't commit `.env` files or private keys to git
|
|
549
683
|
3. **Use read-only RPCs** - For production, use read-only endpoints
|
|
550
684
|
4. **Test on testnet first** - Always test contracts on Sepolia before mainnet
|
|
685
|
+
5. **Verify contracts on Etherscan** - Always verify production contracts
|
|
551
686
|
|
|
552
687
|
```bash
|
|
553
688
|
# Add to .gitignore
|
|
@@ -589,6 +724,20 @@ Solution: npm install
|
|
|
589
724
|
- Verify .sol file exists in ./contracts
|
|
590
725
|
```
|
|
591
726
|
|
|
727
|
+
**Issue: `Cannot use 'from' option with node-managed account`**
|
|
728
|
+
```bash
|
|
729
|
+
- Node-managed accounts cannot be used with the 'from' option
|
|
730
|
+
- Only imported/generated wallets with private keys support 'from'
|
|
731
|
+
- Use .connect() method for node-managed accounts
|
|
732
|
+
```
|
|
733
|
+
|
|
734
|
+
**Issue: `TypeScript types not generated`**
|
|
735
|
+
```bash
|
|
736
|
+
- Ensure contracts compiled successfully with build()
|
|
737
|
+
- Check ABIs exist in build/abis/ directory
|
|
738
|
+
- Look for error messages in the build() output
|
|
739
|
+
```
|
|
740
|
+
|
|
592
741
|
## 📖 API Documentation
|
|
593
742
|
|
|
594
743
|
Full JSDoc documentation is available in the source files. Each file includes:
|
|
@@ -640,4 +789,4 @@ This project is licensed under the BUSL-1.1 License - see LICENSE file for detai
|
|
|
640
789
|
|
|
641
790
|
**Made with ❤️ for Ethereum developers**
|
|
642
791
|
|
|
643
|
-
Happy coding! 🚀
|
|
792
|
+
Happy coding! 🚀
|
package/bin/cli.js
CHANGED
|
@@ -16,7 +16,8 @@ import {
|
|
|
16
16
|
currentCompiler,
|
|
17
17
|
compilerOptions,
|
|
18
18
|
getCompilerOptions,
|
|
19
|
-
compile
|
|
19
|
+
compile,
|
|
20
|
+
changeCompPath
|
|
20
21
|
} from '../src/services/build.js';
|
|
21
22
|
import { set, get, getDefault } from '../src/services/network.js';
|
|
22
23
|
import { deleteDirectory } from '../src/services/files.js';
|
|
@@ -30,11 +31,13 @@ import {
|
|
|
30
31
|
addHD,
|
|
31
32
|
getAllAccounts,
|
|
32
33
|
connectWallet,
|
|
33
|
-
getWalletInfo
|
|
34
|
+
getWalletInfo,
|
|
35
|
+
changeDefaultAccount
|
|
34
36
|
} from '../src/services/wallet.js';
|
|
35
37
|
|
|
36
38
|
import { deploy, add } from '../src/services/addContracts.js';
|
|
37
39
|
import { getContracts } from '../src/services/contracts.js';
|
|
40
|
+
import { getConfigInfo, getDefaultAccount } from '../src/services/config.js';
|
|
38
41
|
|
|
39
42
|
/**
|
|
40
43
|
* REPL instance for EtherShell interactive environment
|
|
@@ -53,7 +56,7 @@ export const r = repl.start({
|
|
|
53
56
|
|
|
54
57
|
// Network commands
|
|
55
58
|
r.context.chain = set;
|
|
56
|
-
r.context.
|
|
59
|
+
r.context.chainInfo = get;
|
|
57
60
|
r.context.defaultChain = getDefault;
|
|
58
61
|
|
|
59
62
|
// Compile commands
|
|
@@ -61,8 +64,14 @@ r.context.compiler = currentCompiler;
|
|
|
61
64
|
r.context.compUpdate = updateCompiler;
|
|
62
65
|
r.context.compInfo = getCompilerOptions;
|
|
63
66
|
r.context.compOpts = compilerOptions;
|
|
67
|
+
r.context.compPath = changeCompPath;
|
|
64
68
|
r.context.build = compile;
|
|
65
69
|
|
|
70
|
+
// Config commands
|
|
71
|
+
r.context.configInfo = getConfigInfo;
|
|
72
|
+
r.context.changeDefWallet = changeDefaultAccount;
|
|
73
|
+
r.context.defWallet = getDefaultAccount;
|
|
74
|
+
|
|
66
75
|
// Clean build folder
|
|
67
76
|
r.context.clean = deleteDirectory;
|
|
68
77
|
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ethershell",
|
|
3
|
-
"
|
|
3
|
+
"license": "MIT",
|
|
4
|
+
"version": "0.1.0-beta.0",
|
|
4
5
|
"description": "Interactive JavaScript console for Ethereum smart contract management",
|
|
5
|
-
"license": "BUSL-1.1",
|
|
6
6
|
"author": "Alireza Kiakojouri (alirezaethdev@gmail.com)",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
"blockchain"
|
|
35
35
|
],
|
|
36
36
|
"dependencies": {
|
|
37
|
+
"commander": "^12.1.0",
|
|
37
38
|
"ethers": "^6.13.0",
|
|
38
39
|
"node-localstorage": "^3.0.5",
|
|
39
40
|
"solc": "^0.8.29",
|
|
@@ -45,5 +46,11 @@
|
|
|
45
46
|
"src/",
|
|
46
47
|
"LICENSE",
|
|
47
48
|
"README.md"
|
|
48
|
-
]
|
|
49
|
+
],
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@typechain/ethers-v6": "^0.5.1",
|
|
52
|
+
"@types/node": "^24.10.2",
|
|
53
|
+
"typechain": "^8.3.2",
|
|
54
|
+
"typescript": "^5.9.3"
|
|
55
|
+
}
|
|
49
56
|
}
|