midnight-wallet-cli 0.1.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 +187 -0
- package/dist/mcp-server.js +2693 -0
- package/dist/wallet.js +3557 -0
- package/package.json +46 -0
package/README.md
ADDED
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
# midnight-wallet-cli
|
|
2
|
+
|
|
3
|
+
A standalone CLI wallet for the Midnight blockchain. Manage wallets, check balances, transfer NIGHT tokens, and run a local devnet — all from the terminal.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g midnight-wallet-cli
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
This installs three commands: `midnight` (or `mn` for short) and `midnight-wallet-mcp`.
|
|
12
|
+
|
|
13
|
+
## Commands
|
|
14
|
+
|
|
15
|
+
| Command | Description |
|
|
16
|
+
|---------|-------------|
|
|
17
|
+
| `midnight generate` | Generate a new wallet or restore from seed/mnemonic |
|
|
18
|
+
| `midnight info` | Display wallet address, network, creation date |
|
|
19
|
+
| `midnight balance [address]` | Check unshielded NIGHT balance |
|
|
20
|
+
| `midnight transfer <to> <amount>` | Send NIGHT tokens to another address |
|
|
21
|
+
| `midnight airdrop <amount>` | Fund wallet from genesis (local devnet only) |
|
|
22
|
+
| `midnight dust register` | Register NIGHT UTXOs for dust (fee token) generation |
|
|
23
|
+
| `midnight dust status` | Check dust registration status and balance |
|
|
24
|
+
| `midnight address --seed <hex>` | Derive an address from a seed |
|
|
25
|
+
| `midnight genesis-address` | Show the genesis wallet address |
|
|
26
|
+
| `midnight inspect-cost` | Display current block cost limits |
|
|
27
|
+
| `midnight config get/set` | Manage persistent config (default network, etc.) |
|
|
28
|
+
| `midnight localnet up/stop/down/status` | Manage a local Midnight network via Docker |
|
|
29
|
+
| `midnight help [command]` | Show usage for all or a specific command |
|
|
30
|
+
|
|
31
|
+
## Quick Start
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
# Generate a wallet
|
|
35
|
+
midnight generate --network preprod
|
|
36
|
+
|
|
37
|
+
# Check balance
|
|
38
|
+
midnight balance
|
|
39
|
+
|
|
40
|
+
# Transfer NIGHT
|
|
41
|
+
midnight transfer mn_addr_preprod1... 100
|
|
42
|
+
|
|
43
|
+
# Local devnet: start network, airdrop, register dust
|
|
44
|
+
midnight localnet up
|
|
45
|
+
midnight generate --network undeployed
|
|
46
|
+
midnight airdrop 1000
|
|
47
|
+
midnight dust register
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Supported Networks
|
|
51
|
+
|
|
52
|
+
| Network | Description |
|
|
53
|
+
|---------|-------------|
|
|
54
|
+
| `preprod` | Midnight pre-production testnet |
|
|
55
|
+
| `preview` | Midnight preview testnet |
|
|
56
|
+
| `undeployed` | Local devnet via Docker (`midnight localnet up`) |
|
|
57
|
+
|
|
58
|
+
## JSON Output for Automation
|
|
59
|
+
|
|
60
|
+
Every command supports `--json` for structured output:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
midnight balance --json
|
|
64
|
+
# → {"address":"mn_addr_...","network":"undeployed","balances":{"NIGHT":"504.850000"},"utxoCount":2,"txCount":8}
|
|
65
|
+
|
|
66
|
+
midnight transfer mn_addr_... 100 --json
|
|
67
|
+
# → {"txHash":"00ab...","amount":100,"recipient":"mn_addr_...","network":"undeployed"}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
When `--json` is active:
|
|
71
|
+
- stdout receives a single line of JSON
|
|
72
|
+
- stderr is fully suppressed (no spinners, no formatting)
|
|
73
|
+
- Errors produce: `{"error":true,"code":"...","message":"...","exitCode":N}`
|
|
74
|
+
|
|
75
|
+
Run `midnight help --json` for a full capability manifest, or `midnight help --agent` for a comprehensive AI agent reference.
|
|
76
|
+
|
|
77
|
+
## MCP Server for AI Agents
|
|
78
|
+
|
|
79
|
+
The package includes an MCP (Model Context Protocol) server that exposes all wallet operations as typed tools. AI agents call them directly via JSON-RPC over stdio — no shell spawning or output parsing needed.
|
|
80
|
+
|
|
81
|
+
### Claude Code
|
|
82
|
+
|
|
83
|
+
Create `.mcp.json` in your project root:
|
|
84
|
+
|
|
85
|
+
```json
|
|
86
|
+
{
|
|
87
|
+
"mcpServers": {
|
|
88
|
+
"midnight-wallet": {
|
|
89
|
+
"command": "npx",
|
|
90
|
+
"args": ["-y", "midnight-wallet-cli@latest", "--mcp"]
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Claude Desktop
|
|
97
|
+
|
|
98
|
+
Add to `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS) or `%APPDATA%\Claude\claude_desktop_config.json` (Windows):
|
|
99
|
+
|
|
100
|
+
```json
|
|
101
|
+
{
|
|
102
|
+
"mcpServers": {
|
|
103
|
+
"midnight-wallet": {
|
|
104
|
+
"command": "npx",
|
|
105
|
+
"args": ["-y", "midnight-wallet-cli@latest", "--mcp"]
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Cursor
|
|
112
|
+
|
|
113
|
+
Create `.cursor/mcp.json` in your project root:
|
|
114
|
+
|
|
115
|
+
```json
|
|
116
|
+
{
|
|
117
|
+
"mcpServers": {
|
|
118
|
+
"midnight-wallet": {
|
|
119
|
+
"command": "npx",
|
|
120
|
+
"args": ["-y", "midnight-wallet-cli@latest", "--mcp"]
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### VS Code (GitHub Copilot)
|
|
127
|
+
|
|
128
|
+
Create `.vscode/mcp.json` in your project root:
|
|
129
|
+
|
|
130
|
+
```json
|
|
131
|
+
{
|
|
132
|
+
"servers": {
|
|
133
|
+
"midnight-wallet": {
|
|
134
|
+
"type": "stdio",
|
|
135
|
+
"command": "npx",
|
|
136
|
+
"args": ["-y", "midnight-wallet-cli@latest", "--mcp"]
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### Windsurf
|
|
143
|
+
|
|
144
|
+
Add to `~/.codeium/windsurf/mcp_config.json`:
|
|
145
|
+
|
|
146
|
+
```json
|
|
147
|
+
{
|
|
148
|
+
"mcpServers": {
|
|
149
|
+
"midnight-wallet": {
|
|
150
|
+
"command": "npx",
|
|
151
|
+
"args": ["-y", "midnight-wallet-cli@latest", "--mcp"]
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
> **Tip:** If you installed globally (`npm install -g midnight-wallet-cli`), you can use `"command": "midnight-wallet-mcp"` instead of the `npx` form.
|
|
158
|
+
|
|
159
|
+
### Available MCP Tools
|
|
160
|
+
|
|
161
|
+
Once connected, your AI agent gets access to 17 tools:
|
|
162
|
+
|
|
163
|
+
| Tool | Description |
|
|
164
|
+
|------|-------------|
|
|
165
|
+
| `midnight_generate` | Generate or restore a wallet |
|
|
166
|
+
| `midnight_info` | Show wallet info (no secrets) |
|
|
167
|
+
| `midnight_balance` | Check NIGHT balance |
|
|
168
|
+
| `midnight_address` | Derive address from seed |
|
|
169
|
+
| `midnight_genesis_address` | Show genesis wallet address |
|
|
170
|
+
| `midnight_inspect_cost` | Show block cost limits |
|
|
171
|
+
| `midnight_airdrop` | Fund wallet from genesis |
|
|
172
|
+
| `midnight_transfer` | Send NIGHT tokens |
|
|
173
|
+
| `midnight_dust_register` | Register UTXOs for dust generation |
|
|
174
|
+
| `midnight_dust_status` | Check dust status |
|
|
175
|
+
| `midnight_config_get` | Read config value |
|
|
176
|
+
| `midnight_config_set` | Write config value |
|
|
177
|
+
| `midnight_localnet_up` | Start local network |
|
|
178
|
+
| `midnight_localnet_stop` | Stop local network |
|
|
179
|
+
| `midnight_localnet_down` | Remove local network |
|
|
180
|
+
| `midnight_localnet_status` | Show service status |
|
|
181
|
+
| `midnight_localnet_clean` | Remove conflicting containers |
|
|
182
|
+
|
|
183
|
+
## Requirements
|
|
184
|
+
|
|
185
|
+
- Node.js >= 20
|
|
186
|
+
- Docker (for `midnight localnet` commands)
|
|
187
|
+
- A running proof server on `localhost:6300` (for transactions on local devnet)
|