For AI agents: an LLM-friendly Markdown version of every page is available by appending .md to its URL or by sending an Accept: text/markdown request header. The full documentation index is at https://www.ankr.com/docs/llms.txt
Skip to main content

Midnight — childstate, rpc, chain, state

API reference for Midnight. All methods ->

childstate_getStorageSize

Gets the byte size of a child storage value.

Parameters

  • id (integer; required): a request ID (example: 1).

  • jsonrpc (string; required): a JSON RPC spec used (example: 2.0).

  • method (string; required): a method used for the request.

  • params (array; required):

    1. <string>: Child storage key (hex-encoded) identifying the child storage.
    2. <string>: Storage key (hex-encoded) whose value size should be retrieved.
    3. <string> (optional; if omitted, uses the latest block): Block hash at which to query storage.

Returns

  • <number|null>:
    • The size of the value stored under the specified key in the given child storage at the provided block hash, expressed in bytes.
    • null if the key does not exist or if the storage key/block hash is invalid.

Request example

curl -X POST https://rpc.ankr.com/midnight_testnet/YOUR_ANKR_API_KEY/ \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "childstate_getStorageSize",
"params": [
"0x1a2b3c4d5e6f", // child storage key
"0x7f8e9d0c1b2a", // storage key to measure
"0xabc123abc123abc123abc123abc123abc123abc123abc123abc123abc123abc1" // block hash
]
}'

Response example

{
"jsonrpc": "2.0",
"id": 1,
"result": 16
}

RPC Meta:

rpc_methods

Returns a list of all available RPC methods.

Parameters

  • id (integer; required): a request ID (example: 1).
  • jsonrpc (string; required): a JSON RPC spec used (example: 2.0).
  • method (string; required): a method used for the request.
  • params (array; required): none.

Returns

  • <object>: Lists all RPC methods supported by the node along with their version numbers.
    • methods (array<string>): An array of available method names.
    • version (number): The RPC API version of the node.

Request example

curl -X POST https://rpc.ankr.com/midnight_testnet/YOUR_ANKR_API_KEY/ \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "rpc_methods",
"params": []
}'

Response example

{
"jsonrpc": "2.0",
"id": 1,
"result": {
"methods": [
"account_nextIndex", "archive_unstable_body", "archive_unstable_call", "archive_unstable_finalizedHeight", "archive_unstable_genesisHash", "archive_unstable_hashByHeight", "archive_unstable_header", "archive_unstable_storage", "author_hasKey", "author_hasSessionKeys", "author_insertKey", "author_pendingExtrinsics", "author_removeExtrinsic", "author_rotateKeys", "author_submitAndWatchExtrinsic", "author_submitExtrinsic", "author_unwatchExtrinsic", "chainHead_v1_body", "chainHead_v1_call", "chainHead_v1_continue", "chainHead_v1_follow", "chainHead_v1_header", "chainHead_v1_stopOperation", "chainHead_v1_storage", "chainHead_v1_unfollow", "chainHead_v1_unpin", "chainSpec_v1_chainName", "chainSpec_v1_genesisHash", "chainSpec_v1_properties", "chain_getBlock", "chain_getBlockHash", "chain_getFinalisedHead", "chain_getFinalizedHead", "chain_getHead", "chain_getHeader", "chain_getRuntimeVersion", "chain_subscribeAllHeads", "chain_subscribeFinalisedHeads", "chain_subscribeFinalizedHeads", "chain_subscribeNewHead", "chain_subscribeNewHeads", "chain_subscribeRuntimeVersion", "chain_unsubscribeAllHeads", "chain_unsubscribeFinalisedHeads", "chain_unsubscribeFinalizedHeads", "chain_unsubscribeNewHead", "chain_unsubscribeNewHeads", "chain_unsubscribeRuntimeVersion", "childstate_getKeys", "childstate_getKeysPaged", "childstate_getKeysPagedAt", "childstate_getStorage", "childstate_getStorageEntries", "childstate_getStorageHash", "childstate_getStorageSize", "grandpa_proveFinality", "grandpa_roundState", "grandpa_subscribeJustifications", "grandpa_unsubscribeJustifications", "midnight_apiVersions", "midnight_contractState", "midnight_decodeEvents", "midnight_jsonBlock", "midnight_jsonContractState", "midnight_ledgerVersion", "midnight_unclaimedAmount", "midnight_zswapChainState", "midnight_zswapStateRoot", "offchain_localStorageGet", "offchain_localStorageSet", "rpc_methods", "sidechain_getAriadneParameters", "sidechain_getEpochCommittee", "sidechain_getParams", "sidechain_getRegistrations", "sidechain_getStatus", "state_call", "state_callAt", "state_getChildReadProof", "state_getKeys", "state_getKeysPaged", "state_getKeysPagedAt", "state_getMetadata", "state_getPairs", "state_getReadProof", "state_getRuntimeVersion", "state_getStorage", "state_getStorageAt", "state_getStorageHash", "state_getStorageHashAt", "state_getStorageSize", "state_getStorageSizeAt", "state_queryStorage", "state_queryStorageAt", "state_subscribeRuntimeVersion", "state_subscribeStorage", "state_traceBlock", "state_unsubscribeRuntimeVersion", "state_unsubscribeStorage", "subscribe_newHead", "system_accountNextIndex", "system_addLogFilter", "system_addReservedPeer", "system_chain", "system_chainType", "system_dryRun", "system_dryRunAt", "system_health", "system_localListenAddresses", "system_localPeerId", "system_name", "system_nodeRoles", "system_peers", "system_properties", "system_removeReservedPeer", "system_reservedPeers", "system_resetLogFilter", "system_syncState", "system_unstable_networkState", "system_version", "transactionWatch_v1_submitAndWatch", "transactionWatch_v1_unwatch", "transaction_v1_broadcast", "transaction_v1_stop", "unsubscribe_newHead"
]
}
}

