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.
Promise
returnsString
:"main"
for main network"ropsten"
for the morden test network"private"
for undetectable networks.
web3.eth.net.getNetworkType()
.then(console.log);
> "main"