⚠️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 Moonbase Alpha 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

Quick Examples


# Read runtime :code (Wasm) at latest
curl -X POST https://api-moonbase-alpha.n.dwellir.com/YOUR_API_KEY -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","id":1,"method":"state_getStorage","params":["0x3a636f6465"]}'

# Read the same key at a specific block
curl -X POST https://api-moonbase-alpha.n.dwellir.com/YOUR_API_KEY -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","id":1,"method":"state_getStorage","params":["0x3a636f6465","0x9d44ea4103132b9ab5addc69bfe96065e0b0d58c44591b9f72bf448ca3877549"]}'

Storage Key Construction

Storage keys follow the pattern:

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

Common Storage Keys

StorageKey PrefixDescription
System.Accounttwox128("System") + twox128("Account")Account information
:code0x3a636f6465Runtime Wasm blob

For Account maps, the key suffix uses blake2_128_concat(accountId) where accountId is 20 bytes on Moonbase Alpha.

Notes

  • Responses are SCALE-encoded; prefer high-level SDKs to decode types correctly.
  • Use state_getKeysPaged to enumerate keys for large prefixes efficiently.
  • Historical queries require a block hash; prefer finalized hashes for consistency.