Node API
Supported Chains
API Reference
Midnight

Midnight

Midnight API is available on Web3 API platform (opens in a new tab).

Midnight is a data protection-focused sidechain of Cardano, designed to support confidential smart contracts and zero-knowledge (ZK) technology. Developed by IOG (Input Output Global)—the same team behind Cardano—Midnight aims to bring privacy-preserving decentralized applications (dApps) to Web3.

Key Features:

  • Confidential Smart Contracts: Written in TypeScript, supporting zero-knowledge (ZK) privacy by default.
  • Zero-Knowledge Proofs (ZKPs): Enable validation without revealing sensitive data.
  • Privacy-First Architecture: Built for data protection and regulatory compliance (example: GDPR).
  • Selective Disclosure: Users can choose what information to share and with whom.
  • Cardano's Sidechain: Interoperable with Cardano, using ADA and its wrapped token DUST.
  • Custom PoS Consensus: A privacy-aware Proof-of-Stake mechanism tailored for Midnight.

Midnight is at a Testnet stage, providing a stable sandbox environment to develop commercially successful on-chain applications that benefit from the transparency of a blockchain while addressing granular data protection needs.

In order for your Web3 application to interact with Midnight — either by reading blockchain data or sending transactions to the network — it must connect to a Midnight node. Developers interact with the blockchain using the methods provided by the API.

Midnight supports JSON-RPC methods for API interaction. Responses come in JSON format (opens in a new tab).

JSON-RPC methods

System Info & Networking:

Accounts & Keys:

Grandpa Finality:

Offchain Storage:

Archive & Unstable Chain Access:

Sidechain & Midnight-specific:

Child State Access:

RPC Meta:

  • rpc_methods — Returns a list of all available RPC methods.

Chain & Block Data:

State & Storage:


System Info & Networking:

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/ \
  -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/ \
  -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/ \
  -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/ \
  -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/ \
  -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/ \
  -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/ \
  -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/ \
  -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/ \
  -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/ \
  -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):

    1. <string>: The storage kind, which defines the namespace. Common kinds include:

      • PERSISTENT: Data that persists across restarts.
      • LOCAL: Data stored only in memory.
    2. <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/ \
  -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):

    1. <string>: The storage kind, which defines the namespace. Common kinds include:

      • PERSISTENT: Data that persists across restarts.
      • LOCAL: Data stored only in memory.
    2. <string>: The storage key to set, typically hex-encoded or UTF-8 string depending on use case.

    3. <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/ \
  -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/ \
  -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):

    1. <string>: The name of the runtime function to call (e.g., Balances_freeBalance).
    2. <string>: A hex-encoded SCALE-encoded parameter payload for the runtime function (can be 0x if no parameters).
    3. <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/ \
  -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/ \
  -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/ \
  -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.
    • null if 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/ \
  -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/ \
  -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):

    1. <string>: The storage key to query (hex-encoded).
    2. <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/ \
  -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/ \
  -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):

    1. <string>: The contract address whose state is being queried.
    2. <string>: The block hash at which to retrieve the contract state (optional depending on implementation; may use latest or 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/ \
  -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):

    1. <string>: The block hash for which to decode events.
    2. <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/ \
  -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/ \
  -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):

    1. <string>: The contract address whose state should be retrieved.
    2. <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/ \
  -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):

    1. <string>: ZSwap contract address (hex-encoded). This must be a valid deployed ZSwap contract address.
    2. <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/ \
  -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/ \
  -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/ \
  -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/ \
  -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/ \
  -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):

    1. <string>: Child storage key (hex-encoded) identifying the child storage.
    2. <string>: Key prefix (hex-encoded) to filter keys. Use 0x for all keys.
    3. <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/ \
  -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):

    1. <string>: Child storage key (hex-encoded) identifying the child storage.
    2. <string>: Key prefix (hex-encoded) to filter keys. Use "0x" for all keys.
    3. <number>: Count — the maximum number of keys to return.
    4. <string>: Start key (hex-encoded) for pagination. Use "0x" or omit to start from the beginning.
    5. <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/ \
  -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):

    1. <string>: Child storage key (hex-encoded) identifying the child storage.
    2. <string>: Key prefix (hex-encoded) to filter keys. Use "0x" to match all keys.
    3. <number>: Count — the maximum number of keys to return.
    4. <string>: Start key (hex-encoded) for pagination. Use "0x" or omit to start from the beginning.
    5. <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/ \
  -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):

    1. <string>: Child storage key (hex-encoded) identifying the child storage.
    2. <string>: Storage key (hex-encoded) to fetch the value for.
    3. <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.
    • null if 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/ \
  -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):

    1. <string>: Child storage key (hex-encoded) identifying the child storage.
    2. <array<string>>: Storage keys (hex-encoded) for which values should be fetched.
    3. <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/ \
  -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):

    1. <string>: Child storage key (hex-encoded) identifying the child storage.
    2. <string>: Storage key (hex-encoded) for which to retrieve the hash.
    3. <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.
    • null if 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/ \
  -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"
}

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/ \
  -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/ \
  -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/ \
  -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/ \
  -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/ \
  -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/ \
  -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/ \
  -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/ \
  -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/ \
  -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/ \
  -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/ \
  -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/ \
  -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/ \
  -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/ \
  -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/ \
  -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/ \
  -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/ \
  -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/ \
  -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/ \
  -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/ \
  -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/ \
  -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/ \
  -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/ \
  -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/ \
  -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
                ]
            ]
        }
    ]
}