Chain & Block Data:

chain_getBlock

Returns full block data for the specified hash.

Parameters

  • id (integer; required): a request ID (example: 1).

  • jsonrpc (string; required): a JSON RPC spec used (example: 2.0).

  • method (string; required): a method used for the request.

  • params (array; required):

    • <string> (optional; default = latest block): Block hash (hex-encoded).

Returns

  • <object|null>: The full block data for the specified (or latest) block.
    • block (object):
      • header (object): Standard block header fields:
        • parentHash (string): Hash of the parent block.
        • number (string): Block number (in hex).
        • stateRoot (string): State trie root hash.
        • extrinsicsRoot (string): Extrinsics trie root hash.
        • digest (object): Consensus-specific digest logs.
      • extrinsics (array<string>): Array of hex-encoded extrinsics included in the block.
    • justifications (array, optional): Consensus justifications if available.
  • null: Returned if the block hash is unknown or unavailable.

Request example

curl -X POST https://rpc.ankr.com/midnight_testnet/YOUR_ANKR_API_KEY/ \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "chain_getBlock",
"params": []
}'

Response example

{
"id": 1,
"jsonrpc": "2.0",
"result": {
"block": {
"header": {
"parentHash": "0x26b043f145df5bc8a79ef3d4b28c4268f00d8dffb3240a5f2e0a9cb9fdf65463",
"number": "0xfd930",
"stateRoot": "0x99e9486ce0903d2e6edd3cb956a8d1e494bd62837a3e49522ae4ce132744c1af",
"extrinsicsRoot": "0xd76623660daae937c6946187f8fd42f73565d8871f558c38691fc66669d41b95",
"digest": {
"logs": [
"0x066175726120b6ef6b1100000000",
"0x066d637368806ee7f2ab25cdde91cf901ff3fcf2574b03aab5ff415dad4709d0eaaed37ba253",
"0x044d4e535610e02e0000",
"0x05617572610101d61d4bb831d89528e61ed672666d5365812e9060e4a9abe832bea327fb48d541eba53fe823022f7d2baee8baa61a981a648c87ded75656a2f01e5fd66fb7b782"
]
}
},
"extrinsics": [
"0x280401000ba039c2519801",
"0x9c040a00e12e00007f913da0a8f430c261bda1748a29a452785213eeb5c70f27efd0afa74f7a5e2a"
]
},
"justifications": null
}
}

chain_getBlockHash

Returns the block hash for a given block number.

Parameters

  • id (integer; required): a request ID (example: 1).

  • jsonrpc (string; required): a JSON RPC spec used (example: 2.0).

  • method (string; required): a method used for the request.

  • params (array; required):

    • <number> (unsigned integer; optional; default = latest block): Block number.

Returns

  • <string|null>:
    • The block hash (hex-encoded) for the specified block number.
    • If no block number is provided, returns the hash of the latest block.
    • null if the given block number is unknown or unavailable.

Request example

curl -X POST https://rpc.ankr.com/midnight_testnet/YOUR_ANKR_API_KEY/ \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "chain_getBlockHash",
"params": [
981031
]
}'

Response example

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

chain_getFinalisedHead

Returns the latest finalized block hash.

