paritytech / paritytech/polkadot-cli
feat: add --at flag to query state at a specific block
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 10
- Forks
- 2
- Avg merge
- 12h 35m
- Merged PRs (30d)
- 4
Description
Problem
Users cannot query historical state at a specific block height or hash. All queries return the latest state only, making it impossible to investigate past conditions or verify state at a particular point in time.
Related
- #58
Proposed Solution
Add an --at flag to the query command accepting either a block number or block hash.
Implementation
polkadot-api's getValue() and getEntries() already accept { at: blockHash } via PullOptions. This is minimal implementation effort:
// Resolve --at to a block hash
let at: string | undefined
if (options.at) {
if (/^0x[0-9a-fA-F]{64}$/.test(options.at)) {
at = options.at // Already a hash
} else {
// Numeric block number — resolve to hash
at = await client.chain_getBlockHash(Number(options.at))
}
}
const value = await storage.getValue(...keys, { at })
UX
# Query by block number
polkadot query System.Account <addr> --at 12345678
# Query by block hash
polkadot query System.Account <addr> --at 0xabc123...
# Combine with other flags
polkadot query Staking.Validators --at 12345678 --output json
Priority
HIGH — low effort, high value for debugging and historical analysis.
Files
src/commands/query.ts
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/query.ts and trace how query options reach the storage calls. Check the existing command entry point and polkadot-api PullOptions usage, then verify that --at accepts a block number or hash and works with the documented query examples and output flag.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- cli
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100