state_getStorage - Midnight

Example code for the state_getStorage JSON-RPC method. Complete guide on how to use state_getStorage JSON-RPC in GetBlock Web3 documentation.

This method returns the value associated with a specific storage key in the current best block. For historical queries, use state_getStorageAt.

Parameters

Parameter
Type
Required
Description

key

string

Yes

Hex-encoded storage key

hash

string

No

Block hash to query at. Defaults to the current best block

Request Example

curl --location --request POST 'https://go.getblock.io/<ACCESS-TOKEN>/' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "state_getStorage",
    "params": [
        "0x26aa394eea5630e07c48ae0c9558cef7b99d880ec681799c0cf30e8886371da9"
    ],
    "id": "getblock.io"
}'

Response Example

Response Parameters

Field
Type
Description

result

string | null

Hex-encoded storage value, or null if the key is unset

Use Cases

  • Reading runtime storage by raw key

  • Implementing typed accessors in SDKs

  • Direct queries for tools that already have the typed metadata

Error Handling

Status Code
Error Message
Cause

403

Forbidden

Missing or invalid <ACCESS-TOKEN>

-32602

Invalid params

Request parameters are missing or malformed

429

Too Many Requests

Rate limit exceeded for your plan

SDK Integration

Last updated

Was this helpful?