curl --request POST \
--url https://hyperliquid-mainnet.core.chainstack.com/4f8d8f4040bdacd1577bff8058438274/evm \
--header 'Content-Type: application/json' \
--data '{
"jsonrpc": "2.0",
"method": "net_version",
"params": [],
"id": 1
}'
{
"jsonrpc": "2.0",
"id": 1,
"result": "998"
}
Returns the current network ID. This method is used to identify which Ethereum network the client is connected to.
curl --request POST \
--url https://hyperliquid-mainnet.core.chainstack.com/4f8d8f4040bdacd1577bff8058438274/evm \
--header 'Content-Type: application/json' \
--data '{
"jsonrpc": "2.0",
"method": "net_version",
"params": [],
"id": 1
}'
{
"jsonrpc": "2.0",
"id": 1,
"result": "998"
}
"998"
.
const getNetworkVersion = async () => {
const response = await fetch('https://hyperliquid-mainnet.core.chainstack.com/YOUR_API_KEY/evm', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
jsonrpc: '2.0',
method: 'net_version',
params: [],
id: 1
})
});
const data = await response.json();
return data.result;
};
// Usage
const networkId = await getNetworkVersion();
console.log('Network ID:', networkId); // "998"
// Verify correct network
const isHyperliquid = networkId === '998';
console.log('Connected to Hyperliquid:', isHyperliquid);
const verifyNetwork = async () => {
const networkId = await getNetworkVersion();
if (networkId !== '998') {
throw new Error(`Wrong network. Expected Hyperliquid (998), got ${networkId}`);
}
console.log('Connected to Hyperliquid mainnet');
return true;
};
// Use before important operations
await verifyNetwork();
// Proceed with transactions...
Successful response with network ID
The response is of type object
.