Parameters
This method takes no parameters.
Returns
string Chain ID, hex: "0x1" for Ethereum mainnet.
When to use it
Confirm which network an endpoint serves before signing or writing data.
How to read the result
Hex chain ID: "0x1" Ethereum, "0xa4b1" Arbitrum One, "0x38" BNB Chain, "0x89" Polygon, "0x2105" Base, "0xa" OP Mainnet, "0xa86a" Avalanche C-Chain.
Tips
- Check it at startup and refuse to run if it does not match your config.