Skip to main content

state_getKeys - JSON-RPC Method

Description#

Returns a list of storage keys that share a given prefix. This method is helpful when you need to discover child keys beneath a map, such as iterating through all system accounts or fuel tank records in Enjin Matrix.

Parameters#

ParameterTypeRequiredDescription
prefixstringYesHex-encoded storage prefix (typically twox128(module) + hasher(storage))
blockHashstring | nullNoBlock hash for historical queries; null uses the best block

Returns#

An array of hex-encoded storage keys matching the supplied prefix.

Request Example#

{
"jsonrpc": "2.0",
"method": "state_getKeys",
"params": [
"0x26aa394eea5630e07c48ae0c9558cef7",
null
],
"id": 1
}

Response Example (truncated)#

{
"jsonrpc": "2.0",
"result": [
"0x26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac",
"0x26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850",
"0x26aa394eea5630e07c48ae0c9558cef734abf5cb34d6244378cddbf18e849d96",
"…"
],
"id": 1
}

Code Examples#

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

Tips#

  • Use state_getKeysPaged for large datasets; it adds pagination controls to avoid heavy responses.
  • Combine with state_getStorage to fetch the associated values for each discovered key.
  • Remember that map storage keys append hashes and encoded keys (e.g., Blake2_128Concat(AccountId)), so you may need to post-process the suffix.