system_chain
Description
Returns the human-readable name of the chain the node is connected to. Use this method during bootstrap to verify whether your endpoint targets Bifrost on Polkadot (Bifrost
) or the Kusama canary deployment (Bifrost Canary
).
Parameters
This method does not require parameters.
Returns
Field | Type | Description |
---|---|---|
result | string | Chain name string (e.g., Bifrost ) |
Request Example
{
"jsonrpc": "2.0",
"method": "system_chain",
"params": [],
"id": 1
}
Response Example
{
"jsonrpc": "2.0",
"result": "Bifrost",
"id": 1
}
Code Examples
JavaScript (polkadot.js)
import { ApiPromise, WsProvider } from '@polkadot/api';
const provider = new WsProvider('wss://api-bifrost-polkadot.n.dwellir.com/YOUR_API_KEY');
const api = await ApiPromise.create({ provider });
const chainName = await api.rpc.system.chain();
console.log('Connected chain:', chainName.toString());
Python (py-substrate-interface)
from substrateinterface import SubstrateInterface
substrate = SubstrateInterface(
url="wss://api-bifrost-polkadot.n.dwellir.com/YOUR_API_KEY"
)
print("Connected chain:", substrate.chain)
Rust (subxt)
use subxt::{config::substrate::SubstrateConfig, OnlineClient};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let api = OnlineClient::<SubstrateConfig>::from_url(
"wss://api-bifrost-polkadot.n.dwellir.com/YOUR_API_KEY"
).await?;
let chain = api.rpc().system_chain().await?;
println!("Connected chain: {}", chain);
Ok(())
}
Tips
- Kusama canary nodes return
Bifrost Canary
. Swap to the canary endpoint when staging runtime upgrades or Hyperbridge changes. - Pair
system_chain
withsystem_properties
(token decimals, SS58 prefix) for comprehensive environment detection.