This repository was archived by the owner on Mar 5, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ getNetworkType
25
25
26
26
Guesses the chain the node is connected by comparing the genesis hashes.
27
27
28
- .. note :: This is not a 100% accurate guess as any private network could use testnet and mainnet genesis blocks and network IDs .
28
+ .. note :: It's recommended to use the :ref:`web3.eth.getChainId <eth-chainId>` method to detect the currently connected chain .
29
29
30
30
-------
31
31
Returns
Original file line number Diff line number Diff line change @@ -1467,3 +1467,31 @@ Example
1467
1467
1468
1468
1469
1469
------------------------------------------------------------------------------
1470
+
1471
+ .. _eth-chainId :
1472
+
1473
+ getChainId
1474
+ ==========
1475
+
1476
+ .. code-block :: javascript
1477
+
1478
+ web3 .eth .getChainId ([callback])
1479
+
1480
+ Returns the chain ID of the current connected node as described in the `EIP-695 <https://github.com/ethereum/EIPs/blob/master/EIPS/eip-695.md >`_.
1481
+
1482
+ -------
1483
+ Returns
1484
+ -------
1485
+
1486
+ ``Promise<Number> `` - Returns chain ID.
1487
+
1488
+ -------
1489
+ Example
1490
+ -------
1491
+
1492
+ .. code-block :: javascript
1493
+
1494
+ web3 .eth .getChainId ().then (console .log );
1495
+ > 61
1496
+
1497
+ ------------------------------------------------------------------------------
You can’t perform that action at this time.
0 commit comments