RPCHub - 推荐一个非常好用的RPC 工具

  • ChainTool
  • 更新于 2023-06-03 13:26
  • 阅读 1894

开源工具推荐,RPCHub 是一款专为Web3 开发者准备的 RPC 聚合器

作为一名 Web3 开发者,你是否遇到这样的问题:MetaMask 配置节点 RPC URL 又连接不上了,需要去ChainlistRpclist 重新找一个节点配置到MetaMask, 也许过段时间有需要重新做一遍。

如果你有这个困扰,RPCHub 推荐给你,RPCHub 由 BlockPI 团队开发, 我也是从 Web3极客公开课 听到这款产品。

RPCHub 是一款 RPC 聚合器, 是一个在本地运行的软件,MetaMask 配置节点连接到 RPCHub, 然后 RPCHub 将RPC请求分发到多个RPC端点。RPCHub可以同时配置多个端点(可以私有的、公共的节点服务器),另外支持我们自己来配置负载平衡的策略,以确保快速响应时间。

RPCHub 安装

RPCHub 是一款开源命令行工具,在GitHub https://github.com/BlockPILabs/aggregator 下载最新的Releases 版本:

image-20230603120307251

当前最新的版本是1.0.1 ,我们选择自己的系统进行下载。下载之后解压缩,会包含一个 aggregator 可执行文件,直接运行:

./aggregator 
v1.0.1
EROR[06-03|03:40:11] Load default config failed               module=config statusCode=0 error=timeout retries=1
INFO[06-03|03:40:15] Load default config success              module=config
INFO[06-03|03:40:16] New load balancer                        module=load-balance chain=ethereum-sepolia nodes=1
INFO[06-03|03:40:16] New load balancer                        module=load-balance chain=gnosis nodes=1
INFO[06-03|03:40:16] New load balancer                        module=load-balance chain=oasys nodes=2
INFO[06-03|03:40:16] New load balancer                        module=load-balance chain=scroll-testnet nodes=2
...
INFO[06-03|03:40:23] Updated authority phishing db            module=plugins addresses=2986
INFO[06-03|03:40:23] Starting proxy server                    module=server addr=:8011
INFO[06-03|03:40:23] Registered RPC                           module=server endpoint=http://localhost:8011/aptos
INFO[06-03|03:40:23] Registered RPC                           module=server endpoint=http://localhost:8011/arbitrum
INFO[06-03|03:40:23] Registered RPC                           module=server endpoint=http://localhost:8011/avalanche
INFO[06-03|03:40:23] Registered RPC                           module=server endpoint=http://localhost:8011/bsc
INFO[06-03|03:40:23] Registered RPC                           module=server endpoint=http://localhost:8011/ethereum
INFO[06-03|03:40:23] Registered RPC                           module=server endpoint=http://localhost:8011/ethereum-goerli
INFO[06-03|03:40:23] Registered RPC                           module=server endpoint=http://localhost:8011/ethereum-sepolia
INFO[06-03|03:40:23] Registered RPC                           module=server endpoint=http://localhost:8011/fantom
INFO[06-03|03:40:23] Registered RPC                           module=server endpoint=http://localhost:8011/gnosis
INFO[06-03|03:40:23] Registered RPC                           module=server endpoint=http://localhost:8011/optimism
INFO[06-03|03:40:23] Registered RPC                           module=server endpoint=http://localhost:8011/polygon
INFO[06-03|03:40:23] Registered RPC                           module=server endpoint=http://localhost:8011/polygon-mumbai
INFO[06-03|03:40:23] Registered RPC                           module=server endpoint=http://localhost:8011/scroll-testnet

aggregator 启动后,会打印差距所有可用的链的RPC (例如:http://localhost:8011/bsc), 介绍就可以把这个端点配置到MetaMask中, 如图:

image-20230603121549078

PRCHub 配置

PRCHub 提供了前端Console页面(https://ag-cfg.rpchub.io/)来方便用户配置区块链的RPC 端口。

打开https://ag-cfg.rpchub.io/, 输入 http://127.0.0.1:8012 和密码123456

image-20230603124329397

之后就进入了控制台。

其实 RPCHub 的配置是存储在本地的, Console 前端的配置页面会通过访问 RPCHub 启动的 server (http://127.0.0.1:8012)来读取本地配置以及写入新配置

添加 RPC

image-20230603123106410

我这里给BSC添加了一个新的 RPC URL:

image-20230603123016873

随后我们可以在aggregator 控制台看到有对新添加节点 ninicoin 的请求。

DBUG[06-03|04:54:07] relay rpc -> eth_call                    module=plugins sid=s-0000000000000158 node=bsc-blockpi-public isTx=true tries=2
DBUG[06-03|04:54:21] relay rpc -> eth_blockNumber             module=plugins sid=s-0000000000000159 node=bsc-blockpi-public isTx=false tries=1
DBUG[06-03|04:54:21] relay rpc -> eth_getBlockByNumber        module=plugins sid=s-0000000000000160 node=bsc-blockpi-public isTx=false tries=1
DBUG[06-03|04:54:21] relay rpc -> eth_call                    module=plugins sid=s-0000000000000161 node=ninicoin isTx=true tries=1
DBUG[06-03|04:54:41] relay rpc -> eth_blockNumber             module=plugins sid=s-0000000000000162 node=omniatech isTx=false tries=1
DBUG[06-03|04:54:43] relay rpc -> eth_getBlockByNumber        module=plugins sid=s-0000000000000163 node=ninicoin isTx=false tries=1
DBUG[06-03|04:54:46] relay rpc -> eth_getBlockByNumber        module=plugins sid=s-0000000000000163 node=omniatech isTx=false tries=2
DBUG[06-03|04:54:47] relay rpc -> eth_call                    module=plugins sid=s-0000000000000164 node=bsc-official isTx=true tries=1

我们还可以根据需要设置代理, 设置钓鱼地址数据库等。

image-20230603125817619

开发者们如果对 RPCHub 有什么想法,还可以向 @BlockPI

希望 RPCHub 可以帮助到各位 web3 开发者。

本文来自 @Tiny熊ChainToolDAO 致力于为开发者提供高效、易用、开源的区块链开发工具。

点赞 1
收藏 1
分享
本文参与登链社区写作激励计划 ,好文好收益,欢迎正在阅读的你也加入。

0 条评论

请先 登录 后评论
ChainTool
ChainTool
https://chaintool.tech/ ChainToolDAO 致力于为开发者提供高效、易用、开源的区块链开发工具,我们的成员不仅仅是贡献者,也是自己产品的用户,我们构建自己喜欢的产品的同时,让更多的人受益。