eth_chainId

返回当前的链 ID,该值用于 EIP-155 引入的受重放保护的交易签名。

Request

curl https://eth-mainnet.solarpath.io/v1/YOUR-API-KEY \
    -X POST \
    -H "Content-Type: application/json" \
    -d '{"jsonrpc": "2.0", "id": 1, "method": "eth_chainId", "params": []}'

Response

十六进制整数符串,表示当前的链 ID。

{
  "id": 1,
  "jsonrpc": "2.0",
  "result": "0x1"
}

建议使用 eth_chainId 而不是 net_version,这样可以可靠的识别与之通信的链。

最后更新于