I'm having trouble retrieving the historic balances on Kusama. On Polkadot the exact same code works, so I'm not sure where the issue lies.
/* Kusama address, api init above */
const query_addr = "GyGN5AZe886p5mk6YMmXyksz683LYTLgzdzWRzTK29oLbru"
/* get the current free balance */
const { data: { free: free_now } } = await api.query.system.account(query_addr)
console.log(" now", free_now.toString())
/* init historic */
const block_hash = await api.rpc.chain.getBlockHash(1337)
const api_at = await api.at(block_hash)
/* get the historic balance */
const { data: { free: free_then } } = await api_at.query.system.account(query_addr)
console.log("then", free_then.toString())
/* get the difference */
console.log("diff", free_now.sub(free_then).toString())
The above code yields api_at.query.system.account is not a function
. Additionally when I log Object.keys(api_at.system.account)
I cannot see the account
entry either, so I'm assuming at that point of the runtime it was stored elsewhere.
How can I make the above query work on older blocks?