SHYNZ / Documentation

Verify the Connected Network

Read an injected wallet's chain ID without sending a transaction.

Prerequisites

An EVM-compatible browser wallet and a safe page that you trust. This example reads the chain identifier only.

Example

const provider = (window as Window & {
  ethereum?: {
    request(args: { method: string }): Promise<unknown>;
  };
}).ethereum;
 
if (!provider) throw new Error('No browser wallet detected');
 
const chainId = await provider.request({ method: 'eth_chainId' });
if (typeof chainId !== 'string') throw new Error('Unexpected response');
 
console.log('Current chain ID (hex):', chainId);

Interpret results

The chain ID is not enough to establish network legitimacy. Verify the network name, RPC endpoint, and chain configuration using independent sources. This tutorial performs no signing or asset movement.

On this page