state_getStorage
Returns a storage entry at a specific key on Asset Hub.
Why Asset Hub? Build on Polkadot's system parachain managing $4.5B+ in DOT tokens, native USDC/USDT, and NFTs with 50-90% lower fees than Relay Chain, fee payment in any supported asset, 1.5M+ accounts migrated, and trustless Ethereum bridge access.
Use Cases#
- State queries - Read on-chain storage values
- Account balances - Query account data for native stablecoin transfers (USDC, USDT), DOT staking and governance, and cross-chain asset management via XCM
- Pallet storage - Access runtime storage items
- Historical state - Query state at specific blocks
Parameters#
| Parameter | Type | Required | Description |
|---|---|---|---|
key | String | Yes | Storage key (hex-encoded) |
blockHash | String | No | Block hash for historical query |
Request#
{
"jsonrpc": "2.0",
"method": "state_getStorage",
"params": [""],
"id": 1
}
Code Examples#
- cURL
- JavaScript
- Python
curl https://api-asset-hub-polkadot.n.dwellir.com/<YOUR_API_KEY>/YOUR_API_KEY \
-X POST \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "state_getStorage",
"params": [""],
"id": 1
}'
import { ApiPromise, WsProvider } from '@polkadot/api';
const provider = new WsProvider('wss://api-asset-hub-polkadot.n.dwellir.com/YOUR_API_KEY');
const api = await ApiPromise.create({ provider });
// Query account balance
const account = '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY';
const accountInfo = await api.query.system.account(account);
console.log('Free balance:', accountInfo.data.free.toString());
// Query at specific block
const blockHash = '0x91b171bb158e2d3848fa23a9f1c25182fb8e20313b2c1eb49219da7a70ce90c3';
const historicalBalance = await api.query.system.account.at(blockHash, account);
console.log('Historical balance:', historicalBalance.data.free.toString());
await api.disconnect();
import requests
def get_storage(key, block_hash=None):
url = 'https://api-asset-hub-polkadot.n.dwellir.com/<YOUR_API_KEY>/YOUR_API_KEY'
params = [key] if block_hash is None else [key, block_hash]
payload = {
'jsonrpc': '2.0',
'method': 'state_getStorage',
'params': params,
'id': 1
}
response = requests.post(url, json=payload)
return response.json()['result']
# Query :code storage (runtime wasm)
storage_key = ''
value = get_storage(storage_key)
print(f'Storage value: {value[:66]}...' if value else 'None')
Related Methods#
state_getMetadata- Get runtime metadatastate_getKeysPaged- Enumerate storage keys