Parameters

  • id (integer; required): a request ID (example: 1).
  • jsonrpc (string; required): a JSON RPC spec used (example: 2.0).
  • method (string; required): a method used for the request.
  • params (array; required): none.

Returns

  • <string|null>:
    • The hash of the latest finalized block (hex-encoded).
    • null if no finalized block is available (rare or only in misconfigured nodes).

Request example

curl -X POST https://rpc.ankr.com/midnight_testnet/YOUR_ANKR_API_KEY/ \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "chain_getFinalisedHead",
"params": []
}'

Response example

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

chain_getFinalizedHead

Returns the latest finalized block hash.

Parameters

  • id (integer; required): a request ID (example: 1).
  • jsonrpc (string; required): a JSON RPC spec used (example: 2.0).
  • method (string; required): a method used for the request.
  • params (array; required): none.

Returns

  • <string|null>:
    • The hash of the latest finalized block (hex-encoded).
    • null if no finalized block is available (rare or only in misconfigured nodes).

Request example

curl -X POST https://rpc.ankr.com/midnight_testnet/YOUR_ANKR_API_KEY/ \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "chain_getFinalizedHead",
"params": []
}'

Response example

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

chain_getHead

Returns the current best block hash.

Parameters

  • id (integer; required): a request ID (example: 1).
  • jsonrpc (string; required): a JSON RPC spec used (example: 2.0).
  • method (string; required): a method used for the request.
  • params (array; required): none.

Returns

  • <string|null>:
    • The hash of the current best (head) block in the chain (hex-encoded).
    • null if the head is not available or the node is not fully synced.

Request example

curl -X POST https://rpc.ankr.com/midnight_testnet/YOUR_ANKR_API_KEY/ \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "chain_getHead",
"params": []
}'

Response example

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

chain_getHeader

Fetches the header of a given block.

Parameters

  • id (integer; required): a request ID (example: 1).

  • jsonrpc (string; required): a JSON RPC spec used (example: 2.0).

  • method (string; required): a method used for the request.

  • params (array; required):

    • <string> (optional; default = latest block): Block hash (hex-encoded) of the block header to fetch.

Returns

  • <object|null>: The block header for the specified block hash or the latest block if no hash is provided.
    • parentHash (string): Hash of the parent block.
    • number (string): Block number (hex-encoded).
    • stateRoot (string): State trie root hash.
    • extrinsicsRoot (string): Extrinsics trie root hash.
    • digest (object): Consensus-specific digest logs.

Request example

curl -X POST https://rpc.ankr.com/midnight_testnet/YOUR_ANKR_API_KEY/ \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "chain_getHeader",
"params": []
}'

Response example

{
"id": 1,
"jsonrpc": "2.0",
"result": {
"parentHash": "0x40053cbf0cd5a892d83dd1e571eca18aa26f23b662d73543e4923fd1a423b72d",
"number": "0xfda2c",
"stateRoot": "0x60433a64c395298ed61505bc99640a122ccac6cf001c55a437ee7843d9fdd255",
"extrinsicsRoot": "0xe5e242d6ee488f323663b2361fc35562a753d4144f4f94ee6530d4109685d646",
"digest": {
"logs": [
"0x066175726120bcf06b1100000000",
"0x066d637368805157cac8b69df7748c7d9705a707a2a6a1f2d0ed9d7f669d1e568b91a02e26fa",
"0x044d4e535610e02e0000",
"0x05617572610101bebbfeb2aa9614db5d1b9cb0835c76b7916cd4012e9aa1ea20cdb0817fcb78037ef3eccbc41d3ed1c445a7869410cb5ac5d2c87a9b49d17b58009ae78e82b482"
]
}
}
}

chain_getRuntimeVersion

Returns the current runtime version of the chain.

Parameters

  • id (integer; required): a request ID (example: 1).

  • jsonrpc (string; required): a JSON RPC spec used (example: 2.0).

  • method (string; required): a method used for the request.

  • params (array; required):

    • <string> (optional; default = latest block): Block hash (hex-encoded) at which to retrieve the runtime version.

Returns

  • <object>: Runtime version details for the given block (or the latest if no hash is provided).
    • specName (string): Name of the runtime specification.
    • implName (string): Name of the runtime implementation.
    • authoringVersion (number): Authoring version of the runtime.
    • specVersion (number): Version of the runtime specification.
    • implVersion (number): Implementation version.
    • apis (array<[string, number]>): List of supported API names and their version numbers.
    • transactionVersion (number): Transaction format version supported by the runtime.
    • stateVersion (number, optional): State format version (if present).

Request example

