npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@vandeurenglenn/chainmap

v0.1.4

Published

A comprehensive map of EVM blockchain networks and their associated data. It includes information such as chain IDs, network names, RPC URLs, and currency details.

Downloads

12

Readme

🗺️ ChainMap

npm

ChainMap provides a comprehensive map of EVM blockchain networks and their associated data. It includes information such as chain IDs, network names, RPC URLs, and currency details.

import chainMap from "chainmap";
import { JsonRpcProvider, formatUnits } from "ethers";

const ethereum = chainMap.ethereum.mainnet;
const provider = new JsonRpcProvider(ethereum.rpc[0]);

Features

  • 🗺️ A Comprehensive map of blockchain networks.
  • 📝 Includes chain IDs, network names, image assets, RPC URLs, and currency details.
  • ⚡️ Free RPC URLs for each network.
  • 📅 Built daily to ensure RPCs are working.

Installation

You can install ChainMap using npm/yarn/bun:

npm install chainmap

Supported Networks

Arbitrum Goerli (421613), Arbitrum Mainnet (42161), Arbitrum Nova (42170), Arbitrum Sepolia (421614), Aurora Mainnet (1313161554), Aurora Testnet (1313161555), Avalanche C-chain (43114), Avalanche Fuji Testnet (43113), Base (8453), Binance SmartChain Mainnet (56), Binance SmartChain Testnet (97), Celo Alfajores Testnet (44787), Celo Baklava Testnet (62320), Celo Mainnet (42220), Cronos Mainnet (25), Ethereum Goerli (5), Ethereum Mainnet (1), Ethereum Sepolia (11155111), Fantom Opera (250), Fantom Testnet (4002), Gnosis (100), Harmony Mainnet Shard 0 (1666600000), Harmony Testnet Shard 0 (1666700000), Klayton Mainnet (8217), Moonbase Alpha (1287), Moonbeam (1284), Moonriver (1285), Moonrock (1288), OP Mainnet (10), Polygon (137), Polygon Mumbai (80001), Polygon Zkevm (1101), Polygon Zkevm Testnet (1442), ZkSync Mainnet (324), Zora (7777777)

Usage

Get a specific chains data:

import chainMap from "chainmap";

chainMap.ethereum.mainnet.rpc; // <- an array of free RPC URLs
chainMap.ethereum.mainnet.chainId; // <- the chain ID e.g. "1"
chainMap.ethereum.mainnet.name; // <- the network name e.g. "Ethereum Mainnet"
chainMap.ethereum.mainnet.currency; // <- the currency details e.g. { name: "Ether", symbol: "ETH", decimals: 18 }
chainMap.ethereum.mainnet.explorerUrl; // <- the explorer URL e.g. "https://etherscan.io"

Get a chains data by its chain ID:

import chainMap from "chainmap";

const ethereumInfo = chainMap[1] // <- in this example '1' is the chain ID for Ethereum Mainnet.
ethereumInfo.rpc; // <- an array of free RPC URLs
... // etc

Docs

ChainInfo: An object containing information about a blockchain.

| Property | Type | Description | | ------------- | ----------------- | --------------------------------------------------- | | name | string | The name of the blockchain | | chainId | number | The ID of the blockchain | | rpc | string[] | An array of RPC URLs | | currency | CurrencyInfo | Information about the blockchain's currency | | explorerUrl | string (optional) | The URL of the blockchain's explorer (if available) | | iconUrl | string (optional) | The URL of the blockchain's icon (if available) |

CurrencyInfo: An object containing information about a blockchain's currency.

| Property | Type | Description | | ---------- | ----------------- | --------------------------------------------- | | name | string | The name of the currency | | symbol | string | The symbol of the currency | | decimals | number | The number of decimal places for the currency | | iconUrl | string (optional) | The URL of the currency's icon (if available) |

Contributing

Chainmap source files are generated from specifications in data directory. During the generation process, rpcs are tested to ensure they are working. If a network fails to connect, it is removed from the generated source files.

✏️ Modify a network

Open the network data file data/<network>.list.ts, and make your modifications, ensuring the default exported Object still confroms to the ChainMap interface.

➕ Add a network

Create a new file in the data directory, named <network>.list.ts. The file should export an object that conforms to the ChainMap interface.

e.g. Creating a new network called mychain with chain ID 1234 and RPC URL https://mychain.com:

import { ChainMap } from "./types";

export const MYC {
  name: "MyCoin",
  symbol: "MYC",
  decimals: 18,
  }

export default {
  mainnet: {
    chainId: 1234,
    name: "MyChain mainnet",
    currency: MYC,
    explorerUrl: "https://mychain.com",
    rpc: [
      "https://rpc.mychain.com",
      "https://rpc2.mychain.com",
    ],
  },
} as ChainMap; // <- ensures the object conforms to the ChainMap interface

Generate and build

Typically source files should be generated by the github action, but you can generate them locally using bun.

Prerequisites:

bun run generate

You can then build the distribution files:

bun run build

Testing networks

You can check that all network RPCs are working by running:

bun test