Distinguish a default Substrate account value from a stored record
A metadata-aware query can decode an absent ValueQuery entry to its default structure. For a migration audit, that can obscure whether the raw account key exists at all.
Derive the exact storage key
On a runtime exposing System.Account, set address to the account under inspection and run this polkadot-js code. Send the printed JSON to the chain’s HTTP RPC. Keeping the key and block hash together makes a raw lookup reproducible.
const hash = await api.rpc.chain.getFinalizedHead()
const at = await api.at(hash)
const key = at.query.system.account.key(address)
const body = {
jsonrpc: "2.0", id: 1, method: "state_getStorage",
params: [key.toString(), hash.toHex()]
}
console.log(JSON.stringify(body))
Preserve absence in the migration output
A successful raw result of null means the storage key is absent at that state. A hex byte string means bytes are present and need decoding according to the account type. An object containing zero balance fields from a high-level query alone cannot establish that distinction.
Record an RPC error for pruned historical state separately. Missing state for the entire block and absence of one key in an available state require different remediation.