{
"id": 1,
"jsonrpc": "2.0",
"result": {
"specName": "midnight",
"implName": "midnight",
"authoringVersion": 1,
"specVersion": 12000,
"implVersion": 0,
"apis": [
[
"0xfbc577b9d747efd6",
1
],
[
"0xdf6acb689907609b",
5
],
[
"0x7d699da8a672e867",
4
]
],
"transactionVersion": 2,
"stateVersion": 1
}
}

State & Storage:

state_call

Executes a runtime call without submitting an extrinsic.

Parameters

  • id (integer; required): a request ID (example: 1).

  • jsonrpc (string; required): a JSON RPC spec used (example: 2.0).

  • method (string; required): a method used for the request.

  • params (array; required):

    1. <string>: Runtime function name (e.g., Metadata_metadata).
    2. <string>: Data (hex-encoded SCALE-encoded arguments for the function).
    3. <string> (32-byte, hex; optional; default = latest block): Block hash.

Returns

  • <string>: A hex-encoded SCALE-encoded result returned by the runtime function call.
  • null: Returned if the function call fails or the given parameters are invalid.

Request example

curl -X POST https://rpc.ankr.com/midnight_testnet/YOUR_ANKR_API_KEY/ \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "state_call",
"params": [
"Metadata_metadata",
"0x"
]
}'

Response example

{
"jsonrpc": "2.0",
"id": 1,
"result": "0xde0904006d6574610e8103000c1c73705f636f72651863727970746f2c4163636f756e7449643332000004000401205b75383b2033325d0000040000032000000008000800000503000c08306672616d655f73797374656d2c4163636f756e74496e666f08144e6f6e636501102c4163636f756e74446174610114001401146e6f6e63651001144e6f6e6365000124636f6e73756d657273100120526566436f756e7400012470726f7669646572731001205265664..."
}

state_callAt

Executes a runtime call at a specific block.

Parameters

  • id (integer; required): a request ID (example: 1).

  • jsonrpc (string; required): a JSON RPC spec used (example: 2.0).

  • method (string; required): a method used for the request.

  • params (array; required):

    1. <string>: Runtime function name (for example, Metadata_metadata).
    2. <string>: Data — SCALE-encoded arguments for the function, hex-encoded (use 0x if there are no arguments).
    3. <string> (32-byte, hex): Block hash at which to execute the runtime function call.

Returns

  • <string>: A hex-encoded SCALE-encoded result returned by the runtime function call at the specified block.
  • null: Returned if the call fails or the provided parameters are invalid.

Request example

curl -X POST https://rpc.ankr.com/midnight_testnet/YOUR_ANKR_API_KEY/ \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "state_callAt",
"params": [
"Metadata_metadata",
"0x",
"0x94f03b64f26069f6995de0e68442a3470801fd6cdb3a0cf7491ed7ca217f23ec"
]
}'

Response example

{
"jsonrpc": "2.0",
"id": 1,
"result": "0xde0904006d6574610e8103000c1c73705f636f72651863727970746f2c4163636f756e7449643332000004000401205b75383b2033325d0000040000032000000008000800000503000c08306672616d655f73797374656d2c4163636f756e74496e666f08144e6f6e636501102c4163636f756e74446174610114001401146e6f6e63651001144e6f6e6365000124636f6e73756d657273100120526566436f756e7400012470726f766964657273100120526566436f756e7400012c73756666696369656e7473100120526566436f756e740001106461746114012c4163636f756e74446174610000100000050500140c3c70616c6c65745f62616c616e6365731474797065732c416..."
}

state_getChildReadProof

Returns proof of inclusion for child storage.

Parameters

  • id (integer; required): a request ID (example: 1).

  • jsonrpc (string; required): a JSON RPC spec used (example: 2.0).

  • method (string; required): a method used for the request.

  • params (array; required):

    1. <string>: Child storage key (hex-encoded) identifying the child storage.
    2. <array<string>>: Keys — an array of hex-encoded storage keys inside the child storage to generate a read proof for.
    3. <string> (hex-encoded, 32-byte): Block hash at which to generate the read proof.

Returns

  • <object>: The read proof object for the requested child storage keys.
    • at (string): Block hash at which the proof was generated.
    • proof (array<string>): An array of hex-encoded proof nodes required to prove the existence of the keys.

Request example

curl -X POST https://rpc.ankr.com/midnight_testnet/YOUR_ANKR_API_KEY/ \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "state_getChildReadProof",
"params": [
"0x1a2b3c4d5e6f", // child storage key
[
"0x7f8e9d0c1b2a", // key 1
"0x1234567890ab" // key 2
],
"0x498b4b3aa63dc3abaebf559be8e903357c07589532eb931f9097d533c99800a2" // block hash
]
}'

