Midnight — system, account, grandpa, offchain, archive, midnight, sidechain, childstate (3/3)
API reference for Midnight. All methods ->
childstate_getKeysPagedAt
Returns paged keys from a past 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>: Child storage key (hex-encoded) identifying the child storage.<string>: Key prefix (hex-encoded) to filter keys. Use "0x" to match all keys.<number>: Count — the maximum number of keys to return.<string>: Start key (hex-encoded) for pagination. Use "0x" or omit to start from the beginning.<string>(required): Block hash at which to query state.
Returns
<array<string>>: A list of child storage keys (hex-encoded) that match the given prefix, limited by pagination parameters, at the specified block.[]: Returned if no keys match the prefix at the given block.null: Returned if the child storage key or 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_getKeysPagedAt",
"params": [
"0x1a2b3c4d5e6f", // child storage key
"0x", // key prefix (empty = all keys)
10, // maximum number of keys to return
"0x", // start key for pagination (empty = start from first key)
"0xabc123abc123abc123abc123abc123abc123abc123abc123abc123abc123abc1" // block hash
]
}'
Response example
{
"jsonrpc": "2.0",
"id": 1,
"result": [
"0x1a2b3c4d5e6f0011",
"0x1a2b3c4d5e6f0022",
"0x1a2b3c4d5e6f0033"
]
}
childstate_getStorage
Gets a storage entry from 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):<string>: Child storage key (hex-encoded) identifying the child storage.<string>: Storage key (hex-encoded) to fetch the value for.<string>: Block hash at which to query storage (optional; if omitted, uses the latest block).
Returns
<string|null>:- The hex-encoded SCALE-encoded value stored under the given key in the specified child storage at the given block hash.
nullif no value exists for the key 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_getStorage",
"params": [
"0x1a2b3c4d5e6f", // child storage key
"0x7f8e9d0c1b2a", // storage key to fetch
"0xabc123abc123abc123abc123abc123abc123abc123abc123abc123abc123abc1" // block hash
]
}'
Response example
{
"jsonrpc": "2.0",
"id": 1,
"result": "0x01020304"
}
childstate_getStorageEntries
Gets multiple entries from 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):<string>: Child storage key (hex-encoded) identifying the child storage.<array<string>>: Storage keys (hex-encoded) for which values should be fetched.<string>(optional; if omitted, uses the latest block): Block hash at which to query storage.
Returns
<array<string|null>>: An array of hex-encoded SCALE-encoded values corresponding to the requested storage keys, in the same order as provided in the request.
Each element is either:
- A hex-encoded value (if the key exists).
null(if no value exists for that key).
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_getStorageEntries",
"params": [
"0x1a2b3c4d5e6f", // child storage key
[
"0x7f8e9d0c1b2a", // storage key 1
"0x1234567890ab" // storage key 2
],
"0xabc123abc123abc123abc123abc123abc123abc123abc123abc123abc123abc1" // block hash
]
}'
Response example
{
"jsonrpc": "2.0",
"id": 1,
"result": [
"0x01020304",
null
]
}
childstate_getStorageHash
Gets hash 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):<string>: Child storage key (hex-encoded) identifying the child storage.<string>: Storage key (hex-encoded) for which to retrieve the hash.<string>(optional; if omitted, uses the latest block): Block hash at which to query storage.
Returns
<string|null>:- A hex-encoded hash of the value stored under the specified key in the given child storage at the provided block hash.
nullif no value exists for the key 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_getStorageHash",
"params": [
"0x1a2b3c4d5e6f", // child storage key
"0x7f8e9d0c1b2a", // storage key to hash
"0xabc123abc123abc123abc123abc123abc123abc123abc123abc123abc123abc1" // block hash
]
}'
Response example
{
"jsonrpc": "2.0",
"id": 1,
"result": "0x7f8e9d0c1b2a4f00112233445566778899aabbccddeeff001122334455667788"
}