state_getStorage
Description
Returns the SCALE-encoded value stored under a given storage key. Combine with metadata to decode results into structured data.
Parameters
Position | Type | Description |
---|---|---|
0 | string | Storage key in hex (e.g., 0x26aa… for System.Account ) |
1 (optional) | string | Block hash to query |
Request Example
This sample queries System.Account
for ZEyDXf6563rc78ibEtYQAkHTSKLzMES1m2BrPNdLcma57Tg
.
{
"jsonrpc": "2.0",
"method": "state_getStorage",
"params": [
"0x26aa394eea5630e07c48ae0c9558cef7b99d880ec681799c0cf30e8886371da9e3a5c81a65b0e6ba8e72e48e58704482922ee694ea772dc63a575845fa57a0c5ea93dfdc2a93ec631d9e426962f1e311"
],
"id": 42
}
Response Example
{
"jsonrpc": "2.0",
"id": 42,
"result": "0x0000000001000000010000000000000032b41eb5b90885078a550301000000000000000000000000000000000000000000000081da1cc2709a1dba000000000000000000000000000000000000000080"
}
Decode the result with the AccountInfo
type to access fields such as data.free
and data.reserved
.
Code Examples
JavaScript (polkadot.js)
const api = await ApiPromise.create({ provider: new WsProvider('wss://api-astar.n.dwellir.com/YOUR_API_KEY') });
const account = await api.query.system.account('ZEyDXf6563rc78ibEtYQAkHTSKLzMES1m2BrPNdLcma57Tg');
console.log(account.data.free.toString());
Rust (subxt)
use subxt::ext::sp_runtime::AccountId32;
let api = OnlineClient::<SubstrateConfig>::from_url("wss://api-astar.n.dwellir.com/YOUR_API_KEY").await?;
let account_id: AccountId32 = "ZEyDXf6563rc78ibEtYQAkHTSKLzMES1m2BrPNdLcma57Tg".parse()?;
let storage = api.storage().system().account(&account_id, None).await?;
println!("Free balance {}", storage.data.free);
Python (py-substrate-interface)
substrate = SubstrateInterface(url="wss://api-astar.n.dwellir.com/YOUR_API_KEY", ss58_format=5)
account_info = substrate.query('System', 'Account', params=['ZEyDXf6563rc78ibEtYQAkHTSKLzMES1m2BrPNdLcma57Tg'])
print(account_info.value['data'])