Response example

{
"jsonrpc": "2.0",
"id": 1,
"result": {
"at": "0x498b4b3aa63dc3abaebf559be8e903357c07589532eb931f9097d533c99800a2",
"proof": [
"0x1234abcd5678ef90",
"0x9abcdeffedcba9876543210011223344"
]
}
}

state_getKeys

Returns a list of all keys in the storage.

Parameters

  • id (integer; required): a request ID (example: 1).

  • jsonrpc (string; required): a JSON RPC spec used (example: 2.0).

  • method (string; required): a method used for the request.

  • params (array; required):

    1. <string>: Key prefix (hex-encoded) to filter returned keys. Use 0x to retrieve all keys.
    2. <string> (hex-encoded, 32-byte; optional): Block hash.

Returns

  • <array<string>>: A list of hex-encoded keys in the state that match the specified prefix.
  • []: Returned if no keys match the given prefix.
  • null: Returned if the provided block hash is invalid or unavailable.

Request example

curl -X POST https://rpc.ankr.com/midnight_testnet/YOUR_ANKR_API_KEY/ \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "state_getKeys",
"params": [
"0x"
]
}'

Response example

{
"jsonrpc": "2.0",
"id": 1,
"result": [
"0x0b20199ace3564d0964e2c4d4a9ba4694e7b9012096b41c4eb3aaf947f6ea429",
"0x0cfd083eaa944b95833ee029c0bdffe34e7b9012096b41c4eb3aaf947f6ea429",
"0x0cfd083eaa944b95833ee029c0bdffe388dcde934c658227ee1dfafcd6e16903",
"0x0cfd083eaa944b95833ee029c0bdffe3e0cdd062e6eaf24295ad4ccfc41d4609",
"0x26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac",
"0x26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850",
"0x26aa394eea5630e07c48ae0c9558cef734abf5cb34d6244378cddbf18e849d96"
]
}

state_getKeysPaged

Returns paged storage keys.

Parameters

  • id (integer; required): a request ID (example: 1).

  • jsonrpc (string; required): a JSON RPC spec used (example: 2.0).

  • method (string; required): a method used for the request.

  • params (array; required):

    1. <string>: Key prefix (hex-encoded) to filter returned keys. Use 0x to retrieve all keys.
    2. <number>: Count — maximum number of keys to return.
    3. <string>: Start key (hex-encoded) to start returning keys from. Use 0x or omit to start from the beginning.
    4. <string> (hex-encoded, 32-byte; optional): Block hash at which to query the keys. If omitted, defaults to the latest block.

Returns

  • <array<string>>: A list of hex-encoded keys in the state that match the specified prefix, limited by the given count and starting from start key.
  • []: Returned if no keys match the given criteria.
  • null: Returned if the provided block hash is invalid or unavailable.

Request example

curl -X POST https://rpc.ankr.com/midnight_testnet/YOUR_ANKR_API_KEY/ \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "state_getKeysPaged",
"params": [
"0x",
10,
"0x"
]
}'

Response example

{
"id": 1,
"jsonrpc": "2.0",
"result": [
"0x0b20199ace3564d0964e2c4d4a9ba4694e7b9012096b41c4eb3aaf947f6ea429",
"0x0cfd083eaa944b95833ee029c0bdffe34e7b9012096b41c4eb3aaf947f6ea429",
"0x0cfd083eaa944b95833ee029c0bdffe388dcde934c658227ee1dfafcd6e16903",
"0x0cfd083eaa944b95833ee029c0bdffe3e0cdd062e6eaf24295ad4ccfc41d4609",
"0x26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac",
"0x26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850",
"0x26aa394eea5630e07c48ae0c9558cef734abf5cb34d6244378cddbf18e849d96",
"0x26aa394eea5630e07c48ae0c9558cef74e7b9012096b41c4eb3aaf947f6ea429",
"0x26aa394eea5630e07c48ae0c9558cef75684a022a34dd8bfa2baaf44f172b710",
"0x26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7"
]
}

state_getKeysPagedAt

Returns paged keys at a specific block.

Parameters

  • id (integer; required): a request ID (example: 1).

  • jsonrpc (string; required): a JSON RPC spec used (example: 2.0).

  • method (string; required): a method used for the request.

  • params (array; required):

    1. <string>: Key prefix (hex-encoded) to filter returned keys. Use 0x to retrieve all keys.
    2. <number>: Count — maximum number of keys to return.
    3. <string>: Start key (hex-encoded) to start returning keys from. Use 0x or omit to start from the beginning.
    4. <string> (hex-encoded, 32-byte): Block hash at which to query the keys.

