For the complete documentation index, see llms.txt. This page is also available as Markdown.

system_chain - Midnight

Example code for the system_chain JSON-RPC method. Complete guide on how to use system_chain JSON-RPC in GetBlock Web3 documentation.

This method returns the name of the chain the connected node is on. For Midnight testnet-02 the typical value is testnet-02-1. Use it as a basic sanity check that you are connected to the network you expect.

Parameters

  • None

Request Example

curl --location --request POST 'https://go.getblock.io/<ACCESS-TOKEN>/' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "system_chain",
    "params": [],
    "id": "getblock.io"
}'

Response Example

{
    "jsonrpc": "2.0",
    "id": "getblock.io",
    "result": "testnet-02-1"
}

Response Parameters

Field
Type
Description

jsonrpc

string

JSON-RPC protocol version (2.0)

id

string

Request identifier echoed back

result

string

The chain name (e.g. testnet-02-1)

Use Cases

  • Verifying that a client is connected to Midnight testnet-02 rather than another Substrate chain

  • Building dashboards that display the current network name

  • Multi-chain tooling that branches on chain identity

Error Handling

Status Code
Error Message
Cause

403

Forbidden

Missing or invalid <ACCESS-TOKEN>

-32602

Invalid params

Request parameters are missing or malformed

429

Too Many Requests

Rate limit exceeded for your plan

SDK Integration

Last updated

Was this helpful?