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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@zhengkan2008/rpc-pool

v2.1.2

Published

Health-aware RPC pool with query load balancing and tx primary-backup failover.

Readme

RPC Pool(重写版)

@zhengkan2008/rpc-pool 提供两条通道:

  • 查询通道(query):多 RPC 负载均衡,连续失败自动摘除,进入观察名单,探活后自动回池。
  • 交易通道(tx):单主 RPC 提交交易,连续失败自动切备,故障节点进入观察名单,恢复后回备池。

环境变量

以 Gnosis 为例:

# 查询池(负载均衡)
GNOSIS_RPC_HTTP_GNOSISCHAIN=https://rpc.gnosischain.com/
GNOSIS_RPC_HTTP_PUBLICNODE=https://gnosis-rpc.publicnode.com

# 交易池(可选,不配则默认用查询池第一个作为主)
GNOSIS_RPC_HTTP_PRIMARY=https://rpc.gnosischain.com/
GNOSIS_RPC_HTTP_BACKUP_1=https://gnosis-rpc.publicnode.com

# 或者使用 TX 专用键(优先级更高)
# GNOSIS_RPC_TX_PRIMARY=https://rpc.gnosischain.com/
# GNOSIS_RPC_TX_BACKUP_1=https://gnosis-rpc.publicnode.com

支持链前缀:ETHBSCBASEARBITRUMGNOSIS

新增常用主网支持:POLYGON(137)、OPTIMISM(10)、AVALANCHE(43114)。 别名可用:polygon/maticoptimism/opavalanche/avax

策略参数

RPC_QUERY_FAIL_THRESHOLD=3
RPC_TX_FAIL_THRESHOLD=2
RPC_RECOVER_THRESHOLD=2
RPC_WATCH_COOLDOWN_MS=30000
RPC_HEALTHCHECK_MS=8000
RPC_PROBE_TIMEOUT_MS=2500
RPC_REQUEST_TIMEOUT_MS=10000
RPC_TRANSPORT_RETRY_DELAY_MS=150

使用方式

import {
  getQueryClient,
  getQueryTransport,
  getTxTransport,
  getRpcPoolStats,
} from '@zhengkan2008/rpc-pool';
import { createWalletClient } from 'viem';
import { gnosis } from 'viem/chains';

const queryClient = getQueryClient('gnosis');
const block = await queryClient.getBlockNumber();

const txWallet = createWalletClient({
  chain: gnosis,
  transport: getTxTransport('gnosis'),
});

const stats = getRpcPoolStats('gnosis');
console.log(stats.tx.primaryUrl, stats.query.watchCount);

新 API

  • getRpcPool(chainName)
  • getQueryClient(chainName)
  • getQueryTransport(chainName)
  • getTxTransport(chainName)
  • getRpcPoolStats(chainName)
  • listRpcPoolChains()

.pools 自动补全

可根据已有 provider 条目自动补全“多链 + HTTP/WS”组合(目前内置 ALCHEMYDRPC)。

例如已有:

ETH_RPC_HTTP_ALCHEMY=https://eth-mainnet.g.alchemy.com/v2/<key>

运行后可自动补出同 provider 的:

  • ETH_RPC_WS_ALCHEMY
  • GNOSIS_RPC_HTTP_ALCHEMY
  • GNOSIS_RPC_WS_ALCHEMY
  • 以及该 provider 支持的其他链组合

命令:

# 只预览,不写文件
npm run pools:autofill:dry-run

# 写回 scripts/.pools
npm run pools:autofill

发布到 npm / 私有仓库

1) 发布到 npm 官方仓库

cd shared/rpc-pool
npm run build
npm run pack:dry-run
npm login --registry https://registry.npmjs.org
npm run publish:npm

2) 发布到私有 npm 仓库

cd shared/rpc-pool
export NPM_PRIVATE_REGISTRY="https://npm.company.internal/"
export NPM_PRIVATE_TOKEN="<token>"
npm run publish:private

3) 凭据模板

可参考 .npmrc.example,按你的仓库地址和 token 替换。

4) scope 注意事项

当前包名是 @zhengkan2008/rpc-pool。如果你在 npm 官方不拥有 @zhengkan2008 scope,需要先改 package.jsonname(例如改成你自己的 scope)。