POST
/
evm
eth_chainId
curl --request POST \
  --url https://hyperliquid-mainnet.core.chainstack.com/4f8d8f4040bdacd1577bff8058438274/evm \
  --header 'Content-Type: application/json' \
  --data '{
  "jsonrpc": "2.0",
  "method": "eth_chainId",
  "params": [],
  "id": 1
}'
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": "0x3e6"
}
The eth_chainId JSON-RPC method returns the chain ID of the currently connected blockchain network. This method is fundamental for identifying the specific blockchain network, ensuring transaction compatibility, and implementing network-specific logic in applications.
Get your own node endpoint todayStart for free and get your app to production levels immediately. No credit card required.You can sign up with your GitHub, X, Google, or Microsoft account.

Parameters

This method takes no parameters. The params field should be an empty array.

Response

The method returns the chain ID as a hexadecimal string.

Response structure

Chain identification:
  • result — The chain ID as a hexadecimal string (e.g., “0x3e6” which equals 998 in decimal for Hyperliquid)

Chain ID interpretation

Hexadecimal format:
  • Chain IDs are returned in hexadecimal format with “0x” prefix
  • Convert to decimal for human-readable chain identification
  • Example: “0x3e6” = 998 in decimal (Hyperliquid mainnet)
Network identification:
  • Each blockchain network has a unique chain ID
  • Essential for preventing replay attacks across different networks
  • Used by wallets and applications for network validation

Usage example

Basic implementation

// Get Hyperliquid chain ID
const getChainId = async () => {
  const response = await fetch('https://hyperliquid-mainnet.core.chainstack.com/YOUR_ENDPOINT/evm', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      jsonrpc: '2.0',
      method: 'eth_chainId',
      params: [],
      id: 1
    })
  });
  
  const data = await response.json();
  const chainId = parseInt(data.result, 16);
  
  return {
    hex: data.result,
    decimal: chainId,
    network: chainId === 998 ? 'Hyperliquid Mainnet' : 'Unknown'
  };
};

// Verify network connection
const verifyNetwork = async () => {
  const { decimal: chainId, network } = await getChainId();
  
  if (chainId !== 998) {
    throw new Error(`Expected Hyperliquid Mainnet (998), got ${network} (${chainId})`);
  }
  
  console.log(`Connected to ${network}`);
  return true;
};

// Usage
verifyNetwork()
  .then(() => console.log('Network verified'))
  .catch(error => console.error('Network verification failed:', error));

Network identification

Hyperliquid chain ID

Chain details:
  • Chain ID: 998 (0x3e6 in hexadecimal)
  • Network: Hyperliquid Mainnet
  • Used for transaction signing and replay protection
Security considerations:
  • Always verify chain ID matches expected network (998)
  • Chain ID prevents transaction replay across different networks
  • Essential for secure transaction processing on Hyperliquid

Example request

Shell
curl -X POST \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","method":"eth_chainId","params":[],"id":1}' \
  https://hyperliquid-mainnet.core.chainstack.com/4f8d8f4040bdacd1577bff8058438274/evm

Use cases

The eth_chainId method is essential for applications that need to:
  • Network verification: Verify connection to Hyperliquid Mainnet (chain ID 998)
  • Transaction security: Ensure transactions are signed with correct chain ID for replay protection
  • Wallet configuration: Configure wallets to recognize and connect to Hyperliquid
  • Application initialization: Verify network connection during application startup
  • Error handling: Provide meaningful error messages for network mismatches
  • Development tools: Build tools that automatically detect the Hyperliquid network
  • Multi-network applications: Support Hyperliquid alongside other EVM networks
  • Security validation: Validate network before executing sensitive operations

Body

application/json

Response

200 - application/json

Successful response with the chain ID

The response is of type object.