@towns-labs/wallet 7.0.0 → 7.2.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 +204 -19
- package/dist/cli.js +419 -353
- package/package.json +8 -3
package/README.md
CHANGED
|
@@ -49,10 +49,10 @@ Create a new account (interactive password prompt):
|
|
|
49
49
|
tw account create
|
|
50
50
|
```
|
|
51
51
|
|
|
52
|
-
Create a named profile
|
|
52
|
+
Create a named profile:
|
|
53
53
|
|
|
54
54
|
```bash
|
|
55
|
-
tw account create --
|
|
55
|
+
tw account create --profile agent
|
|
56
56
|
```
|
|
57
57
|
|
|
58
58
|
Keystore layout:
|
|
@@ -65,7 +65,7 @@ Keystore layout:
|
|
|
65
65
|
Resume a previously created profile:
|
|
66
66
|
|
|
67
67
|
```bash
|
|
68
|
-
tw account create --resume --
|
|
68
|
+
tw account create --resume --profile agent
|
|
69
69
|
```
|
|
70
70
|
|
|
71
71
|
Non-interactive mode (stdin password + JSON output):
|
|
@@ -77,7 +77,7 @@ echo "my-password" | tw account create --password-stdin --json
|
|
|
77
77
|
Use an explicit keystore path:
|
|
78
78
|
|
|
79
79
|
```bash
|
|
80
|
-
tw account create --keystore-path ~/.config/towns/tw/profiles/
|
|
80
|
+
tw account create --keystore-path ~/.config/towns/tw/profiles/prod/team/default.keystore.json
|
|
81
81
|
```
|
|
82
82
|
|
|
83
83
|
## Account Export
|
|
@@ -85,19 +85,19 @@ tw account create --keystore-path ~/.config/towns/tw/profiles/dev/team/default.k
|
|
|
85
85
|
Export metadata only (safe default):
|
|
86
86
|
|
|
87
87
|
```bash
|
|
88
|
-
tw account export --
|
|
88
|
+
tw account export --profile agent
|
|
89
89
|
```
|
|
90
90
|
|
|
91
91
|
Export metadata in JSON:
|
|
92
92
|
|
|
93
93
|
```bash
|
|
94
|
-
tw account export --
|
|
94
|
+
tw account export --profile agent --json
|
|
95
95
|
```
|
|
96
96
|
|
|
97
97
|
Export decrypted private keys (interactive confirmation required):
|
|
98
98
|
|
|
99
99
|
```bash
|
|
100
|
-
tw account export --
|
|
100
|
+
tw account export --profile agent --show-private
|
|
101
101
|
```
|
|
102
102
|
|
|
103
103
|
## Account Address
|
|
@@ -105,7 +105,7 @@ tw account export --env dev --profile agent --show-private
|
|
|
105
105
|
Print the main/root account address:
|
|
106
106
|
|
|
107
107
|
```bash
|
|
108
|
-
tw account address --
|
|
108
|
+
tw account address --profile agent
|
|
109
109
|
```
|
|
110
110
|
|
|
111
111
|
## Address (Root Alias)
|
|
@@ -141,17 +141,15 @@ tw address --token 0x1111111111111111111111111111111111111111 --amount 1 --decim
|
|
|
141
141
|
Check USDC balance for the main/root account on Base (default):
|
|
142
142
|
|
|
143
143
|
```bash
|
|
144
|
-
tw account balance --
|
|
144
|
+
tw account balance --profile agent
|
|
145
145
|
```
|
|
146
146
|
|
|
147
147
|
Check USDC balance on Polygon:
|
|
148
148
|
|
|
149
149
|
```bash
|
|
150
|
-
tw account balance --
|
|
150
|
+
tw account balance --profile agent --chain polygon
|
|
151
151
|
```
|
|
152
152
|
|
|
153
|
-
For local dev (`--env dev`), default chain is Anvil (`http://127.0.0.1:8545`).
|
|
154
|
-
|
|
155
153
|
## Account Send
|
|
156
154
|
|
|
157
155
|
Send USDC to an address:
|
|
@@ -169,15 +167,42 @@ tw account send 2.5 vitalik.eth --chain base
|
|
|
169
167
|
Send USDC on Polygon with JSON output:
|
|
170
168
|
|
|
171
169
|
```bash
|
|
172
|
-
tw account send 10 0x1111111111111111111111111111111111111111 --chain polygon --
|
|
170
|
+
tw account send 10 0x1111111111111111111111111111111111111111 --chain polygon --json
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
Send using a specific local session by name (without changing active session):
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
tw account send 1 0x1111111111111111111111111111111111111111 --profile agent --session worker-2
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
## Account History
|
|
180
|
+
|
|
181
|
+
Get paginated relayer call history for an EOA. By default this uses your local profile root EOA from keystore:
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
tw account history --profile agent
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
Query an explicit EOA (without reading local keystore):
|
|
188
|
+
|
|
189
|
+
```bash
|
|
190
|
+
tw account history --address 0x1111111111111111111111111111111111111111 --limit 10 --offset 20
|
|
173
191
|
```
|
|
174
192
|
|
|
175
|
-
|
|
193
|
+
Filter by one or more chains:
|
|
176
194
|
|
|
177
195
|
```bash
|
|
178
|
-
tw account
|
|
196
|
+
tw account history --chain base,polygon --json
|
|
179
197
|
```
|
|
180
198
|
|
|
199
|
+
Notes:
|
|
200
|
+
|
|
201
|
+
- `--limit` defaults to `20` and max is `100`
|
|
202
|
+
- `--offset` defaults to `0`
|
|
203
|
+
- `offset + limit` must be `<= 1000`
|
|
204
|
+
- History queries are EOA-based (root EOA), not delegated account address
|
|
205
|
+
|
|
181
206
|
## Contacts
|
|
182
207
|
|
|
183
208
|
Store aliases in a global contacts file:
|
|
@@ -238,21 +263,23 @@ Send with a portable session file (no root keystore required):
|
|
|
238
263
|
|
|
239
264
|
```bash
|
|
240
265
|
tw account send 1 0x1111111111111111111111111111111111111111 \
|
|
241
|
-
--
|
|
266
|
+
--chain base --session-file ./worker-1.session.json
|
|
242
267
|
```
|
|
243
268
|
|
|
269
|
+
`--session` and `--session-file` are mutually exclusive.
|
|
270
|
+
|
|
244
271
|
## Account Status
|
|
245
272
|
|
|
246
273
|
Show compact readiness status:
|
|
247
274
|
|
|
248
275
|
```bash
|
|
249
|
-
tw account status --
|
|
276
|
+
tw account status --profile agent
|
|
250
277
|
```
|
|
251
278
|
|
|
252
279
|
JSON output for automation:
|
|
253
280
|
|
|
254
281
|
```bash
|
|
255
|
-
tw account status --
|
|
282
|
+
tw account status --profile agent --chain polygon --json
|
|
256
283
|
```
|
|
257
284
|
|
|
258
285
|
## Account Update Password
|
|
@@ -260,7 +287,7 @@ tw account status --env prod --profile agent --chain polygon --json
|
|
|
260
287
|
Rotate local keystore encryption password (interactive):
|
|
261
288
|
|
|
262
289
|
```bash
|
|
263
|
-
tw account update password --
|
|
290
|
+
tw account update password --profile agent
|
|
264
291
|
```
|
|
265
292
|
|
|
266
293
|
Rotate password non-interactively using stdin lines:
|
|
@@ -295,6 +322,10 @@ Grant full wildcard access (explicit opt-in):
|
|
|
295
322
|
echo "my-password" | tw session create worker-admin --profile agent --full-access --password-stdin
|
|
296
323
|
```
|
|
297
324
|
|
|
325
|
+
`--full-access` is mutually exclusive with `--target`, `--selector`, `--spend-limit`, `--spend-limit-raw`, and `--spend-period`.
|
|
326
|
+
Omitting both `--target` and `--selector` uses wildcard call permissions by default; you do not need to pass magic wildcard values.
|
|
327
|
+
`--spend-limit` accepts human USDC amounts (for example `10` = `10 USDC`). Use `--spend-limit-raw` for base units.
|
|
328
|
+
|
|
298
329
|
## Session List
|
|
299
330
|
|
|
300
331
|
List local sessions:
|
|
@@ -355,6 +386,10 @@ Rotate to an explicit new session name:
|
|
|
355
386
|
echo "my-password" | tw session rotate --profile agent --new-name worker-3 --password-stdin
|
|
356
387
|
```
|
|
357
388
|
|
|
389
|
+
`--full-access` is mutually exclusive with `--target`, `--selector`, `--spend-limit`, `--spend-limit-raw`, and `--spend-period`.
|
|
390
|
+
Omitting both `--target` and `--selector` uses wildcard call permissions by default; you do not need to pass magic wildcard values.
|
|
391
|
+
`--spend-limit` accepts human USDC amounts (for example `10` = `10 USDC`). Use `--spend-limit-raw` for base units.
|
|
392
|
+
|
|
358
393
|
Resume interrupted rotation:
|
|
359
394
|
|
|
360
395
|
```bash
|
|
@@ -381,6 +416,150 @@ Idempotent retry/cleanup when already revoked on-chain:
|
|
|
381
416
|
echo "my-password" | tw session revoke worker-2 --profile agent --resume --password-stdin --json
|
|
382
417
|
```
|
|
383
418
|
|
|
419
|
+
## Agent Commands
|
|
420
|
+
|
|
421
|
+
Agents are session-key-backed Towns identities with their own encryption device and named channel bindings.
|
|
422
|
+
|
|
423
|
+
Agent keystore files live alongside normal sessions:
|
|
424
|
+
|
|
425
|
+
```text
|
|
426
|
+
~/.config/towns/tw/profiles/<env>/<profile>/sessions/agent-<name>.json
|
|
427
|
+
~/.config/towns/tw/profiles/<env>/<profile>/agent-channels.json
|
|
428
|
+
```
|
|
429
|
+
|
|
430
|
+
Create two local agents:
|
|
431
|
+
|
|
432
|
+
```bash
|
|
433
|
+
TW_PASSWORD="my-password" tw agent create alice --profile agent
|
|
434
|
+
TW_PASSWORD="my-password" tw agent create bob --profile agent
|
|
435
|
+
```
|
|
436
|
+
|
|
437
|
+
List local agents:
|
|
438
|
+
|
|
439
|
+
```bash
|
|
440
|
+
TW_PASSWORD="my-password" tw agent list --profile agent --json
|
|
441
|
+
```
|
|
442
|
+
|
|
443
|
+
Create or bind a named channel:
|
|
444
|
+
|
|
445
|
+
```bash
|
|
446
|
+
TW_PASSWORD="my-password" tw agent connect --from alice --channel art --to bob --profile agent
|
|
447
|
+
```
|
|
448
|
+
|
|
449
|
+
The first `connect` returns:
|
|
450
|
+
|
|
451
|
+
- `streamId` — the underlying GDM stream
|
|
452
|
+
- `secret` — the shared rendezvous secret, returned only when the binding is first created
|
|
453
|
+
|
|
454
|
+
Bind the same named channel from the other side:
|
|
455
|
+
|
|
456
|
+
```bash
|
|
457
|
+
TW_PASSWORD="my-password" tw agent connect --from bob --channel art --secret "<shared-secret>" --to alice --profile agent
|
|
458
|
+
```
|
|
459
|
+
|
|
460
|
+
Send to a named channel:
|
|
461
|
+
|
|
462
|
+
```bash
|
|
463
|
+
TW_PASSWORD="my-password" tw agent send --from alice --channel art "hello from alice" --profile agent
|
|
464
|
+
```
|
|
465
|
+
|
|
466
|
+
Send directly to a raw stream ID:
|
|
467
|
+
|
|
468
|
+
```bash
|
|
469
|
+
TW_PASSWORD="my-password" tw agent send --from alice 77aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa "debug message" --profile agent
|
|
470
|
+
```
|
|
471
|
+
|
|
472
|
+
Listen on a named channel:
|
|
473
|
+
|
|
474
|
+
```bash
|
|
475
|
+
TW_PASSWORD="my-password" tw agent listen --from bob --channel art --profile agent
|
|
476
|
+
```
|
|
477
|
+
|
|
478
|
+
Listen on a specific stream:
|
|
479
|
+
|
|
480
|
+
```bash
|
|
481
|
+
TW_PASSWORD="my-password" tw agent listen --from bob --stream 77aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa --profile agent
|
|
482
|
+
```
|
|
483
|
+
|
|
484
|
+
Inspect local named bindings:
|
|
485
|
+
|
|
486
|
+
```bash
|
|
487
|
+
TW_PASSWORD="my-password" tw agent channels --from alice --profile agent --json
|
|
488
|
+
```
|
|
489
|
+
|
|
490
|
+
Remove an agent:
|
|
491
|
+
|
|
492
|
+
```bash
|
|
493
|
+
TW_PASSWORD="my-password" tw agent remove bob --profile agent
|
|
494
|
+
```
|
|
495
|
+
|
|
496
|
+
## Agent Quickstart
|
|
497
|
+
|
|
498
|
+
This is the shortest end-to-end flow to start a conversation between two local agents.
|
|
499
|
+
|
|
500
|
+
1. Create or reuse a wallet profile:
|
|
501
|
+
|
|
502
|
+
```bash
|
|
503
|
+
tw account create --profile agent
|
|
504
|
+
```
|
|
505
|
+
|
|
506
|
+
2. Create two agents:
|
|
507
|
+
|
|
508
|
+
```bash
|
|
509
|
+
TW_PASSWORD="my-password" tw agent create alice --profile agent
|
|
510
|
+
TW_PASSWORD="my-password" tw agent create bob --profile agent
|
|
511
|
+
```
|
|
512
|
+
|
|
513
|
+
3. Create a named channel and copy the returned `secret` and `streamId`:
|
|
514
|
+
|
|
515
|
+
```bash
|
|
516
|
+
TW_PASSWORD="my-password" tw agent connect --from alice --channel art --to bob --profile agent
|
|
517
|
+
```
|
|
518
|
+
|
|
519
|
+
4. Bind the same channel from Bob using that secret:
|
|
520
|
+
|
|
521
|
+
```bash
|
|
522
|
+
TW_PASSWORD="my-password" tw agent connect --from bob --channel art --secret "<shared-secret>" --to alice --profile agent
|
|
523
|
+
```
|
|
524
|
+
|
|
525
|
+
5. Start a listener in one terminal:
|
|
526
|
+
|
|
527
|
+
```bash
|
|
528
|
+
TW_PASSWORD="my-password" tw agent listen --from bob --channel art --profile agent
|
|
529
|
+
```
|
|
530
|
+
|
|
531
|
+
6. Send from another terminal:
|
|
532
|
+
|
|
533
|
+
```bash
|
|
534
|
+
TW_PASSWORD="my-password" tw agent send --from alice --channel art "hello from alice" --profile agent
|
|
535
|
+
```
|
|
536
|
+
|
|
537
|
+
7. Bob's listener prints NDJSON when the message arrives:
|
|
538
|
+
|
|
539
|
+
```json
|
|
540
|
+
{
|
|
541
|
+
"type": "message",
|
|
542
|
+
"streamId": "77...",
|
|
543
|
+
"senderId": "0x...",
|
|
544
|
+
"eventId": "0x...",
|
|
545
|
+
"timestamp": 1709654400,
|
|
546
|
+
"content": "hello from alice"
|
|
547
|
+
}
|
|
548
|
+
```
|
|
549
|
+
|
|
550
|
+
8. Inspect the local binding if you need the underlying stream:
|
|
551
|
+
|
|
552
|
+
```bash
|
|
553
|
+
TW_PASSWORD="my-password" tw agent channels --from alice --profile agent
|
|
554
|
+
```
|
|
555
|
+
|
|
556
|
+
For a single-command live verification, run the built-in smoke script:
|
|
557
|
+
|
|
558
|
+
```bash
|
|
559
|
+
cd packages/wallet
|
|
560
|
+
TW_PASSWORD="my-password" bun run smoke:agent
|
|
561
|
+
```
|
|
562
|
+
|
|
384
563
|
## Permissions List
|
|
385
564
|
|
|
386
565
|
List all on-chain keys with summarized call/spend permissions:
|
|
@@ -417,6 +596,12 @@ Grant spend permission for daily USDC limit:
|
|
|
417
596
|
echo "my-password" | tw permissions grant agent-key --type spend --token USDC --spend-limit 100 --period day --profile agent --password-stdin --json
|
|
418
597
|
```
|
|
419
598
|
|
|
599
|
+
For raw base units instead of human USDC amounts, use:
|
|
600
|
+
|
|
601
|
+
```bash
|
|
602
|
+
echo "my-password" | tw permissions grant agent-key --type spend --token USDC --spend-limit-raw 100000000 --period day --profile agent --password-stdin --json
|
|
603
|
+
```
|
|
604
|
+
|
|
420
605
|
## Permissions Revoke
|
|
421
606
|
|
|
422
607
|
Revoke one rule by stable rule id:
|