Midnight — system, account, grandpa, offchain, archive, midnight, sidechain, childstate
API reference for Midnight. All methods ->
system_chain
Returns the name 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): none.
Returns
<string>: the name of the blockchain network the node is connected to.
Request example
curl -X POST https://rpc.ankr.com/midnight_testnet/YOUR_ANKR_API_KEY/ \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"method": "system_chain",
"params": [],
"id": 1
}'
Response example
{
"id": 1,
"jsonrpc": "2.0",
"result": "testnet-02-1"
}
system_chainType
Returns chain type (dev, local, live).
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>: The type of chain the node is connected to. Common values include:Live: A production network.Development: A local development chain.Local: A locally run chain or test instance.
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": "system_chainType",
"params": []
}'
Response example
{
"id": 1,
"jsonrpc": "2.0",
"result": "Live"
}
system_health
Returns node health and sync status.
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>: A health status object describing the current state of the node. It contains the following fields:isSyncing(boolean): Indicates whether the node is currently syncing with the network.peers(integer): The number of peers the node is connected to.shouldHavePeers(boolean): Indicates whether the node is expected to have peers (based on its configuration).networkState(object, optional): Additional network diagnostics (included on some node types).
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": "system_health",
"params": []
}'
Response example
{
"id": 1,
"jsonrpc": "2.0",
"result": {
"peers": 19,
"isSyncing": false,
"shouldHavePeers": true
}
}
system_properties
Returns chain properties (token decimals, etc).
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>: A key-value object containing chain-specific properties. Common fields include:ss58Format(integer): The default SS58 address format used by the chain.tokenDecimals(array<integer>): Number of decimal places used by each token on the chain.tokenSymbol(array<string>): The symbols of the tokens used by the chain (e.g., ["DUST"] or ["ADA"]).- Additional implementation-specific properties may also be returned depending on the chain configuration.
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": "system_properties",
"params": []
}'
Response example
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"genesis_tx": "fe6a2c00040500e26a2c00303230343030303030303030303030343030303030303030303033383030303030303031356666353561343934666466653636626535353639393864396262663937313232623537313931386239623230636638313430626565393..."
}
}
system_syncState
Returns sync status and highest known 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): none.
Returns
<object>: Synchronization status of the node, containing:startingBlock(string): The block number at which the node started syncing.currentBlock(string): The current block number the node has synced up to.highestBlock(string): The highest known block number that the node is aware of.
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": "system_syncState",
"params": []
}'
Response example
{
"id": 1,
"jsonrpc": "2.0",
"result": {
"startingBlock": 657521,
"currentBlock": 967344,
"highestBlock": 967344
}
}
system_version
Returns node implementation version.
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>: The version of the node implementation, typically including:- The client name,
- Semantic version number, and
- Build metadata (if applicable).
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": "system_version",
"params": []
}'
Response example
{
"id": 1,
"jsonrpc": "2.0",
"result": "0.12.0-29935d2f"
}
Accounts & Keys:
account_nextIndex
Returns the next nonce for an account.
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>: The account address (SS58-encoded) for which to retrieve the next usable nonce.
Returns
<string>: The next valid transaction nonce for the given account, returned as a string representing an unsigned integer. This value is used when constructing a new extrinsic to ensure it has the correct transaction order.
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": "account_nextIndex",
"params": [
"5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY" // example Base58 address
]
}'
Response example
{
"jsonrpc": "2.0",
"id": 1,
"result": "5"
}
system_accountNextIndex
Alias to
account_nextIndex.
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>: The account address (SS58-encoded) for which to retrieve the next usable nonce.
Returns
<string>: The next valid transaction nonce for the given account, returned as a string representing an unsigned integer. This value is used when constructing a new extrinsic to ensure it has the correct transaction order.
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": "system_accountNextIndex",
"params": [
"5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY" // example Base58 address
]
}'
Response example
{
"jsonrpc": "2.0",
"id": 1,
"result": "5"
}
Grandpa Finality:
grandpa_proveFinality
Provides a justification proof for finalized blocks via Grandpa.
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>(block number or hash): The block identifier for which to generate a GRANDPA finality proof. Can be specified as a block number (hex or decimal) or a block hash (hex).
Returns
<object>: A GRANDPA finality proof object, which typically contains:block: (string) The block hash that was proven finalized.justification: (string) A hex-encoded GRANDPA justification, proving the finality of the 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": "grandpa_proveFinality",
"params": [981031]
}'
Response example
{
"jsonrpc": "2.0",
"id": 1,
"result": "0x315fed908a6b3ecdba9098b49b3d4e1df77a7c4ba1ed34669cdea91dfa98ad4aa91feb09000000000000315fed908a6b3ecdba9098b49b3d4e1df77a7c4ba1ed34669cdea91dfa98ad4a62f80e003c315fed908a6b3ecdba9098b49b3d4e1df77a7c4ba1ed34669cdea91df..."
}
grandpa_roundState
Returns the current round state of the Grandpa finality mechanism.
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>: Information about the current GRANDPA finality round state. Common fields include:setId(string): Identifier of the current GRANDPA authority set.best(object): The best round known to the node, including round number and state.background(array<object>): Other rounds running in the background with their states and details.
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": "grandpa_roundState",
"params": []
}'
Response example
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"setId": 852,
"best": {
"round": 1457,
"totalWeight": 1200,
"thresholdWeight": 801,
"prevotes": {
"currentWeight": 1149,
"missing": [
"5C9FrTp4JJZZsAVScQVNhFaQTcxLNhmFW9r9mPDFLCbjK9BL",
"5CAJk7RPtFHmRefs7dpuid9VHi5nG2so2pS4MsfDYQQ6Z3L5",
"5CjZ1FWmxwkrLPysomPbXmKdMiwNqqofQgbxZER2TVMaLX7K",
"5DCdVZpFv6uMvXZDgPjvq47crKS5abVFCUfmfgXYZs2Seu8W",
"5DDKJxdjrMWL8AJF9xZmpjkseLVJCjTBqxFM15Kjndv2Bojr",
"5Dc3F4sUqWn7ntf9tnrNgk6R528o59TsHrstgjohJDXtYN63",
"5DrNYsps2JJH4wfrpfnSvmLV2ZoaCY4cCGKRNV36PdTBiFyK",
"5DwjEBxvtJCjYVRjcNWiRE93a8Yr6g725iHHmBfUDjwqNef5",
"5E2vguriAEWW2VZ8itKPw4LTcbHKA5LYm8TP65Ty7LncYp4K"
]
}
},
"background": []
}
}
Offchain Storage:
offchain_localStorageGet
Gets data from local offchain 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>: The storage kind, which defines the namespace. Common kinds include:PERSISTENT: Data that persists across restarts.LOCAL: Data stored only in memory.
-
<string>: The storage key to retrieve, typically hex-encoded or UTF-8 string depending on use case.
-
Returns
<string|null>:- A hex-encoded value stored under the provided key and storage kind, if it exists.
- null if no value is associated with the given 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": "offchain_localStorageGet",
"params": [
"PERSISTENT", // storage kind
"0x1234567890abcdef" // key to retrieve
]
}'
Response example
{
"jsonrpc": "2.0",
"id": 1,
"result": "0x68656c6c6f" // hex-encoded value
}
offchain_localStorageSet
Stores data in local offchain 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>: The storage kind, which defines the namespace. Common kinds include:PERSISTENT: Data that persists across restarts.LOCAL: Data stored only in memory.
-
<string>: The storage key to set, typically hex-encoded or UTF-8 string depending on use case. -
<string>: The storage value to store, hex-encoded.
-
Returns
<null>:- Returns null if the operation is successful.
- Errors are returned if the node cannot write to offchain storage or if the method is restricted (common on public RPC endpoints).
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": "offchain_localStorageSet",
"params": [
"PERSISTENT", // storage kind
"0x1234567890abcdef", // key to set
"0x68656c6c6f" // value to store
]
}'
Response example
{
"jsonrpc": "2.0",
"id": 1,
"result": null
}
Archive & Unstable Chain Access:
archive_unstable_body
Fetches block body for historical blocks.
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>(block hash): The hash of the block whose body (list of extrinsics) should be retrieved.
Returns
-
<array<string>>: An array of hex-encoded extrinsics contained in the block body.- Each string is a SCALE-encoded extrinsic represented in hexadecimal.
- If the block has no extrinsics, an empty array is returned.
-
null: Returned if the specified block hash does not exist or cannot be accessed.
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": "archive_unstable_body",
"params": [
"0xabc123abc123abc123abc123abc123abc123abc123abc123abc123abc123abc1"
]
}'
Response example
{
"jsonrpc": "2.0",
"id": 1,
"result": [
"0x280403000b009cbe..." ,
"0x1c0200000500d2a4..."
]
}
archive_unstable_call
Executes a runtime call at a specific block height.
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>: The name of the runtime function to call (e.g.,Balances_freeBalance).<string>: A hex-encoded SCALE-encoded parameter payload for the runtime function (can be0xif no parameters).<string>: The block hash at which to execute the call.
Returns
<string>(hex): The hex-encoded SCALE-encoded result of the runtime function call executed at the specified block.null: Returned if the block does not exist, the runtime function is unknown, or execution fails.
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": "archive_unstable_call",
"params": [
"Balances_freeBalance", // runtime function to call
"0x1cbd2d1b6d8a54b6208b1e5d5ba3f9a3", // SCALE-encoded params (mock data)
"0xabc123abc123abc123abc123abc123abc123abc123abc123abc123abc123abc1" // block hash
]
}'
Response example
{
"jsonrpc": "2.0",
"id": 1,
"result": "0x00000000000000000000000000000064"
}
archive_unstable_finalizedHeight
Returns the finalized block height.
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>: The height (block number) of the latest finalized block in the archive, returned as a string representing an unsigned integer.
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": "archive_unstable_finalizedHeight",
"params": []
}'
Response example
{
"id": 1,
"jsonrpc": "2.0",
"result": 995341
}
archive_unstable_genesisHash
Returns the genesis 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>: The hash of the genesis block of the chain, returned as a hex-encoded string.
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": "archive_unstable_genesisHash",
"params": []
}'
Response example
{
"id": 1,
"jsonrpc": "2.0",
"result": "0x2757396f0837b1c8f52d6c16887f0d4b39c9bca5462b774a86570fb82701040b"
}
archive_unstable_hashByHeight
Returns the block hash at a specific height.
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):<integer>: The block height (number) for which to retrieve the block hash.
Returns
<string|null>:- A hex-encoded block hash corresponding to the specified block height if it exists.
nullif no block is found at the given height or the archive does not have that block stored.
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": "archive_unstable_hashByHeight",
"params": [
981031
]
}'
Response example
{
"id": 1,
"jsonrpc": "2.0",
"result": [
"0x87f5c08ba8334e4ee1642ff9646e94dd46080b71fff03714be8b36f22e481b95"
]
}
archive_unstable_header
Fetches block header from archive.
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>(block hash): The hash of the block for which the header should be retrieved.
Returns
<object|null>: The block header object or null if the block hash does not exist.
Typical block header fields include:
parentHash(string): The hash of the parent block.number(string): The block number (in hex).stateRoot(string): The root of the state trie after executing this block.extrinsicsRoot(string): The root hash of the block’s extrinsics.digest(object): Consensus-specific digest items, such as logs from BABE or GRANDPA.
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": "archive_unstable_header",
"params": [
"0xabc123abc123abc123abc123abc123abc123abc123abc123abc123abc123abc1"
]
}'
Response example
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"parentHash": "0xdef456def456def456def456def456def456def456def456def456def456def4",
"number": "0x0f0f0f",
"stateRoot": "0xaaaabbbbccccddddeeeeffff1111222233334444555566667777888899990000",
"extrinsicsRoot": "0xbbbbccccddddeeeeffff0000111122223333444455556666777788889999aaaa",
"digest": {
"logs": [
"0x0642414245fc"
]
}
}
}
archive_unstable_storage
Returns historical storage values.
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>: The storage key to query (hex-encoded).<string>: The block hash at which to read the storage value.
Returns
<string|null>:- The hex-encoded SCALE-encoded value stored under the given key at the specified block.
- 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": "archive_unstable_storage",
"params": [
"0x1a2b3c4d5e6f", // storage key
"0xabc123abc123abc123abc123abc123abc123abc123abc123abc123abc123abc1" // block hash
]
}'
Response example
{
"jsonrpc": "2.0",
"id": 1,
"result": "0x01020304"
}
Sidechain & Midnight-specific:
midnight_apiVersions
Lists supported API versions for the Midnight node.
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
<array<object>>: A list of available API versions supported by the Midnight node. Each object typically contains:api(string): The name of the RPC API (e.g., "chain", "state", "system").version(number): The supported version number for that API.
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": "midnight_apiVersions",
"params": []
}'
Response example
{
"id": 1,
"jsonrpc": "2.0",
"result": [
2
]
}
midnight_contractState
Fetches the on-chain state of a specific Midnight contract.
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>: The contract address whose state is being queried.<string>: The block hash at which to retrieve the contract state (optional depending on implementation; may uselatestor be omitted for the latest state).
Returns
-
<object>: The current state of the specified contract, which may include:storage(object): Key-value pairs of the contract’s storage slots (hex-encoded keys and values).metadata(object, optional): Information about the contract (e.g., ABI hash, deployment block).
-
null: Returned if the contract does not exist or no state is available at the given block hash.
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": "midnight_contractState",
"params": [
"0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef", // contract address
"0xabc123abc123abc123abc123abc123abc123abc123abc123abc123abc123abc1" // block hash
]
}'
Response example
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"storage": {
"0x0000": "0x01020304",
"0x0001": "0x0a0b0c0d"
},
"metadata": {
"deployedAt": "0xabc123abc123abc123abc123abc123abc123abc123abc123abc123abc123abc1"
}
}
}
midnight_decodeEvents
Decodes event data emitted by Midnight smart contracts.
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>: The block hash for which to decode events.<string>: The raw events data (hex-encoded SCALE-encoded bytes) typically obtained from chain storage (system.events).
Returns
<array<object>>: A list of decoded events from the specified block. Each event object typically includes:section(string): The pallet/module name that emitted the event (e.g.,balances).method(string): The specific event name (e.g.,Transfer).data(array<any>): Event parameters, decoded according to the runtime metadata.topics(array<string>, optional): Event topics, if applicable.
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": "midnight_decodeEvents",
"params": [
"0xabc123abc123abc123abc123abc123abc123abc123abc123abc123abc123abc1", // block hash
"0x01020304aabbccdd" // raw events data
]
}'
Response example
{
"jsonrpc": "2.0",
"id": 1,
"result": [
{
"section": "balances",
"method": "Transfer",
"data": [
"5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY",
"5FHneW46xGXgs5mUiveU4sbTyGBzmstT8dQ8x6b8S1uZxZ8M",
1000000000000
]
},
{
"section": "system",
"method": "ExtrinsicSuccess",
"data": []
}
]
}
midnight_jsonBlock
Returns a full block in a JSON format.
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>: The block hash of the block to retrieve in JSON format.
Returns
<object|null>: A JSON representation of the specified block, or null if the block does not exist.
Typical fields include:
-
block:header: Standard block header fields:parentHash(string): The parent block hash.number(string): Block number (in hex).stateRoot(string): State trie root.extrinsicsRoot(string): Extrinsics trie root.digest(object): Consensus-specific digest logs.extrinsics: (array<string>): List of extrinsics included in the block.
-
justifications(array, optional): GRANDPA justifications 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": "midnight_jsonBlock",
"params": [
"0x3cc34cd9d6a758999d66e977779b0d2f3bbeeb83fcd8dc8a361e7fe76905f0c6"
]
}'
Response example
{
"id": 1,
"jsonrpc": "2.0",
"result": "{\"header\":{\"parentHash\":\"0x62975104b79de4cb21a747c6edbd590fb4226eb51bcaa16e008b8528252731a7\",\"number\":\"0xf315b\",\"stateRoot\":\"0xd4962bed8eac446b29a3a5128bac1f0dc873355f1341e87120f2f4ee1ae67077\",\"extrinsicsRoot\":\"0x7e3b01b1f843be8994081418391ced306dd5e5cb03977bb292739b943942ef4c\",\"digest\":{\"logs\":[\"0x06617572612055426b1100000000\",\"0x066d63736880593d93a5de83054c0383f8e2e9e13209afb622807b8675b7d39b8a471d282bc6\",\"0x044d4e535610e02e0000\",\"0x056175726101012ca4b4d8924f801071b84d836cf248ee979b2c26021ff3f02123768fe20dd539701edf4a75062884f555b0894d23fd9a4b0333e6489cf23d496adb4d2a8e3480\"]}},\"body\":[{\"Timestamp\":1753452030000},\"UnknownTransaction\"],\"transactions_index\":[]}"
}
midnight_jsonContractState
Returns human-readable JSON format of contract state.
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>: The contract address whose state should be retrieved.<string>: The block hash at which to query the state (optional in some implementations; if omitted, the latest state may be returned).
Returns
<string|null>: A JSON object encoded as a string representing the contract state or null if no state is available.
The JSON string (when parsed) typically contains:
storage: Key-value pairs for the contract’s storage slots (hex-encoded).metadata: Optional information about the contract such as ABI or deployment details.
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": "midnight_jsonContractState",
"params": [
"0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef", // contract address
"0xabc123abc123abc123abc123abc123abc123abc123abc123abc123abc123abc1" // block hash
]
}'
Response example
{
"jsonrpc": "2.0",
"id": 1,
"result": "{\"storage\":{\"0x0000\":\"0x01020304\",\"0x0001\":\"0x0a0b0c0d\"},\"metadata\":{\"deployedAt\":\"0xabc123...\"}}"
}
midnight_zswapChainState
Returns ZSwap contract state information.
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>: ZSwap contract address (hex-encoded). This must be a valid deployed ZSwap contract address.<string>(optional): Block hash at which to query the chain state. If omitted, defaults to the latest block.
Returns
<string|null>: A JSON object encoded as a string representing the ZSwap chain state, or null if no data is available.
The decoded JSON string typically contains information such as:
pools: Active liquidity pools and their parameters.tokens: Supported tokens and balances.
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": "midnight_zswapChainState",
"params": [
"0x<zswap_contract_address>"
]
}'
Response example
{
"jsonrpc": "2.0",
"id": 1,
"result": "{\"pools\":[{\"id\":1,\"tokenA\":\"ZUSD\",\"tokenB\":\"ZBTC\",\"liquidity\":\"1000000000\"}],\"parameters\":{\"fee\":\"0.003\"}}"
}
sidechain_getAriadneParameters
Gets Ariadne protocol parameters used for privacy.
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):<integer>(u32; required): Epoch ID (must be greater than or equal to the minimum supported epoch, which is usually 2 on testnet).
Returns
<object>: A set of Ariadne protocol parameters used by the Midnight sidechain. Typical fields may include (structure depends on the node implementation):epochLength(number): Number of blocks per epoch.committeeSize(number): Number of validators in the Ariadne committee.finalityThreshold(number): Threshold required for finality (e.g., percentage or quorum count).otherParams(object): Any additional Ariadne-specific configuration values.
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": "sidechain_getAriadneParameters",
"params": [<integer>]
}'
Response example
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"epochLength": 100,
"committeeSize": 21,
"finalityThreshold": 15,
"otherParams": {
"rewardRate": "0.05",
"slashRatio": "0.02"
}
}
}
sidechain_getEpochCommittee
Returns the validator committee for the current or given epoch.
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):<integer>: The epoch number (u32) for which to retrieve the committee information.
Returns
<object>: Committee information for the specified epoch. Fields:sidechainEpoch(number): The sidechain epoch number queried.committee(array<object>): A list of committee members, where each object contains:
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": "sidechain_getEpochCommittee",
"params": [
243000
]
}'
Response example
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"sidechainEpoch": 243000,
"committee": [
{
"sidechainPubKey": "0x0203ae55458c8b9123b37a61ddd7f2a334ff35a80385825a2265eb490688cdebc5"
},
{
"sidechainPubKey": "0x0250159344a81b11aa21d9b4d2b5f24000682a95eb6564caccfe67b96ade9e202a"
}
]
}
}
sidechain_getParams
Fetches current configuration parameters for the sidechain.
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>: Sidechain parameters object.genesis_utxo(string): Identifier of the genesis UTXO (Unspent Transaction Output) in the sidechain, including the transaction hash and output index (e.g., "46876a22...b11#0").
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": "sidechain_getParams",
"params": []
}'
Response example
{
"id": 1,
"jsonrpc": "2.0",
"result": {
"genesis_utxo": "46876a2250ec0e523eccc30b0fc6d6fa55c61dd200b83140acaab291edeb0b11#0"
}
}
sidechain_getStatus
Returns current sidechain status including sync state and parameters.
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>: Contains the status of both the sidechain and the mainchain. Fields:-
sidechain(object): Status information for the Midnight sidechain.epoch(number): Current sidechain epoch number.slot(number): Current sidechain slot number.nextEpochTimestamp(number): UNIX timestamp (ms) for the start of the next sidechain epoch.
-
mainchain(object): Status information for the connected mainchain.epoch(number): Current mainchain epoch number.slot(number): Current mainchain slot number.nextEpochTimestamp(number): UNIX timestamp (ms) for the start of the next mainchain epoch.
-
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": "sidechain_getStatus",
"params": []
}'
Response example
{
"id": 1,
"jsonrpc": "2.0",
"result": {
"sidechain": {
"epoch": 243570,
"slot": 292285076,
"nextEpochTimestamp": 1753711200000
},
"mainchain": {
"epoch": 1007,
"slot": 87054433,
"nextEpochTimestamp": 1753747200000
}
}
}
Child State Access:
childstate_getKeys
Returns the keys 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>: Key prefix (hex-encoded) to filter keys. Use0xfor all keys.<string>: Block hash at which to query state. If omitted, defaults to the latest block.
Returns
<array<string>>: An array of keys (hex-encoded) stored under the specified child storage, filtered by the provided key prefix.[]: Returned if there are no keys matching the given prefix.null: Returned if the child storage 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_getKeys",
"params": [
"0x1a2b3c4d5e6f", // child storage key
"0x", // key prefix (empty to get all keys)
"0xabc123abc123abc123abc123abc123abc123abc123abc123abc123abc123abc1" // block hash
]
}'
Request example
{
"jsonrpc": "2.0",
"id": 1,
"result": [
"0x1a2b3c4d5e6f0011",
"0x1a2b3c4d5e6f0022",
"0x1a2b3c4d5e6f0033"
]
}
childstate_getKeysPaged
Returns paged keys 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>: Key prefix (hex-encoded) to filter keys. Use "0x" for 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>: Block hash at which to query state. If omitted, defaults to the latest block.
Returns
<array<string>>: A list of child storage keys (hex-encoded) matching the given prefix and pagination parameters.[]: Returned if no keys match the given prefix or pagination window.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_getKeysPaged",
"params": [
"0x1a2b3c4d5e6f", // child storage key
"0x", // key prefix (empty = all keys)
10, // 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",
"0x1a2b3c4d5e6f0044"
]
}
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"
}