Returns

  • <array<string>>: A list of hex-encoded keys in the state that match the specified prefix, limited by the given count, starting from start key, at the specified block hash.
  • []: Returned if no keys match the given criteria.
  • null: Returned if the provided block hash is invalid or unavailable.

Request example

curl -X POST https://rpc.ankr.com/midnight_testnet/YOUR_ANKR_API_KEY/ \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "state_getKeysPagedAt",
"params": [
"0x1a2b3c", // key prefix
10, // maximum number of keys
"0x", // start key (empty = start from first key)
"0x498b4b3aa63dc3abaebf559be8e903357c07589532eb931f9097d533c99800a2" // block hash
]
}'

Response example

{
"jsonrpc": "2.0",
"id": 1,
"result": [
"0x1a2b3c4d5e6f0011",
"0x1a2b3c4d5e6f0022",
"0x1a2b3c4d5e6f0033"
]
}

state_getMetadata

Returns the current runtime metadata.

Parameters

  • id (integer; required): a request ID (example: 1).

  • jsonrpc (string; required): a JSON RPC spec used (example: 2.0).

  • method (string; required): a method used for the request.

  • params (array; required):

    • <string> (hex-encoded, 32-byte; optional; default = latest block): Block hash at which to query the metadata.

Returns

  • <string>:

    • Hex-encoded SCALE-encoded metadata for the runtime at the given block hash (or latest block if no hash is provided).
    • This metadata describes the runtime's modules, storage items, extrinsics, and constants.
  • null: Returned if the metadata is unavailable or the block hash is invalid.

Request example

curl -X POST https://rpc.ankr.com/midnight_testnet/YOUR_ANKR_API_KEY/ \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "state_getMetadata",
"params": []
}'

Response example

{
"jsonrpc": "2.0",
"id": 1,
"result": "0x6d6574610e8103000c1c73705f636f72651863727970746f2c4163636f756e7449643332000004000401205b75383b2033325d0000040000032000000008000800000503000c08306672616d655f73797374656d2c4163636f756e74496e666f08144e6f6e636501102c4163636f756e74446174610114001401146e6f6e63651001144e6f6e6365000124636f6e73756d657273100120526566436f756e7400012470726f766964657273100120526566436f756e7400012c73756666696369656e7473100120526566436f756e740001106461746114012c4163636f756e74446174610000100000050500140c3c70616c6c65745f62616c616e6365731474797065732c4163636f7..."
}

state_getReadProof

Returns a proof of inclusion for storage entries.

Parameters

  • id (integer; required): a request ID (example: 1).

  • jsonrpc (string; required): a JSON RPC spec used (example: 2.0).

  • method (string; required): a method used for the request.

  • params (array; required):

    1. <array<string>>: Keys — an array of hex-encoded state keys to create a read proof for.
    2. <string> (hex-encoded, 32-byte): Block hash at which to generate the proof.

Returns

  • <object>: The read proof object for the requested state keys.
    • at (string): Block hash at which the proof was generated.
    • proof (array<string>): An array of hex-encoded proof nodes required to prove the existence of the keys at the specified block.

Request example

curl -X POST https://rpc.ankr.com/midnight_testnet/YOUR_ANKR_API_KEY/ \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "state_getReadProof",
"params": [
[
"0x1a2b3c4d5e6f0011",
"0x1a2b3c4d5e6f0022"
],
"0x94f03b64f26069f6995de0e68442a3470801fd6cdb3a0cf7491ed7ca217f23ec"
]
}'

Response example

{
"id": 1,
"jsonrpc": "2.0",
"result": {
"at": "0x94f03b64f26069f6995de0e68442a3470801fd6cdb3a0cf7491ed7ca217f23ec",
"proof": [
"0x802db9803d16513e9985407f820a80efdce62468bf83d4bd901439f1bd90301ed67b140c802558978862c74093fbfbda43640e35d7835a94faef9cc901d7a587db0ddd785180db91f4799a4b8ee3625aa624fdd488505a164f72c123ebb190b131c8259abd36809b8be6ee23eadd747a7fd1201db80a1b3639abf057a79e74ea893c40a4aeefbf80482fbb43c1300417b5e77c5f80ee53cbd3e403c638e893a077bab16a423771818077baa6c5755310b557a6c78028494f837157f8f782f12094d1ff4763d98f05238000e4849ead44a8fe73e1a5536de4173f3c980af6598cb2c9d182eb5be81538ad80f9301ba37a1430856c624d3e305a0a09b900845ddf916cb024988b10b077b55780c5834099227798c65ed9f0771bcb2599e1c4b66e7817e058eb1d6b6f1337ba67"
]
}
}

