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 🙏

© 2025 – Pkg Stats / Ryan Hefner

chainlist-rpcs

v0.5.260

Published

Wrapper around the rpcs as published by DefiLlama/chainlist.

Readme

Unofficial chainlist RPC npm module

npm version

This package is a developer-friendly way to access the public RPCs as presented on chainlist.org. The RPC endpoint list is maintained by the DefiLlama team at DefiLlama/chainlist. Keep in mind that these RPC urls are public and do not come with any uptime or performance guarantees.

Installation:

npm install -S chainlist-rpcs

Note that the RPC list is updated once a day automatically, and that every RPC list bump results in a patch semver update of this package. You can see the npm deployment history here.

Usage of constants

The module exports constants that are objects you can access. The rpcs and chains_by_id constants which equal the chainlist sources in this folder of their repository. The chains_by_name constant is an object that maps chain names to their id.

import { rpcs, chains_by_id, chains_by_name } from 'chainlist-rpcs'

// You can access chain names by their chain id. Chain id 1 is Ethereum mainnet.
console.log( chains[1] ) // Output: "ethereum". Note that this is by chain id and not by index. 1 here refers to chain id 1.

// You can access the RPCs for a chain by its chain id.
console.log( rpcs[1] ) // [ { url: String, tracking: String, trackingDetails: String } ].

// You can access the chain id by its name.
console.log( chains_by_name["ethereum"] ) // Output: 1

Usage of helper functions

This module makes available helpers that allow you to grab RPCs based on chain id or chain name.

/**
 * Retrieves the RPC urls for a specified blockchain.
 *
 * @param {Object} params - The parameters for retrieving RPCs.
 * @param {number} [params.chain_id] - The ID of the blockchain.
 * @param {string} [params.chain_name] - The name of the blockchain.
 * @param {Array} [params.allowed_tracking=[]] - An array of tracking objects. Options: none, limited, yes.
 * @returns {Array} The list of RPCs for the specified blockchain.
 * @throws {Error} If both chain_id and chain_name are specified but do not match.
 */
export function get_rpcs_for_chain( { chain_id, chain_name, allowed_tracking=[] } )

/**
 * Retrieves the RPC urls for the specified chains.
 *
 * @param {Object} params - The parameters object.
 * @param {Array<string>} [params.chain_ids=[]] - An array of chain IDs.
 * @param {Array<string>} [params.chain_names=[]] - An array of chain names.
 * @param {Array} [params.allowed_tracking=[]] - An array of tracking objects. Options: none, limited, yes.
 * @returns {Array} An array of RPCs for the specified chains.
 */
export function get_rpcs_for_chains( { chain_ids=[], chain_names=[], allowed_tracking=[] } )

Example usage:

import { get_rpcs_for_chains, get_rpcs_for_chains } from 'chainlist-rpcs'

const single_chain_by_id = get_rpcs_for_chains( { chain_id: 1 } ) // Output: [ { url: String, tracking: String, trackingDetails: String } ]
const single_chain_by_name = get_rpcs_for_chains( { chain_name: "ethereum" } ) // Output: [ { url: String, tracking: String, trackingDetails: String } ]

const multiple_chains_by_id = get_rpcs_for_chains( { chain_ids: [1, 42161] } ) // Output: { 1: [ { url: String, tracking: String, trackingDetails: String } ], 42161: [ { url: String, tracking: String, trackingDetails: String } ], ethereum: [ { url: String, tracking: String, trackingDetails: String } ], arbitrum: [ { url: String, tracking: String, trackingDetails: String } ] }

const multiple_chains_by_name = get_rpcs_for_chains( { chain_names: ["ethereum", "arbitrum"] } ) // Output: { 1: [ { url: String, tracking: String, trackingDetails: String } ], 42161: [ { url: String, tracking: String, trackingDetails: String } ], ethereum: [ { url: String, tracking: String, trackingDetails: String } ], arbitrum: [ { url: String, tracking: String, trackingDetails: String } ] }

Example usage with viem

import { get_rpcs_for_chains } from 'chainlist-rpcs'
import { arbitrum } from 'viem/chains'
import { createPublicClient, fallback, http, formatEther } from 'viem'

const your_private_rpc_endpoints = [ "https://your-private-rpc-endpoint.com", "https://your-private-rpc-endpoint-2.com" ]
const chainlist_rpc_endpoints = get_rpcs_for_chains( { chain_name: 'arbitrum' } )
const rpc_endpoints = [ ...your_private_rpc_endpoints, ...chainlist_rpc_endpoints ]

const public_client = createPublicClient( {
    chain: arbitrum,
    transport: fallback( rpc_endpoints.map( ( rpc ) => http( rpc ) ) )
} )

const gas_price_wei = await public_client.getGasPrice()