Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nya1/eth-net-type
Get infos about your current ethereum network
https://github.com/nya1/eth-net-type
chain ethereum mainnet network testnet
Last synced: 27 days ago
JSON representation
Get infos about your current ethereum network
- Host: GitHub
- URL: https://github.com/nya1/eth-net-type
- Owner: nya1
- License: mit
- Created: 2017-06-03T11:05:23.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-06-04T16:25:03.000Z (over 7 years ago)
- Last Synced: 2024-08-11T00:30:38.421Z (3 months ago)
- Topics: chain, ethereum, mainnet, network, testnet
- Language: JavaScript
- Size: 7.81 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
### eth-net-type
[![npm version](https://badge.fury.io/js/eth-net-type.svg)](https://badge.fury.io/js/eth-net-type) [![Build Status](https://travis-ci.org/nya1/eth-net-type.svg?branch=master)](https://travis-ci.org/nya1/eth-net-type)
Get infos about your current network type, supported networks so far: mainnet, morden, ropsten, kovan, rinkeby.
```
npm install eth-net-type --save
```**Note:** Supported Node.js 4.0.0 and above
```
const ethNetType = require('eth-net-type')
ethNetType.guess(myWeb3Instance.eth.getBlock(0))// returns (kovan example):
{
'match': true,
'block_hash': '0xa3c565fc15c7478862d50ccd6561e3c06b24cc509bf388941c25ea985ce32cb9',
'network_id': 42,
'name': 'kovan',
'disused': false,
'start_date': 1488459412
}
```### API
```
ethNetType.guess()
```Get network type by the network id number or the the genesis block hash.
```
ethNetType.getByGenBlockHash()
```Get network type by the genesis block hash (block number 0).
```
ethNetType.getByNetId()
```Get network type by the network id number.
All methods return a `match` parameter, true if there is a match otherwise false.
### TESTS
Unit tests (chai+mocha) are included in `test/general.js`
```
npm run test
```### LICENSE
MIT