Skip to content

Commit

Permalink
Add eth.getChainId to the docs
Browse files Browse the repository at this point in the history
  • Loading branch information
gabmontes committed Oct 8, 2019
1 parent be8ab5d commit 8a34697
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docs/web3-eth-net.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ getNetworkType
Guesses the chain the node is connected by comparing the genesis hashes.

.. note:: This is not a 100% accurate guess as any private network could use testnet and mainnet genesis blocks and network IDs.
.. note:: It's recommended to use the :ref:`web3.eth.getChainId <eth-chainId>` method to detect the currently connected chain.

-------
Returns
Expand Down
28 changes: 28 additions & 0 deletions docs/web3-eth.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1467,3 +1467,31 @@ Example
------------------------------------------------------------------------------

.. _eth-chainId:

getChainId
==========

.. code-block:: javascript
web3.eth.getChainId([callback])
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>`_.

-------
Returns
-------

``Promise<Number>`` - Returns chain ID.

-------
Example
-------

.. code-block:: javascript
web3.eth.getChainId().then(console.log);
> 61
------------------------------------------------------------------------------

0 comments on commit 8a34697

Please sign in to comment.