@towns-labs/wallet 7.0.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 +446 -0
- package/dist/cli.js +20844 -0
- package/package.json +44 -0
package/README.md
ADDED
|
@@ -0,0 +1,446 @@
|
|
|
1
|
+
# towns wallet-cli
|
|
2
|
+
|
|
3
|
+
CLI for `tw` account onboarding, session key lifecycle, and relayed transactions.
|
|
4
|
+
|
|
5
|
+
Built on [incur](https://github.com/wevm/incur) — every command supports `--help`, `--json`, `--format`, and can run as an MCP server via `--mcp`.
|
|
6
|
+
|
|
7
|
+
## Run with bunx
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
bunx @towns-labs/wallet --help
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Permissionless
|
|
14
|
+
|
|
15
|
+
`tw` is fully permissionless: no signup, no account registration, and no login flow. You can run it immediately with local keys.
|
|
16
|
+
|
|
17
|
+
## Output Modes
|
|
18
|
+
|
|
19
|
+
incur handles output formatting automatically:
|
|
20
|
+
|
|
21
|
+
- `--json` — structured JSON output
|
|
22
|
+
- `--format table` — tabular output
|
|
23
|
+
- Default: human-readable text
|
|
24
|
+
|
|
25
|
+
## Help and Discovery
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
# Show all commands
|
|
29
|
+
tw --help
|
|
30
|
+
|
|
31
|
+
# Show help for a specific command
|
|
32
|
+
tw account create --help
|
|
33
|
+
|
|
34
|
+
# Machine-readable command manifest (for LLMs/agents)
|
|
35
|
+
tw --llms
|
|
36
|
+
|
|
37
|
+
# Run as an MCP server
|
|
38
|
+
tw --mcp
|
|
39
|
+
|
|
40
|
+
# Version
|
|
41
|
+
tw --version
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Account Create
|
|
45
|
+
|
|
46
|
+
Create a new account (interactive password prompt):
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
tw account create
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Create a named profile in local dev:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
tw account create --env dev --profile agent
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Keystore layout:
|
|
59
|
+
|
|
60
|
+
```text
|
|
61
|
+
~/.config/towns/tw/profiles/<env>/<profile>/default.keystore.json
|
|
62
|
+
~/.config/towns/tw/profiles/<env>/<profile>/sessions/<session-name>.json
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Resume a previously created profile:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
tw account create --resume --env dev --profile agent
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Non-interactive mode (stdin password + JSON output):
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
echo "my-password" | tw account create --password-stdin --json
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Use an explicit keystore path:
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
tw account create --keystore-path ~/.config/towns/tw/profiles/dev/team/default.keystore.json --env dev
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Account Export
|
|
84
|
+
|
|
85
|
+
Export metadata only (safe default):
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
tw account export --env dev --profile agent
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Export metadata in JSON:
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
tw account export --env dev --profile agent --json
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Export decrypted private keys (interactive confirmation required):
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
tw account export --env dev --profile agent --show-private
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## Account Address
|
|
104
|
+
|
|
105
|
+
Print the main/root account address:
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
tw account address --env dev --profile agent
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## Address (Root Alias)
|
|
112
|
+
|
|
113
|
+
`tw address` is a root alias for `tw account address` with optional funding display helpers.
|
|
114
|
+
|
|
115
|
+
Print address + default funding context (USDC on Base):
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
tw address
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
Show a funding payment link:
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
tw address --link --amount 100
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Show a QR for the same payment payload:
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
tw address --qr --amount 100
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
Custom token amount requires explicit decimals:
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
tw address --token 0x1111111111111111111111111111111111111111 --amount 1 --decimals 18 --link
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
## Account Balance
|
|
140
|
+
|
|
141
|
+
Check USDC balance for the main/root account on Base (default):
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
tw account balance --env dev --profile agent
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
Check USDC balance on Polygon:
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
tw account balance --env prod --profile agent --chain polygon
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
For local dev (`--env dev`), default chain is Anvil (`http://127.0.0.1:8545`).
|
|
154
|
+
|
|
155
|
+
## Account Send
|
|
156
|
+
|
|
157
|
+
Send USDC to an address:
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
tw account send 1 0x1111111111111111111111111111111111111111
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
Send USDC to ENS on Base:
|
|
164
|
+
|
|
165
|
+
```bash
|
|
166
|
+
tw account send 2.5 vitalik.eth --chain base
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
Send USDC on Polygon with JSON output:
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
tw account send 10 0x1111111111111111111111111111111111111111 --chain polygon --env prod --json
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
Local dev defaults to Anvil:
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
tw account send 1 0x1111111111111111111111111111111111111111 --env dev
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
## Contacts
|
|
182
|
+
|
|
183
|
+
Store aliases in a global contacts file:
|
|
184
|
+
|
|
185
|
+
```text
|
|
186
|
+
~/.config/towns/tw/contacts.json
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
Add contact aliases:
|
|
190
|
+
|
|
191
|
+
```bash
|
|
192
|
+
tw contacts add vitalik vitalik.eth
|
|
193
|
+
tw contacts add treasury 0x1111111111111111111111111111111111111111
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
List or show contacts:
|
|
197
|
+
|
|
198
|
+
```bash
|
|
199
|
+
tw contacts list --json
|
|
200
|
+
tw contacts show vitalik --json
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
Update, rename, and remove:
|
|
204
|
+
|
|
205
|
+
```bash
|
|
206
|
+
tw contacts update vitalik 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045
|
|
207
|
+
tw contacts rename vitalik vitalik-main
|
|
208
|
+
tw contacts remove vitalik-main
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
Export and import:
|
|
212
|
+
|
|
213
|
+
```bash
|
|
214
|
+
tw contacts export --json
|
|
215
|
+
tw contacts import ./contacts.json --json
|
|
216
|
+
tw contacts import ./contacts.json --force --json
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
Import returns deterministic summary fields:
|
|
220
|
+
|
|
221
|
+
- `importedCount`
|
|
222
|
+
- `skippedInvalidCount`
|
|
223
|
+
- `skippedConflictCount`
|
|
224
|
+
- `overwrittenCount`
|
|
225
|
+
|
|
226
|
+
Send via alias:
|
|
227
|
+
|
|
228
|
+
```bash
|
|
229
|
+
tw account send 10 vitalik
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
ENS safety behavior for ENS-backed contacts:
|
|
233
|
+
|
|
234
|
+
- If ENS re-resolution fails, `tw account send` falls back to the stored address.
|
|
235
|
+
- If ENS re-resolution succeeds but points to a different address than stored, send aborts and requires explicit `tw contacts update`.
|
|
236
|
+
|
|
237
|
+
Send with a portable session file (no root keystore required):
|
|
238
|
+
|
|
239
|
+
```bash
|
|
240
|
+
tw account send 1 0x1111111111111111111111111111111111111111 \
|
|
241
|
+
--env prod --chain base --session-file ./worker-1.session.json
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
## Account Status
|
|
245
|
+
|
|
246
|
+
Show compact readiness status:
|
|
247
|
+
|
|
248
|
+
```bash
|
|
249
|
+
tw account status --env dev --profile agent
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
JSON output for automation:
|
|
253
|
+
|
|
254
|
+
```bash
|
|
255
|
+
tw account status --env prod --profile agent --chain polygon --json
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
## Account Update Password
|
|
259
|
+
|
|
260
|
+
Rotate local keystore encryption password (interactive):
|
|
261
|
+
|
|
262
|
+
```bash
|
|
263
|
+
tw account update password --env dev --profile agent
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
Rotate password non-interactively using stdin lines:
|
|
267
|
+
|
|
268
|
+
```bash
|
|
269
|
+
printf "old-password\nnew-password\n" | tw account update password --current-password-stdin --new-password-stdin --json
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
## Session Create
|
|
273
|
+
|
|
274
|
+
Create and authorize a scoped session key in one intent:
|
|
275
|
+
|
|
276
|
+
```bash
|
|
277
|
+
echo "my-password" | tw session create worker-1 --profile agent --password-stdin --json
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
Create and activate immediately:
|
|
281
|
+
|
|
282
|
+
```bash
|
|
283
|
+
echo "my-password" | tw session create worker-2 --profile agent --activate --password-stdin
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
Resume a previously interrupted create flow:
|
|
287
|
+
|
|
288
|
+
```bash
|
|
289
|
+
echo "my-password" | tw session create worker-1 --profile agent --resume --password-stdin --json
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
Grant full wildcard access (explicit opt-in):
|
|
293
|
+
|
|
294
|
+
```bash
|
|
295
|
+
echo "my-password" | tw session create worker-admin --profile agent --full-access --password-stdin
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
## Session List
|
|
299
|
+
|
|
300
|
+
List local sessions:
|
|
301
|
+
|
|
302
|
+
```bash
|
|
303
|
+
tw session list --profile agent --json
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
Include on-chain key status:
|
|
307
|
+
|
|
308
|
+
```bash
|
|
309
|
+
tw session list --profile agent --on-chain --json
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
## Session Export
|
|
313
|
+
|
|
314
|
+
Export a session key as a portable file:
|
|
315
|
+
|
|
316
|
+
```bash
|
|
317
|
+
TW_PASSWORD="my-password" TW_EXPORT_PASSWORD="export-password" \
|
|
318
|
+
tw session export worker-1 --profile agent --output ./worker-1.session.json
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
Or provide the export password via stdin:
|
|
322
|
+
|
|
323
|
+
```bash
|
|
324
|
+
echo "export-password" | tw session export worker-1 --profile agent \
|
|
325
|
+
--output ./worker-1.session.json --export-password-stdin
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
## Session Import
|
|
329
|
+
|
|
330
|
+
Import a portable session as a session-only profile:
|
|
331
|
+
|
|
332
|
+
```bash
|
|
333
|
+
tw session import ./worker-1.session.json --profile worker-1
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
This creates:
|
|
337
|
+
|
|
338
|
+
```bash
|
|
339
|
+
~/.config/towns/tw/profiles/worker-1/session.json
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
Session-only profiles can execute `account send` but cannot run manager commands that require a root keystore.
|
|
343
|
+
|
|
344
|
+
## Session Rotate
|
|
345
|
+
|
|
346
|
+
Rotate the active session (auto-generates new name):
|
|
347
|
+
|
|
348
|
+
```bash
|
|
349
|
+
echo "my-password" | tw session rotate --profile agent --password-stdin --json
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
Rotate to an explicit new session name:
|
|
353
|
+
|
|
354
|
+
```bash
|
|
355
|
+
echo "my-password" | tw session rotate --profile agent --new-name worker-3 --password-stdin
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
Resume interrupted rotation:
|
|
359
|
+
|
|
360
|
+
```bash
|
|
361
|
+
echo "my-password" | tw session rotate --profile agent --resume --password-stdin --json
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
## Session Revoke
|
|
365
|
+
|
|
366
|
+
Revoke a non-active session on-chain, verify, then delete local file:
|
|
367
|
+
|
|
368
|
+
```bash
|
|
369
|
+
echo "my-password" | tw session revoke worker-1 --profile agent --password-stdin --json
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
Force revoke active session:
|
|
373
|
+
|
|
374
|
+
```bash
|
|
375
|
+
echo "my-password" | tw session revoke worker-2 --profile agent --force --password-stdin
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
Idempotent retry/cleanup when already revoked on-chain:
|
|
379
|
+
|
|
380
|
+
```bash
|
|
381
|
+
echo "my-password" | tw session revoke worker-2 --profile agent --resume --password-stdin --json
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
## Permissions List
|
|
385
|
+
|
|
386
|
+
List all on-chain keys with summarized call/spend permissions:
|
|
387
|
+
|
|
388
|
+
```bash
|
|
389
|
+
tw permissions list --profile agent --json
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
## Permissions Show
|
|
393
|
+
|
|
394
|
+
Show full permission rules for a key using positional `<key-ref>`:
|
|
395
|
+
|
|
396
|
+
```bash
|
|
397
|
+
tw permissions show agent-key --profile agent --json
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
Explicit selectors are also supported:
|
|
401
|
+
|
|
402
|
+
```bash
|
|
403
|
+
tw permissions show --key-hash 0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa --profile agent --json
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
## Permissions Grant
|
|
407
|
+
|
|
408
|
+
Grant wildcard call permission:
|
|
409
|
+
|
|
410
|
+
```bash
|
|
411
|
+
echo "my-password" | tw permissions grant agent-key --type call --target any --selector any --profile agent --password-stdin --json
|
|
412
|
+
```
|
|
413
|
+
|
|
414
|
+
Grant spend permission for daily USDC limit:
|
|
415
|
+
|
|
416
|
+
```bash
|
|
417
|
+
echo "my-password" | tw permissions grant agent-key --type spend --token USDC --spend-limit 100 --period day --profile agent --password-stdin --json
|
|
418
|
+
```
|
|
419
|
+
|
|
420
|
+
## Permissions Revoke
|
|
421
|
+
|
|
422
|
+
Revoke one rule by stable rule id:
|
|
423
|
+
|
|
424
|
+
```bash
|
|
425
|
+
echo "my-password" | tw permissions revoke agent-key --rule call:0x2222222222222222222222222222222222222222:0xa9059cbb --profile agent --password-stdin --json
|
|
426
|
+
```
|
|
427
|
+
|
|
428
|
+
Revoke all call/spend rules for a key:
|
|
429
|
+
|
|
430
|
+
```bash
|
|
431
|
+
echo "my-password" | tw permissions revoke agent-key --all --profile agent --password-stdin --json
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
## Password Automation
|
|
435
|
+
|
|
436
|
+
Use `TW_PASSWORD` for non-interactive flows:
|
|
437
|
+
|
|
438
|
+
```bash
|
|
439
|
+
TW_PASSWORD="my-password" tw session list --profile agent --json
|
|
440
|
+
```
|
|
441
|
+
|
|
442
|
+
Stdin is supported for commands requiring keystore decryption/signing:
|
|
443
|
+
|
|
444
|
+
```bash
|
|
445
|
+
echo "my-password" | tw session rotate --profile agent --password-stdin --json
|
|
446
|
+
```
|