Git Product home page Git Product logo

eth-chains's Introduction

Publish npm

Eth Chains

Helper module for getting Ethereum chains info from chainid.network.

Install

yarn add eth-chains
npm install eth-chains

Usage

Import chains methods and enums:

import chains, { ChainId, ChainName } from 'eth-chains'

Easily get most popular chains:

import { chain } from 'eth-chains'

console.log(chain.ethereum.rinkeby)

console.log(chain.polygon.mumbai)

Chain names and ids via Enums:

console.log(ChainId.EthereumMainnet) // 1
console.log(ChainId.BinanceSmartChainMainnet) // 56
console.log(ChainName.EthereumMainnet) // "Ethereum Mainnet"
console.log(ChainName.Rinkeby) // "Rinkeby"

Chain by ID:

chains.getById(ChainId.EthereumMainnet) // { name: "Ethereum Mainnet", ..., "infoURL": "https://ethereum.org" }
// Equivalent
chains.getById(1)

Chain by Name:

chains.getByName(ChainName.EthereumMainnet) // { name: "Ethereum Mainnet", ..., "infoURL": "https://ethereum.org" }
// Equivalent
chains.getByName('Ethereum Mainnet')

Get all Chains:

const allChains = chains.all() 
// { 1: { name: "Ethereum Mainnet", ..., "infoURL": "https://ethereum.org" }, 2: {...}}

Typescript Types:

import { Chain, NativeCurrency, Explorer } from 'eth-chains'
const ethereum: Chain = chains.getById(ChainId.EthereumMainnet)
ethereum.chain // 'ETH'

TODO:

  • Add webhook that watches the chains repo and triggers an update to this package whenever that repo gets updated
    • Add check in the deploy script to make sure that the types are correct before publishing
  • Add Tests
    • Once quicktype is added, test with different chains.json objects to make sure it can handle new types
  • Use quicktype to autogen types from json
  • Autogen Chain Id enum
  • Autogen Chain Name enum

eth-chains's People

Contributors

taylorjdawson avatar amyboyd avatar

Stargazers

Roman avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.