web3-detect-network
v0.0.18
Published
Detect network from Web3 provider.
Downloads
76
Maintainers
Readme
web3-detect-network
Detect network from Web3 provider.
Install
npm install web3-detect-network
API
detectNetwork(web3Provider) -> Promise({object})
- {object} web3Provider - Web3 provider object
Returns an object containing
id
(network ID) andtype
(network name).
Usage
const detectNetwork = require('web3-detect-network')
;(async () => {
const network = await detectNetwork(web3.currentProvider)
console.log(network)
/*
{
"id": "4",
"type": "rinkeby"
}
*/
})()
Test
npm test
License
MIT