midnight-wallet-cli 0.1.11 → 0.2.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 +65 -10
- package/dist/mcp-server.js +244 -149
- package/dist/wallet.js +334 -186
- package/package.json +13 -9
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
[](https://npm-stat.com/charts.html?package=midnight-wallet-cli)
|
|
5
5
|
[](https://www.apache.org/licenses/LICENSE-2.0)
|
|
6
6
|
[](https://www.typescriptlang.org/)
|
|
7
|
-
|
|
7
|
+
|
|
8
8
|
|
|
9
9
|
A standalone CLI wallet for the Midnight blockchain. Manage wallets, check balances, transfer NIGHT tokens, and run a local network — all from the terminal.
|
|
10
10
|
|
|
@@ -20,7 +20,11 @@ This installs two commands: `midnight` (or `mn` for short) and `midnight-wallet-
|
|
|
20
20
|
|
|
21
21
|
| Command | Description |
|
|
22
22
|
|---------|-------------|
|
|
23
|
-
| `midnight generate
|
|
23
|
+
| `midnight wallet generate <name>` | Create a named wallet and set it as active |
|
|
24
|
+
| `midnight wallet list` | List all wallets with active marker |
|
|
25
|
+
| `midnight wallet use <name>` | Set the active wallet |
|
|
26
|
+
| `midnight wallet info [name]` | Show wallet details |
|
|
27
|
+
| `midnight wallet remove <name>` | Remove a wallet |
|
|
24
28
|
| `midnight info` | Display wallet address, network, creation date |
|
|
25
29
|
| `midnight balance [address]` | Check unshielded NIGHT balance |
|
|
26
30
|
| `midnight transfer <to> <amount>` | Send NIGHT tokens to another address |
|
|
@@ -30,27 +34,38 @@ This installs two commands: `midnight` (or `mn` for short) and `midnight-wallet-
|
|
|
30
34
|
| `midnight address --seed <hex>` | Derive an address from a seed |
|
|
31
35
|
| `midnight genesis-address` | Show the genesis wallet address |
|
|
32
36
|
| `midnight inspect-cost` | Display current block cost limits |
|
|
33
|
-
| `midnight
|
|
37
|
+
| `midnight serve` | Start DApp Connector server (WebSocket JSON-RPC) |
|
|
38
|
+
| `midnight config get/set` | Manage persistent config (network, wallet, endpoints) |
|
|
34
39
|
| `midnight localnet up/stop/down/status` | Manage a local Midnight network via Docker |
|
|
35
40
|
| `midnight help [command]` | Show usage for all or a specific command |
|
|
36
41
|
|
|
37
42
|
## Quick Start
|
|
38
43
|
|
|
44
|
+
### Preprod (testnet)
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
# Generate a wallet on preprod
|
|
48
|
+
midnight wallet generate alice --network preprod
|
|
49
|
+
|
|
50
|
+
# Check balance
|
|
51
|
+
midnight balance
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Local development
|
|
55
|
+
|
|
39
56
|
```bash
|
|
40
57
|
# Start local network
|
|
41
58
|
midnight localnet up
|
|
42
59
|
|
|
43
60
|
# Generate a wallet
|
|
44
|
-
midnight generate --network undeployed
|
|
61
|
+
midnight wallet generate dev --network undeployed
|
|
45
62
|
|
|
46
63
|
# Airdrop tokens and register dust
|
|
47
64
|
midnight airdrop 1000
|
|
48
65
|
midnight dust register
|
|
49
66
|
|
|
50
|
-
# Check balance
|
|
67
|
+
# Check balance and transfer
|
|
51
68
|
midnight balance
|
|
52
|
-
|
|
53
|
-
# Transfer NIGHT
|
|
54
69
|
midnight transfer mn_addr_undeployed1... 100
|
|
55
70
|
```
|
|
56
71
|
|
|
@@ -59,6 +74,41 @@ midnight transfer mn_addr_undeployed1... 100
|
|
|
59
74
|
| Network | Description |
|
|
60
75
|
|---------|-------------|
|
|
61
76
|
| `undeployed` | Local network via Docker (`midnight localnet up`) |
|
|
77
|
+
| `preprod` | Midnight pre-production testnet |
|
|
78
|
+
| `preview` | Midnight preview testnet |
|
|
79
|
+
|
|
80
|
+
Wallets are network-agnostic — one seed derives addresses for all three networks. Use `--network <name>` on any command, or persist it with `midnight config set network preview`.
|
|
81
|
+
|
|
82
|
+
## DApp Connector
|
|
83
|
+
|
|
84
|
+
`midnight serve` starts a WebSocket JSON-RPC server that implements the same `ConnectedAPI` interface as the Lace browser wallet. Any DApp can connect to it — no browser extension needed.
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
# Start the connector server
|
|
88
|
+
midnight serve --network preview
|
|
89
|
+
|
|
90
|
+
# Or auto-approve all requests (dev only)
|
|
91
|
+
midnight serve --network preview --approve-all
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
To connect from your DApp, install the connector package:
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
npm install midnight-wallet-connector
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
```typescript
|
|
101
|
+
import { createWalletClient } from 'midnight-wallet-connector';
|
|
102
|
+
|
|
103
|
+
const wallet = await createWalletClient({
|
|
104
|
+
url: 'ws://localhost:9932',
|
|
105
|
+
networkId: 'Preview',
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
const balances = await wallet.getUnshieldedBalances();
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
See the [midnight-wallet-connector](https://www.npmjs.com/package/midnight-wallet-connector) package for the full API, and [midnight-starship](https://github.com/nel349/midnight-starship) for a working example DApp.
|
|
62
112
|
|
|
63
113
|
## JSON Output for Automation
|
|
64
114
|
|
|
@@ -158,11 +208,16 @@ Add to `~/.codeium/windsurf/mcp_config.json`:
|
|
|
158
208
|
|
|
159
209
|
### Available MCP Tools
|
|
160
210
|
|
|
161
|
-
Once connected, your AI agent gets access to
|
|
211
|
+
Once connected, your AI agent gets access to 22 tools:
|
|
162
212
|
|
|
163
213
|
| Tool | Description |
|
|
164
214
|
|------|-------------|
|
|
165
|
-
| `
|
|
215
|
+
| `midnight_wallet_generate` | Create a named wallet |
|
|
216
|
+
| `midnight_wallet_list` | List all wallets |
|
|
217
|
+
| `midnight_wallet_use` | Set active wallet |
|
|
218
|
+
| `midnight_wallet_info` | Show wallet details |
|
|
219
|
+
| `midnight_wallet_remove` | Remove a wallet |
|
|
220
|
+
| `midnight_generate` | Generate a wallet (deprecated) |
|
|
166
221
|
| `midnight_info` | Show wallet info (no secrets) |
|
|
167
222
|
| `midnight_balance` | Check NIGHT balance |
|
|
168
223
|
| `midnight_address` | Derive address from seed |
|
|
@@ -190,4 +245,4 @@ For documentation, guides, and more: [midnight-wallet-cli-hub](https://github.co
|
|
|
190
245
|
|
|
191
246
|
- Node.js >= 20
|
|
192
247
|
- Docker (for `midnight localnet` commands)
|
|
193
|
-
- A running proof server on `localhost:6300` (for transactions on
|
|
248
|
+
- A running proof server on `localhost:6300` (for transactions — required on all networks)
|