Last active
December 20, 2017 02:24
-
-
Save devonwesley/966d8b977a831a33816a436e6327aa95 to your computer and use it in GitHub Desktop.
A code snippet that checks which ethereum network your on.
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
function currentNetwork() { | |
const network = web3.eth.getBlock(0).hash | |
const main = '0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3' | |
const test = '0x41941023680923e0fe4d74a34bdac8141f2540e3ae90623718e47d66d1ca4a2d' | |
switch (network) { | |
case main: | |
return 'Main Net' | |
case test: | |
return 'Ropsten Network' | |
default: | |
return 'TestRPC Testnet' | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment