web3-network-detective
A simple module to determine if your web3 provider is on the Ethereum mainnet, (morden) testnet or a custom network.
Install
npm install --save web3-network-detective
Usage
;; // setup example web3 instanceconst web3 = 'https://morden.infura.io/'; // network detective usage; /*example detective result:{ network: 'mainnet', // or 'testnet' or 'custom' mainnet: true, testnet: false, custom: false,}*/
API Design
constructor
Detects the current network of a web3 provider.
Parameters
web3Provider
Object the web3 provider you would like to check the nextwork (i.e. 'livenet' or 'testnet') of.
Returns Object, example:
{
network: 'mainnet', // or 'testnet' or 'custom'
mainnet: true,
testnet: false,
custom: false,
}
Deployment
- Make sure you have an
account.json
file outside this repo, that contains one JSON object with two propertiesaddress
andprivateKey
, like so:{"address": "0x000...", "privateKey": "000..."}
. - Run
npm run deploy
npm run deploy
Tests
npm test
LICENCE
MIT -- LICENCE