# system_chain - Manta Atlantic RPC Method

Returns the chain name of the Manta Atlantic network. This identifies the specific chain or network the node is connected to (e.g., `"Polkadot"`, `"Kusama"`, `"Westend"`).

> **Why Manta Atlantic?** Build on the ZK Layer 1 on Polkadot enabling private transactions and on-chain compliance identities with zkSNARK-powered privacy, modular compliance identities, MANTA token staking hub, and end-to-end transaction privacy.

## When to Use This Method

`system_chain` is essential for privacy-focused developers, DeFi builders requiring private swaps, and teams needing zkSNARK capabilities:

- **Network Verification** -- Confirm your application is connected to the correct Manta Atlantic 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 private asset transfers, zkNFTs, on-chain compliance identities, and private parachain asset 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_properties` for 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

## Request Parameters

This method accepts no parameters.

## Request Example

```json
{
  "jsonrpc": "2.0",
  "method": "system_chain",
  "params": [],
  "id": 1
}
```

## Response Fields

- `result` (`String, required`): The human-readable chain name (e.g., "Polkadot", "Kusama", "Acala")

## Successful Response

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": "Manta Atlantic"
}
```

## Error Responses

### Error Response

- Code: `-32603`

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "error": {
    "code": -32603,
    "message": "Internal error"
  }
}
```

## Code Examples

cURL
JavaScript
Python
Rust

```bash
curl -X POST https://api-manta-atlantic-mainnet.n.dwellir.com/YOUR_API_KEY \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "method": "system_chain",
    "params": [],
    "id": 1
  }'
```

```javascript
// Using @polkadot/api
import { ApiPromise, WsProvider } from '@polkadot/api';

const provider = new WsProvider('wss://api-manta-atlantic-mainnet.n.dwellir.com/YOUR_API_KEY');
const api = await ApiPromise.create({ provider });

const chain = await api.rpc.system.chain();
console.log('Connected to chain:', chain.toString());

await api.disconnect();

// Using fetch (HTTP JSON-RPC)
const response = await fetch('https://api-manta-atlantic-mainnet.n.dwellir.com/YOUR_API_KEY', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    jsonrpc: '2.0',
    method: 'system_chain',
    params: [],
    id: 1
  })
});

const { result } = await response.json();
console.log('Connected to chain:', result);
```

```python
import requests

def get_chain_name():
    response = requests.post(
        'https://api-manta-atlantic-mainnet.n.dwellir.com/YOUR_API_KEY',
        json={
            'jsonrpc': '2.0',
            'method': 'system_chain',
            'params': [],
            'id': 1
        }
    )
    return response.json()['result']

chain = get_chain_name()
print(f'Connected to chain: {chain}')

# Using substrate-interface
from substrateinterface import SubstrateInterface

substrate = SubstrateInterface(url='wss://api-manta-atlantic-mainnet.n.dwellir.com/YOUR_API_KEY')
chain = substrate.rpc_request('system_chain', [])['result']
print(f'Connected to chain: {chain}')
```

```rust
use serde_json::json;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = reqwest::Client::new();
    let response = client
        .post("https://api-manta-atlantic-mainnet.n.dwellir.com/YOUR_API_KEY")
        .json(&json!({
            "jsonrpc": "2.0",
            "method": "system_chain",
            "params": [],
            "id": 1
        }))
        .send()
        .await?;

    let result: serde_json::Value = response.json().await?;
    println!("Connected to chain: {}", result["result"]);
    Ok(())
}
```

## Common Use Cases

### 1. Network Connection Verification

Validate that your application connects to the correct chain before processing any transactions:

```javascript
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-manta-atlantic-mainnet.n.dwellir.com/YOUR_API_KEY', 'Manta Atlantic');
```

### 2. Multi-Chain Router

Route operations based on detected chain identity:

```javascript
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:

```javascript
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()
  };
}
```

## Related Methods

- [`system_name`](https://www.dwellir.com/docs/manta-atlantic/system_name) -- Get the node implementation name
- [`system_version`](https://www.dwellir.com/docs/manta-atlantic/system_version) -- Get the node implementation version
- [`system_properties`](https://www.dwellir.com/docs/manta-atlantic/system_properties) -- Get chain properties (token symbol, decimals, SS58 format)
- [`state_getRuntimeVersion`](https://www.dwellir.com/docs/manta-atlantic/state_getRuntimeVersion) -- Get the on-chain runtime version
- [`rpc_methods`](https://www.dwellir.com/docs/manta-atlantic/rpc_methods) -- List all available RPC methods
