Last active
January 14, 2019 12:11
-
-
Save ylv-io/7dbaf38d506e2cd4c8e9fabd164a3fd6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if (web3js) { | |
| switch (web3js.version.network) { | |
| case '1': | |
| console.log('This is mainnet'); | |
| break; | |
| case '2': | |
| console.log('This is the deprecated Morden test network.'); | |
| break; | |
| case '3': | |
| console.log('This is the ropsten test network.'); | |
| break; | |
| case '4': | |
| console.log('This is the Rinkeby test network.'); | |
| break; | |
| case '42': | |
| console.log('This is the Kovan test network.'); | |
| break; | |
| default: | |
| console.log('This is an unknown network.'); | |
| } | |
| const desiredNetwork = 1; | |
| if (web3js.version.network !== desiredNetwork) { | |
| // ask user to switch to desired network | |
| console.log('Please switch to main network.'); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment