Midnight — system, account, grandpa, offchain, archive, midnight, sidechain, childstate (1/3)
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"
]
}