Skip to content

Latest commit

 

History

History
50 lines (28 loc) · 943 Bytes

web3-eth-net.rst

File metadata and controls

50 lines (28 loc) · 943 Bytes
web3.eth.net

Contains functions to get information about the current network.



getNetworkType
web3.eth.net.getNetworkType([callback])

Guesses the chain the node is connected by comparing the genesis hashes.

Note

It's recommended to use the web3.eth.getChainId <eth-chainId> method to detect the currently connected chain.

Returns

Promise returns String:
  • "main" for main network
  • "ropsten" for the morden test network
  • "private" for undetectable networks.

Example

web3.eth.net.getNetworkType()
.then(console.log);
> "main"