⚠️Blast API (blastapi.io) ends Oct 31. Migrate to Dwellir and skip Alchemy's expensive compute units.
Switch Today →
Skip to main content

state_getStorage

Description

Retrieves a storage value from the Moonriver state at a given key. Storage keys are constructed from pallet name, storage item name, and optional parameters. The returned value is SCALE-encoded and needs to be decoded according to the storage item's type.

Parameters

ParameterTypeRequiredDescription
storageKeystringYesHex-encoded storage key
blockHashstringNoBlock hash to query state at. If omitted, uses latest block

Returns

FieldTypeDescription
resultstringHex-encoded SCALE-encoded storage value, or null if not exists

Request Example

{
"jsonrpc": "2.0",
"method": "state_getStorage",
"params": [
"0x26aa394eea5630e07c48ae0c9558cef7b99d880ec681799c0cf30e8886371da9"
],
"id": 1
}

Response Example

{
"jsonrpc": "2.0",
"result": "0x0000000000000000000000000000000000000000000000000000000000000000",
"id": 1
}

Storage Key Construction

Storage keys follow the pattern:

twox128(pallet_name) + twox128(storage_item_name) + hasher(key_params)

Common Storage Keys

StorageKey PrefixDescription
System.Account0x26aa394eea5630e07c48ae0c9558cef7Account information
Balances.TotalIssuance0xc2261276cc9d1f8598ea4b6a74b15c2fTotal token supply
Staking.Validators0x5f3e4907f716ac89b6347d15ececedcaValidator preferences
Staking.Nominators0x5f3e4907f716ac89b6347d15ececedcaNominator information

Code Examples

from substrateinterface import SubstrateInterface
import json

# Using substrate-interface for easier key construction
substrate = SubstrateInterface(
url="https://api-moonriver.n.dwellir.com/YOUR_API_KEY",
extra_headers={"Authorization": "Bearer YOUR_API_KEY"}
)

# Query account info
def get_account_info(address):
result = substrate.query(
module='System',
storage_function='Account',
params=[address]
)

return {
'nonce': result['nonce'],
'free': result['data']['free'],
'reserved': result['data']['reserved']
}

# Direct RPC call
def get_storage_raw(storage_key):
url = "https://api-moonriver.n.dwellir.com/YOUR_API_KEY"
headers = {
"Content-Type": "application/json"
}

payload = {
"jsonrpc": "2.0",
"method": "state_getStorage",
"params": [storage_key],
"id": 1
}

response = requests.post(url, headers=headers, data=json.dumps(payload))
return response.json()["result"]

Common Storage Queries

Account Balance

// Storage key for System.Account
const key = '0x26aa394eea5630e07c48ae0c9558cef7b99d880ec681799c0cf30e8886371da9' +
// Add account address hash
accountHash;

Total Issuance

// Storage key for Balances.TotalIssuance
const key = '0xc2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80';

Validator Count

// Storage key for Staking.ValidatorCount
const key = '0x5f3e4907f716ac89b6347d15ececedca9e6291df5932f5f9e8b539b69d9bc699';

Notes

  • Storage values are SCALE-encoded and require proper decoding
  • Use high-level APIs when possible for automatic encoding/decoding
  • Storage keys can be complex for map-type storage items
  • Null result indicates the storage item doesn't exist