system_chain
Description#
Reports the human-readable name of the chain the node is serving. Use this to confirm you are connected to Astar mainnet versus Shiden or Shibuya before broadcasting extrinsics.
Parameters#
This method does not require any parameters.
Returns#
| Type | Description |
|---|---|
| string | Chain name (for example Astar, Shiden, or Shibuya) |
Request Example#
{
"jsonrpc": "2.0",
"method": "system_chain",
"params": [],
"id": 1
}
Response Example#
{
"jsonrpc": "2.0",
"result": "Astar",
"id": 1
}
Code Examples#
- cURL
- Python
- JavaScript
curl https://api-astar.n.dwellir.com/YOUR_API_KEY \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "system_chain",
"params": [],
"id": 1
}'
import requests
import json
resp = requests.post(
"https://api-astar.n.dwellir.com/YOUR_API_KEY",
headers={"Content-Type": "application/json"},
data=json.dumps({
"jsonrpc": "2.0",
"method": "system_chain",
"params": [],
"id": 1
})
)
print(resp.json()["result"])
import { ApiPromise, WsProvider } from '@polkadot/api';
const api = await ApiPromise.create({
provider: new WsProvider('wss://api-astar.n.dwellir.com/YOUR_API_KEY')
});
const chain = await api.rpc.system.chain();
console.log('Connected to', chain.toString());