system_chain - FLOP RPC Method
Get the chain name on FLOP. Essential for network identification, multi-chain applications, and verifying the correct network connection.
FLOP RPC endpoint: endpoint URLs, plans and pricing.
Returns the chain name of the FLOP network. This identifies the specific chain or network the node is connected to (e.g., "Polkadot", "Kusama", "Westend").
Why FLOP? Build on the Substrate Proof of Inference Layer 1 built for autonomous AI agents with Proof of Inference with TOPLOC activation commitments, full historical archive state from genesis, and JSON-RPC v2 archive and chainHead APIs.
When to Use This Method
system_chain is essential for AI agent builders, FLOP miners, indexers, and Substrate developers:
- Network Verification -- Confirm your application is connected to the correct FLOP network before processing transactions
- Multi-Chain Applications -- Dynamically identify which Substrate chain you are interacting with in cross-chain or multi-network dApps
- UI Display -- Show the connected network name in wallet interfaces and dashboards for Proof of Inference settlement, 1-second BABE blocks with AlephBFT finality, archive state queries, and HTLC atomic swaps
- Configuration Validation -- Verify endpoint configuration matches the expected chain during deployment
Best Practices
- Cache the chain name at startup -- it does not change during a session
- Use with
system_propertiesfor complete chain identification (name, token, decimals) - Chain name is a simple string identifier, not a unique numeric ID
- For multi-chain applications, maintain a mapping of chain names to app configuration
{
"jsonrpc": "2.0",
"method": "system_chain",
"params": [],
"id": 1
}Code Examples
curl -X POST https://api-flop-testnet.n.dwellir.com/YOUR_API_KEY \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "system_chain",
"params": [],
"id": 1
}'Common Use Cases
1. Network Connection Verification
Validate that your application connects to the correct chain before processing any transactions:
import { ApiPromise, WsProvider } from '@polkadot/api';
async function connectAndVerify(endpoint, expectedChain) {
const provider = new WsProvider(endpoint);
const api = await ApiPromise.create({ provider });
const chain = await api.rpc.system.chain();
const chainName = chain.toString();
if (chainName !== expectedChain) {
await api.disconnect();
throw new Error(
`Expected "${expectedChain}" but connected to "${chainName}"`
);
}
console.log(`Verified connection to ${chainName}`);
return api;
}
// Usage
const api = await connectAndVerify('https://api-flop-testnet.n.dwellir.com/YOUR_API_KEY', 'FLOP');2. Multi-Chain Router
Route operations based on detected chain identity:
async function getChainConfig(api) {
const [chain, properties] = await Promise.all([
api.rpc.system.chain(),
api.rpc.system.properties()
]);
const chainName = chain.toString();
const configs = {
Polkadot: { explorer: 'https://polkadot.subscan.io', confirmations: 1 },
Kusama: { explorer: 'https://kusama.subscan.io', confirmations: 1 },
};
const config = configs[chainName] || { explorer: null, confirmations: 1 };
return {
name: chainName,
tokenSymbol: properties.tokenSymbol.toString(),
tokenDecimals: properties.tokenDecimals.toJSON(),
...config
};
}3. Health Check with Chain Identity
Include chain identity in health-check monitoring:
async function healthCheck(api) {
const [chain, name, version] = await Promise.all([
api.rpc.system.chain(),
api.rpc.system.name(),
api.rpc.system.version()
]);
return {
status: 'healthy',
chain: chain.toString(),
nodeImplementation: name.toString(),
nodeVersion: version.toString(),
timestamp: new Date().toISOString()
};
}Error Handling
Common errors and solutions:
| Error Code | Description | Solution |
|---|---|---|
| -32603 | Internal error | Node may be starting up -- retry after delay |
| -32005 | Rate limit exceeded | Reduce request frequency or implement client-side rate limiting |
| Connection refused | Node unreachable | Verify the RPC endpoint URL and that the node is running |
Related Methods
system_name-- Get the node implementation namesystem_version-- Get the node implementation versionsystem_properties-- Get chain properties (token symbol, decimals, SS58 format)state_getRuntimeVersion-- Get the on-chain runtime versionrpc_methods-- List all available RPC methods
system_health
Check node health status on FLOP. Returns peer count, sync status, and connectivity - essential for monitoring, load balancing, and infrastructure management on the Substrate Proof of Inference Layer 1 built for autonomous AI agents.
system_version
Get the node implementation version on FLOP. Essential for compatibility checking, runtime upgrades, and monitoring node deployments across the the Substrate Proof of Inference Layer 1 built for autonomous AI agents network.