EXAMPLES
When you are connected to a local node:
cast chain-id
31337
When providing a RPC endpoint URL:
cast chain-id --rpc-url https://rpc.sepolia.org/
11155111
Works with -r too:
cast chain-id -r https://polygon-rpc.com
137
cast chain-id
cast chain-id --rpc-url https://rpc.sepolia.org/
cast chain-id -r https://polygon-rpc.com
cast-chain-id - Get the Ethereum chain ID.
cast chain-id
[options]
Get the Ethereum chain ID from the RPC endpoint we are connected to.
--rpc-url
url
The RPC endpoint. Accepts a URL or an existing alias in the [rpc_endpoints] table, like mainnet
.
Environment: ETH_RPC_URL
-h
--help
Prints help information.
Get the chain ID when talking to $RPC
:
cast chain-id --rpc-url $RPC
Get the chain ID when $ETH_RPC_URL
is set:
cast chain-id