midnight-wallet-cli 0.5.1 → 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 +40 -19
- package/dist/mcp-server.js +678 -674
- package/dist/wallet.js +843 -808
- package/docs/SKILL-CORE.md +45 -0
- package/docs/SKILL.md +21 -11
- package/package.json +17 -20
package/README.md
CHANGED
|
@@ -8,14 +8,20 @@
|
|
|
8
8
|
[](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
|
|
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 (
|
|
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
|
|
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,24 +105,37 @@ midnight transfer mn_addr_preprod1... 100
|
|
|
97
105
|
|
|
98
106
|
| Network | Description |
|
|
99
107
|
|---------|-------------|
|
|
100
|
-
| `undeployed` | Local network
|
|
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
|
|
|
114
|
+
## Native dust acceleration
|
|
115
|
+
|
|
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>`).
|
|
117
|
+
|
|
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.
|
|
119
|
+
|
|
106
120
|
## DApp Connector
|
|
107
121
|
|
|
108
122
|
`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.
|
|
109
123
|
|
|
110
124
|
```bash
|
|
111
125
|
# Start the connector server
|
|
112
|
-
midnight serve
|
|
126
|
+
midnight serve
|
|
113
127
|
|
|
114
128
|
# Or auto-approve all requests (dev only)
|
|
115
|
-
midnight serve --
|
|
129
|
+
midnight serve --approve-all
|
|
130
|
+
|
|
131
|
+
# Or act as a fee wallet for an agent (see below)
|
|
132
|
+
midnight serve --approve-fees
|
|
116
133
|
```
|
|
117
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
|
+
|
|
118
139
|
To connect from your DApp, install the connector package:
|
|
119
140
|
|
|
120
141
|
```bash
|
|
@@ -126,7 +147,7 @@ import { createWalletClient } from 'midnight-wallet-connector';
|
|
|
126
147
|
|
|
127
148
|
const wallet = await createWalletClient({
|
|
128
149
|
url: 'ws://localhost:9932',
|
|
129
|
-
networkId: '
|
|
150
|
+
networkId: 'undeployed',
|
|
130
151
|
});
|
|
131
152
|
|
|
132
153
|
const balances = await wallet.getUnshieldedBalances();
|
|
@@ -228,7 +249,7 @@ Add to `~/.codeium/windsurf/mcp_config.json`:
|
|
|
228
249
|
}
|
|
229
250
|
```
|
|
230
251
|
|
|
231
|
-
> **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).
|
|
232
253
|
|
|
233
254
|
### Available MCP Tools
|
|
234
255
|
|
|
@@ -255,7 +276,7 @@ Once connected, your AI agent gets access to 30 tools:
|
|
|
255
276
|
| `midnight_config_set` | Write config value |
|
|
256
277
|
| `midnight_config_unset` | Remove config value |
|
|
257
278
|
| `midnight_cache_clear` | Clear wallet state cache |
|
|
258
|
-
| `midnight_localnet_up` | Start local network |
|
|
279
|
+
| `midnight_localnet_up` | Start local network (refused on this ledger-9 build) |
|
|
259
280
|
| `midnight_localnet_stop` | Stop local network |
|
|
260
281
|
| `midnight_localnet_down` | Remove local network |
|
|
261
282
|
| `midnight_localnet_status` | Show service status |
|
|
@@ -300,8 +321,8 @@ Found a bug or have a feature request? [Open an issue](https://github.com/nel349
|
|
|
300
321
|
## Requirements
|
|
301
322
|
|
|
302
323
|
- Node.js >= 20
|
|
303
|
-
- Docker (for `midnight localnet` commands)
|
|
304
|
-
- A
|
|
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
|
|
305
326
|
|
|
306
327
|
## Development
|
|
307
328
|
|