web3-detect-network

0.0.18 • Public • Published

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) and type (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

/web3-detect-network/

    Package Sidebar

    Install

    npm i web3-detect-network

    Weekly Downloads

    36

    Version

    0.0.18

    License

    MIT

    Unpacked Size

    8.32 kB

    Total Files

    7

    Last publish

    Collaborators

    • miguelmota