⚠️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 - JSON-RPC Method

Description

Fetches the SCALE-encoded value stored at a specific storage key. Combine this method with metadata and hashing helpers to access low-level data such as account balances, fuel tank configurations, or NFT records on Enjin Matrix.

Parameters

ParameterTypeRequiredDescription
storageKeystringYesFull storage key (module prefix + storage hasher output)
blockHashstring | nullNoBlock hash for historical reads

Returns

FieldTypeDescription
resultstring | nullSCALE-encoded storage value, or null if the key does not exist

Building Keys Example (System.Account)

import hashlib

SS58_ADDRESS = 'efS1ZdvCHHviX7qnTGZEZQX9Uz3qpibG9L5RpF9niM8ne5RBn'
MODULE_PREFIX = '26aa394eea5630e07c48ae0c9558cef7' # twox128("System")
STORAGE_PREFIX = '02a5c1b19ab7a04f536c519aca4983ac' # twox128("Account")

# Decode SS58 to AccountId
account_id = decode_ss58(SS58_ADDRESS) # 32 bytes

# Blake2_128Concat hasher = blake2_128(account_id) ++ account_id
hash_part = hashlib.blake2b(account_id, digest_size=16).digest()

storage_key = '0x' + MODULE_PREFIX + STORAGE_PREFIX + hash_part.hex() + account_id.hex()

Pass storage_key to state_getStorage to retrieve the raw account info. Decode the result with SCALE codecs (AccountInfo structure) to obtain balances and nonce. For convenience, the high-level RPC query.system.account already performs these steps:

{
"account": {
"nonce": "1",
"data": {
"free": "249,999,994,815,222,109,223,128",
"reserved": "0",
"frozen": "0",
"flags": "170,141,183,460,469,231,731,687,303,715,884,105,728"
}
}
}

Direct RPC Request Example

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

The sample key corresponds to System.Account for the zeroed account ID (twox128("System") ++ twox128("Account")). The result contains the SCALE-encoded AccountInfo; decode it with Polkadot.js (api.rpc.state.getStorage) or scalecodec to inspect nonce/balance fields.

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

cURL Skeleton

curl https://api-enjin-matrixchain.n.dwellir.com/YOUR_API_KEY \
-X POST \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "state_getStorage",
"params": ["0x26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac", null],
"id": 1
}'

Tips

  • Use state_getStorageHash and state_getStorageSize for lightweight change detection before fetching full values.
  • Always consult runtime metadata to confirm the hasher used for a storage item (e.g., Blake2_128Concat, Twox64Concat).
  • For large scans, pair with state_getKeysPaged and rate-limit requests to avoid exhausting RPC quotas.