Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.

Commit 8a34697

Browse files
committed
Add eth.getChainId to the docs
1 parent be8ab5d commit 8a34697

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

docs/web3-eth-net.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ getNetworkType
2525
2626
Guesses the chain the node is connected by comparing the genesis hashes.
2727

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.
2929

3030
-------
3131
Returns

docs/web3-eth.rst

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1467,3 +1467,31 @@ Example
14671467
14681468
14691469
------------------------------------------------------------------------------
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+
------------------------------------------------------------------------------

0 commit comments

Comments
 (0)