midnight-wallet-cli 0.5.2 → 0.6.0-rc.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/README.md CHANGED
@@ -8,14 +8,20 @@
8
8
  [![TypeScript](https://img.shields.io/badge/TypeScript-5.9-blue?logo=typescript)](https://www.typescriptlang.org/)
9
9
 
10
10
 
11
- A standalone CLI wallet for the Midnight blockchain. Manage wallets, check balances, transfer NIGHT tokens, and run a local network — all from the terminal.
11
+ A standalone CLI wallet for the Midnight blockchain. Manage wallets, check balances, transfer NIGHT tokens, and manage a local network — all from the terminal.
12
12
 
13
- Built for two audiences: **beginners** starting their first Midnight project (localnet + funded wallets + contract deploy in under 5 minutes), and **AI agents** (Cursor, Claude Code, any MCP client) using the same primitives via a built-in MCP server.
13
+ Built for two audiences: **beginners** starting their first Midnight project (a local chain + funded wallets + contract deploy in minutes), and **AI agents** (Cursor, Claude Code, any MCP client) using the same primitives via a built-in MCP server.
14
+
15
+ > [!IMPORTANT]
16
+ > **0.6.0-rc.0 is a ledger-9-only prerelease.** It is built on wallet-sdk 2.0.0-rc.0, ledger-v9 1.0.0-rc.5, midnight-js 5.0.0-rc.1 and compact-runtime 0.20.0 (contracts compiled with Compact 0.35 / language 0.27). It refuses any chain still on ledger 8, which today includes `preview` and `preprod`: stay on 0.5.x (`npm install -g midnight-wallet-cli@latest`) for those.
17
+ >
18
+ > `midnight localnet up` is refused on this build, because no published indexer image runs ledger 9 yet. Run a ledger-9 stack yourself (node 2.1.0-rc.2, proof-server 9.0.0-rc.8, a 4.4 indexer) and point mn at it. On the default ports (node 9944, indexer 8088, proof server 6300) `--network undeployed` reaches it with no configuration. On other ports pass `--node`, `--indexer-ws` and `--proof-server` per command, or save them once with `midnight config set node <url>`, `midnight config set indexer-ws <url>` and `midnight config set proof-server <url>`.
14
19
 
15
20
  ## Install
16
21
 
17
22
  ```bash
18
- npm install -g midnight-wallet-cli
23
+ npm install -g midnight-wallet-cli # stable 0.5.x (ledger 8)
24
+ npm install -g midnight-wallet-cli@next # this ledger-9 prerelease
19
25
  ```
20
26
 
21
27
  This installs two commands: `midnight` (or `mn` for short) and `midnight-wallet-mcp`.
@@ -35,20 +41,20 @@ This installs two commands: `midnight` (or `mn` for short) and `midnight-wallet-
35
41
  | `midnight airdrop <amount>` | Fund a wallet or raw address from genesis (`--shielded` for shielded, undeployed only) |
36
42
  | `midnight dust register` | Register NIGHT UTXOs for dust (fee token) generation |
37
43
  | `midnight dust status` | Check dust registration status and balance |
38
- | `midnight dust export` | Emit a restorable dust snapshot for fast warm-restore |
44
+ | `midnight dust export` | Emit a restorable dust snapshot for fast warm-restore (ledger-9 snapshot on this build) |
39
45
  | `midnight address --seed <hex>` | Derive an address from a seed |
40
46
  | `midnight genesis-address` | Show the genesis wallet address |
41
47
  | `midnight inspect-cost` | Display current block cost limits |
42
- | `midnight serve` | Start DApp Connector server (WebSocket JSON-RPC) |
48
+ | `midnight serve` | Start DApp Connector server (WebSocket JSON-RPC); `--approve-fees` runs it as a fee wallet for an agent |
43
49
  | `midnight contract inspect` | Show circuits, witnesses, and types for a compiled contract |
44
50
  | `midnight contract deploy` | Deploy a contract to the network (`--secret-key <64-hex>` seeds a caller-chosen initial private-state secret for constructors that derive their owner from `public_key(secret_key())`; passed via env to the deploy subprocess, never written to disk) |
45
51
  | `midnight contract call` | Call a circuit on a deployed contract |
46
52
  | `midnight contract state` | Read ledger state of a deployed contract |
47
- | `midnight dev` | Contract dev loop — watcher auto-compiles on save; `[t]` runs tests, `[d]` deploys |
53
+ | `midnight dev` | Contract dev loop — watcher auto-compiles on save; `[t]` runs tests, `[d]` deploys (on this build it uses a ledger-9 stack you run, at the configured endpoints) |
48
54
  | `midnight test create/run/list/results` | Generate and run E2E tests for Midnight dApps |
49
55
  | `midnight config get/set/unset` | Manage persistent config (network, wallet, endpoints) |
50
56
  | `midnight cache clear` | Clear wallet state cache |
51
- | `midnight localnet up/stop/down/status/logs/clean` | Manage a local Midnight network via Docker |
57
+ | `midnight localnet up/stop/down/status/logs/clean` | Manage a local Midnight network via Docker (`up` is refused on this ledger-9 build) |
52
58
  | `midnight help [command]` | Show usage for all or a specific command |
53
59
  | `midnight manual` | Full reference manual (every command, every flag) |
54
60
 
@@ -57,8 +63,8 @@ This installs two commands: `midnight` (or `mn` for short) and `midnight-wallet-
57
63
  ### Local development (undeployed)
58
64
 
59
65
  ```bash
60
- # 1. Start local network (node, indexer, proof server)
61
- midnight localnet up
66
+ # 1. Start a ledger-9 node, indexer and proof server yourself (see the note at the top).
67
+ # `midnight localnet up` is refused on this build.
62
68
 
63
69
  # 2. Create a wallet and set the network
64
70
  midnight wallet generate alice
@@ -75,6 +81,8 @@ midnight transfer mn_addr_undeployed1... 100
75
81
 
76
82
  ### Preprod / Preview (testnet)
77
83
 
84
+ Both run ledger 8 today, so this build refuses them; use 0.5.x there. Once a network moves to ledger 9 the flow is:
85
+
78
86
  ```bash
79
87
  # 1. Create a wallet and set the network
80
88
  midnight wallet generate alice
@@ -97,20 +105,17 @@ midnight transfer mn_addr_preprod1... 100
97
105
 
98
106
  | Network | Description |
99
107
  |---------|-------------|
100
- | `undeployed` | Local network via Docker (`midnight localnet up`) |
101
- | `preprod` | Midnight pre-production testnet |
102
- | `preview` | Midnight preview testnet |
108
+ | `undeployed` | Local network. On this build: a ledger-9 stack you run yourself (`midnight localnet up` is refused) |
109
+ | `preprod` | Midnight pre-production testnet (ledger 8 today: refused by this build, use 0.5.x) |
110
+ | `preview` | Midnight preview testnet (ledger 8 today: refused by this build, use 0.5.x) |
103
111
 
104
112
  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`.
105
113
 
106
114
  ## Native dust acceleration
107
115
 
108
- The first dust sync for a wallet on a hosted network (`preprod`/`preview`) replays the chain's full dust event history — the slow part of a cold start. The CLI bundles a native (Rust) accelerator that does this ~5× faster than the WASM fallback: a ~1.45M-event preprod prime drops from ~22 min to ~4.5 min.
109
-
110
- It installs automatically — a per-platform `optionalDependency` (`@nel349/dust-sync-<os>-<arch>`) for macOS (arm64/x64), Linux (x64/arm64), and Windows (x64). No configuration, no install scripts. On any other platform the CLI falls back to the WASM reader, so dust priming still works, just slower.
116
+ The first dust sync for a wallet on a hosted network replays the chain's full dust event history, the slow part of a cold start. On 0.5.x a native (Rust) accelerator does this about 5× faster than the WASM reader (a ~1.45M-event preprod prime drops from ~22 min to ~4.5 min), installed as a per-platform `optionalDependency` (`@nel349/dust-sync-<os>-<arch>`).
111
117
 
112
- - `MN_DISABLE_NATIVE_DUST=1` — force the WASM path (to compare, or if a binary misbehaves).
113
- - `MN_DUST_SYNC_BIN=/path/to/dust-sync` — use your own build instead of the installed binary.
118
+ **Not on this ledger-9 build.** The accelerator is built against ledger 8, so this prerelease does not ship it (no `@nel349/dust-sync-*` dependencies) and never runs it: dust sync always uses the WASM reader, and `MN_DUST_SYNC_BIN` and `MN_DISABLE_NATIVE_DUST` are ignored.
114
119
 
115
120
  ## DApp Connector
116
121
 
@@ -118,12 +123,19 @@ It installs automatically — a per-platform `optionalDependency` (`@nel349/dust
118
123
 
119
124
  ```bash
120
125
  # Start the connector server
121
- midnight serve --network preview
126
+ midnight serve
122
127
 
123
128
  # Or auto-approve all requests (dev only)
124
- midnight serve --network preview --approve-all
129
+ midnight serve --approve-all
130
+
131
+ # Or act as a fee wallet for an agent (see below)
132
+ midnight serve --approve-fees
125
133
  ```
126
134
 
135
+ Read methods never prompt. Every write prompts in the terminal (and is rejected without one), balancing included: `balanceUnsealedTransaction` / `balanceSealedTransaction` reserve the wallet's coins, sign, and return a finished transaction the dApp could submit through any node itself.
136
+
137
+ `--approve-fees` is for an agent that builds and proves its own ledger-9 transaction (its own value already balanced) and only needs the Dust fee paid. `balanceUnsealedTransaction` / `balanceSealedTransaction` then add only Dust, and are auto-approved only when the transaction spends none of this wallet's funds, has no unsigned unshielded input, needs no non-Dust value and is not a rewards claim; otherwise they are refused, listing every reason. `submitTransaction` is auto-approved only for a transaction this server balanced that way on the same connection. Everything else still prompts in the terminal (and is rejected without one). It cannot be combined with `--approve-all`. Two limits bound what an agent can cost the wallet: `--max-fee <DUST>` refuses a transaction whose total Dust fee (the agent's transaction plus the wallet's balancing) is higher (default 10 DUST; a simple contract call costs about 0.5), and `--max-pending <n>` refuses new balances while n balanced transactions wait to be submitted (default 2). Both are checked before any Dust is reserved. Each balanced transaction reserves a whole Dust coin until it is submitted and on chain (about 20 seconds on a 6-second-block localnet) or released, so a fee wallet serves as many agents at once as it has Dust coins: one per NIGHT UTXO registered for Dust generation. A request that finds none free waits for one, then fails with an error saying so. With `--json`, the line `mn serve` prints once it is listening includes the approval policy (`"approval": {"reads": "auto", "balancing": "fee-only", "writes": "fee-only", "feeLimits": {"maxFeeSpecks": "10000000000000000", "maxPending": 2}}`), so whoever started it can check what it will approve.
138
+
127
139
  To connect from your DApp, install the connector package:
128
140
 
129
141
  ```bash
@@ -135,7 +147,7 @@ import { createWalletClient } from 'midnight-wallet-connector';
135
147
 
136
148
  const wallet = await createWalletClient({
137
149
  url: 'ws://localhost:9932',
138
- networkId: 'Preview',
150
+ networkId: 'undeployed',
139
151
  });
140
152
 
141
153
  const balances = await wallet.getUnshieldedBalances();
@@ -237,7 +249,7 @@ Add to `~/.codeium/windsurf/mcp_config.json`:
237
249
  }
238
250
  ```
239
251
 
240
- > **Tip:** If you haven't installed globally, use `"command": "npx"` with `"args": ["-y", "midnight-wallet-cli@latest", "--mcp"]` instead.
252
+ > **Tip:** If you haven't installed globally, use `"command": "npx"` with `"args": ["-y", "midnight-wallet-cli@latest", "--mcp"]` instead (`midnight-wallet-cli@next` for this ledger-9 prerelease).
241
253
 
242
254
  ### Available MCP Tools
243
255
 
@@ -264,7 +276,7 @@ Once connected, your AI agent gets access to 30 tools:
264
276
  | `midnight_config_set` | Write config value |
265
277
  | `midnight_config_unset` | Remove config value |
266
278
  | `midnight_cache_clear` | Clear wallet state cache |
267
- | `midnight_localnet_up` | Start local network |
279
+ | `midnight_localnet_up` | Start local network (refused on this ledger-9 build) |
268
280
  | `midnight_localnet_stop` | Stop local network |
269
281
  | `midnight_localnet_down` | Remove local network |
270
282
  | `midnight_localnet_status` | Show service status |
@@ -309,8 +321,8 @@ Found a bug or have a feature request? [Open an issue](https://github.com/nel349
309
321
  ## Requirements
310
322
 
311
323
  - Node.js >= 20
312
- - Docker (for `midnight localnet` commands)
313
- - A running proof server on `localhost:6300` (for transactions — required on all networks)
324
+ - Docker (for `midnight localnet` commands; `up` is refused on this build)
325
+ - A ledger-9 chain to talk to: node, indexer (4.4) and proof server. The proof server defaults to `localhost:6300` and is required for transactions on every network
314
326
 
315
327
  ## Development
316
328