L0vdL0vd

eth_chainId

Returns the chain ID used for signing (EIP-155). Use it to check you are on the right network.

curl https://eth.l0vdinfra.com/YOUR_KEY \
  -X POST \
  -H "Content-Type: application/json" \
  --data '{"jsonrpc":"2.0","id":1,"method":"eth_chainId","params":[]}'

响应示例

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": "0x1"
}
参数与您的端点

参数

此方法没有参数。

返回值

string Chain ID, hex: "0x1" for Ethereum mainnet.

适用场景

Confirm which network an endpoint serves before signing or writing data.

如何解读结果

Hex chain ID: "0x1" Ethereum, "0xa4b1" Arbitrum One, "0x38" BNB Chain, "0x89" Polygon, "0x2105" Base, "0xa" OP Mainnet, "0xa86a" Avalanche C-Chain.

提示

  • Check it at startup and refuse to run if it does not match your config.

相关方法