system_chainType - JSON-RPC Method
Description#
Returns the chain type classification for the Moonbase Alpha network. This method identifies whether the connected node is running on a live production network, development testnet, or local instance. The chain type is crucial for determining the appropriate security considerations, testing strategies, and deployment configurations for your applications.
Parameters#
This method does not require any parameters.
Returns#
| Field | Type | Description |
|---|---|---|
result | string | Chain type identifier (e.g., "Live", "Development", "Local") |
Common Chain Types#
- Live: Production mainnet environment
- Development: Public testnet or development network
- Local: Local development node
Use Cases#
- Environment Detection: Automatically configure application behavior based on network type
- Security Configuration: Apply stricter validation and security measures for live networks
- Feature Flags: Enable or disable experimental features based on chain environment
- Testing Workflows: Verify deployment targets before executing transactions
- CI/CD Pipeline: Validate correct network connections in automated deployments
- User Warnings: Display appropriate warnings when connected to development networks
Request Example#
curl -X POST https://api-moonbase-alpha.n.dwellir.com/YOUR_API_KEY \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":1,"method":"system_chainType","params":[]}'
Response Example#
{
"jsonrpc": "2.0",
"result": "Development",
"id": 1
}
Code Examples#
JavaScript (polkadot.js)#
import { ApiPromise, WsProvider } from '@polkadot/api';
const api = await ApiPromise.create({
provider: new WsProvider('wss://api-moonbase-alpha.n.dwellir.com/YOUR_API_KEY')
});
const chainType = await api.rpc.system.chainType();
console.log(`Chain type: ${chainType.toString()}`);
Python#
import requests
import json
def get_chain_type():
url = "https://api-moonbase-alpha.n.dwellir.com/YOUR_API_KEY"
payload = {
"jsonrpc": "2.0",
"method": "system_chainType",
"params": [],
"id": 1
}
response = requests.post(url, json=payload)
return response.json()["result"]
chain_type = get_chain_type()
print(f"Connected to {chain_type} network")
Best Practices#
- Cache the chain type result during application initialization
- Use chain type to conditionally enable debug logging and verbose error messages
- Implement environment-specific transaction limits and confirmation requirements
- Display clear visual indicators in UI for development vs. production networks
Related Methods#
system_chain- Get the chain namesystem_name- Get node implementation namesystem_properties- Get chain properties