state_getRuntimeVersion

Returns the runtime version at the current best block.

Parameters

  • id (integer; required): a request ID (example: 1).

  • jsonrpc (string; required): a JSON RPC spec used (example: 2.0).

  • method (string; required): a method used for the request.

  • params (array; required):

    • <string> (hex-encoded, 32-byte; optional; default = latest block): Block hash at which to query the runtime version.

Returns

  • <object>: The runtime version information for the given block (or the latest block if none is provided).
    • specName (string): Name of the runtime specification.
    • implName (string): Name of the runtime implementation.
    • authoringVersion (number): Authoring version of the runtime.
    • specVersion (number): Runtime specification version.
    • implVersion (number): Runtime implementation version.
    • apis (array<[string, number]>): List of supported runtime API names and their versions.
    • transactionVersion (number): Transaction format version.
    • stateVersion (number, optional): State format version (if present).

Request example

curl -X POST https://rpc.ankr.com/midnight_testnet/YOUR_ANKR_API_KEY/ \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "state_getRuntimeVersion",
"params": []
}'

Response example

{
"id": 1,
"jsonrpc": "2.0",
"result": {
"specName": "midnight",
"implName": "midnight",
"authoringVersion": 1,
"specVersion": 12000,
"implVersion": 0,
"apis": [
[
"0xfbc577b9d747efd6",
1
],
[
"0xdf6acb689907609b",
5
],
[
"0x7d699da8a672e867",
4
]
],
"transactionVersion": 2,
"stateVersion": 1
}
}

state_getStorage

Returns storage value for a given key.

Parameters

  • id (integer; required): a request ID (example: 1).

  • jsonrpc (string; required): a JSON RPC spec used (example: 2.0).

  • method (string; required): a method used for the request.

  • params (array; required):

    1. <string>: Storage key (hex-encoded) identifying the desired value in the state.
    2. <string> (hex-encoded, 32-byte; optional; default = latest block): Block hash at which to query storage.

Returns

  • <string|null>:
    • The hex-encoded SCALE-encoded value stored under the specified storage key at the given block hash (or at the latest block if no hash is provided).
    • null if the key does not exist or the block hash is invalid.

Request example

curl -X POST https://rpc.ankr.com/midnight_testnet/YOUR_ANKR_API_KEY/ \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "state_getStorage",
"params": [
"0x1a2b3c4d5e6f"
]
}'

Response example

{
"id": 1,
"jsonrpc": "2.0",
"result": null
}

state_getStorageAt

Returns storage value at a given block.

Parameters

  • id (integer; required): a request ID (example: 1).

  • jsonrpc (string; required): a JSON RPC spec used (example: 2.0).

  • method (string; required): a method used for the request.

  • params (array; required):

    1. <string>: Storage key (hex-encoded) identifying the desired value in the state.
    2. <string> (hex-encoded, 32-byte): Block hash at which to query storage.

Returns

  • <string|null>:
    • The hex-encoded SCALE-encoded value stored under the specified storage key at the given block hash.
    • null if the key does not exist or the block hash is invalid.

Request example

curl -X POST https://rpc.ankr.com/midnight_testnet/YOUR_ANKR_API_KEY/ \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "state_getStorageAt",
"params": [
"0x1a2b3c4d5e6f",
"0x94f03b64f26069f6995de0e68442a3470801fd6cdb3a0cf7491ed7ca217f23ec"
]
}'

Response example

{
"id": 1,
"jsonrpc": "2.0",
"result": null
}

state_getStorageHash

Returns hash of the storage entry.

Parameters

  • id (integer; required): a request ID (example: 1).

  • jsonrpc (string; required): a JSON RPC spec used (example: 2.0).

  • method (string; required): a method used for the request.

  • params (array; required):

    1. <string>: Storage key (hex-encoded) identifying the desired value in the state.
    2. <string> (hex-encoded, 32-byte; optional; default = latest block): Block hash at which to query the storage hash.

Returns

  • <string|null>:
    • The hash (hex-encoded) of the value stored under the specified storage key at the given block hash (or latest block if omitted).
    • null if the key does not exist or the block hash is invalid.

Request example

curl -X POST https://rpc.ankr.com/midnight_testnet/YOUR_ANKR_API_KEY/ \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "state_getStorageHash",
"params": [
"0x1a2b3c4d5e6f"
]
}'

Response example

{
"id": 1,
"jsonrpc": "2.0",
"result": null
}

