paritytech / paritytech/polkadot-cli
feat: add `dot watch` command for real-time block, storage, and event streaming
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 10
- Forks
- 2
- Avg merge
- 12h 35m
- Merged PRs (30d)
- 4
Description
Parent Epic: #63
Summary
Add a watch command that streams real-time chain data as NDJSON, enabling agents to monitor blocks, storage changes, and events.
Usage
dot watch blocks --output json
dot watch storage System.Account 5FHn... --output json
dot watch events --output json
dot watch events Balances.Transfer --output json
Output (NDJSON)
Blocks:
{"blockNumber":12345,"blockHash":"0x...","parentHash":"0x...","extrinsicsCount":5}
{"blockNumber":12346,"blockHash":"0x...","parentHash":"0x...","extrinsicsCount":3}
Storage:
{"blockNumber":12345,"value":{"nonce":42,"data":{"free":"1000000000000"}}}
{"blockNumber":12350,"value":{"nonce":43,"data":{"free":"999000000000"}}}
Events:
{"blockNumber":12345,"pallet":"Balances","event":"Transfer","fields":{"from":"...","to":"...","amount":"1000"}}
Implementation
- Use polkadot-api's
client.finalizedBlock$for block streaming (same RxJS pattern aswatchTransactionin tx.ts) - Use polkadot-api's
watchValuefor storage subscriptions - Emit NDJSON lines using
printJsonLine()from output.ts - Support
Ctrl+Cgraceful shutdown
Files
src/commands/watch.ts— NEW command withblocks,storage,eventssubcommandssrc/cli.ts— register new command
Verification
- Stream blocks for 30 seconds, verify each line is valid JSON
- Watch a storage value, trigger a change via tx, verify the update appears
- Filter events by pallet, verify only matching events are emitted
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/commands/tx.ts at the watchTransaction RxJS pattern, then inspect src/output.ts for printJsonLine() and src/cli.ts for command registration. Implement the blocks, storage, and events subcommands in src/commands/watch.ts using finalizedBlock$ and watchValue, and verify valid NDJSON, storage updates, event filtering, and graceful Ctrl+C shutdown.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- cli
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100