state_getStorageHashAt

Returns hash of storage at a specific block.

Parameters

  • id (integer; required): a request ID (example: 1).

  • jsonrpc (string; required): a JSON RPC spec used (example: 2.0).

  • method (string; required): a method used for the request.

  • params (array; required):

    1. <string>: Storage key (hex-encoded) identifying the desired value in the state.
    2. <string> (hex-encoded, 32-byte): Block hash at which to query the storage hash.

Returns

  • <string|null>:
    • The hash (hex-encoded) of the value stored under the specified storage key at the given block hash.
    • null if the key does not exist or the block hash is invalid.

Request example

curl -X POST https://rpc.ankr.com/midnight_testnet/YOUR_ANKR_API_KEY/ \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "state_getStorageHashAt",
"params": [
"0x1a2b3c4d5e6f",
"0x94f03b64f26069f6995de0e68442a3470801fd6cdb3a0cf7491ed7ca217f23ec"
]
}'

Response example

{
"id": 1,
"jsonrpc": "2.0",
"result": null
}

state_getStorageSize

Returns byte size of storage for a key.

Parameters

  • id (integer; required): a request ID (example: 1).

  • jsonrpc (string; required): a JSON RPC spec used (example: 2.0).

  • method (string; required): a method used for the request.

  • params (array; required):

    1. <string>: Storage key (hex-encoded) identifying the desired value in the state.
    2. <string> (hex-encoded, 32-byte; optional; default = latest block): Block hash at which to query the storage size.

Returns

  • <number|null>:
    • The size of the value stored under the specified storage key, in bytes, at the given block hash (or at the latest block if no hash is provided).
    • null if the key does not exist or the block hash is invalid.

Request example

curl -X POST https://rpc.ankr.com/midnight_testnet/YOUR_ANKR_API_KEY/ \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "state_getStorageSize",
"params": [
"0x1a2b3c4d5e6f"
]
}'

Response example

{
"id": 1,
"jsonrpc": "2.0",
"result": null
}

state_getStorageSizeAt

Returns size of storage at a given block.

Parameters

  • id (integer; required): a request ID (example: 1).

  • jsonrpc (string; required): a JSON RPC spec used (example: 2.0).

  • method (string; required): a method used for the request.

  • params (array; required):

    1. <string>: Storage key (hex-encoded) identifying the desired value in the state.
    2. <string> (hex-encoded, 32-byte): Block hash at which to query the storage size.

Returns

  • <number|null>:
    • The size of the value stored under the specified storage key, in bytes, at the given block hash.
    • null if the key does not exist or the block hash is invalid.

Request example

curl -X POST https://rpc.ankr.com/midnight_testnet/YOUR_ANKR_API_KEY/ \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "state_getStorageSizeAt",
"params": [
"0x01020304abcdef",
"0x111122223333444455556666777788889999aaaabbbbccccddddeeeeffff0000"
]
}'

Response example

{
"jsonrpc": "2.0",
"id": 1,
"result": 32
}

state_queryStorageAt

Queries storage at a specific block.

Parameters

  • id (integer; required): a request ID (example: 1).

  • jsonrpc (string; required): a JSON RPC spec used (example: 2.0).

  • method (string; required): a method used for the request.

  • params (array; required):

    1. <array<string>>: Keys — an array of hex-encoded storage keys to query.
    2. <string> (hex-encoded, 32-byte; optional; default = latest block): Block hash at which to query.

Returns

  • <array<object>>: An array containing one or more change sets for the specified keys at the given block (or latest block if none is specified).
    • block (string): The block hash at which the values were queried.
    • changes (array<[string, string|null]>): Key-value pairs for each requested storage key:
      • key (string): Hex-encoded storage key.
      • value (string|null): Hex-encoded value stored at that key, or null if no value is set.

Request example

curl -X POST https://rpc.ankr.com/midnight_testnet/YOUR_ANKR_API_KEY/ \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "state_queryStorageAt",
"params": [
[
"0x26aa394eea5630e07c48ae0c9558cef7",
"0x1a2b3c4d"
],
"0x84e03f95bf0241e0e6768d510bd5d53fd86353cec4e5903524161e04da3905fc"
]
}'

Response example

{
"id": 1,
"jsonrpc": "2.0",
"result": [
{
"block": "0x84e03f95bf0241e0e6768d510bd5d53fd86353cec4e5903524161e04da3905fc",
"changes": [
[
"0x26aa394eea5630e07c48ae0c9558cef7",
null
],
[
"0x1a2b3c4d",
null
]
]
}
]
}