连接 Hedera 测试网有 3 个选项:
- Hashio
- Arkhia
- 运行你自己的hedera-json-rpc-relay实例于
localhost
以上按升序排列困难水平,
和递增的顺序可靠性水平。
不幸的是,为了提高可靠性,您需要做更多的工作。
目前,您正在使用 Hashio,
我推测您可能受到费率限制;
或者此服务的负载水平可能高于平常
导致它丢弃一些传入的请求。
因此我建议你改用Arkhia,
看看这是否适合你(很可能会)。
如果你真的想尽量减少对集中服务,
或需要debug单独的 RPC 请求,
您可以考虑在本地运行您自己的 RPC 中继实例。
RPC 端点选项
Hashio
这是一个“公共”RPC 端点,由 Swirlds Labs 托管,
开发 Hedera 的是同一个组织。
因此,它是免费使用的,不需要任何注册,
并且对向其发出的请求也有最严格的速率限制。
这使得它易于使用,但不太可靠。
要通过 Hashio 连接到 Hedera 测试网,
只需在初始化钱包/ web3 提供程序实例时使用此 URL:
https://testnet.hashio.io/api
这就是所需要的一切 - 不需要进一步的设置/配置
Arkhia
这是由第三方组织运营的,
并且有一些付费组件,以及免费套餐。
因此,它只能免费使用到一定程度,
并需要此后注册。
它对向其发出的请求的速率限制较少。
这使得它在易用性方面处于平均水平,
并且比使用公共 RPC 端点更可靠。
要通过 Arkhia 连接到 Hedera 测试网,
初始化钱包/ web3 提供程序实例时使用此 URL:
https://pool.arkhia.io/hedera/testnet/json-rpc/v1/YOUR_API_KEY
为了得到YOUR_API_KEY
,您将需要执行以下先决步骤:
- (1) 注册账号auth.arkhia.io/signup
- (2) 单击确认电子邮件中的链接
- (3) Click on the "create project" button in the top-right corner of the Arkhia dashboard
- (4) Fill in whatever you like in the modal dialog that pops up
- (5) Click on the "Manage" button on the right side of your newly created project
- (6) In the project details, copy the "API Key" field, and the "JSON-RPC" field as well (in case it is different from what I've pasted above).
- (7) 在 RPC URL 中使用 API 密钥 - 完成!
本地主机上的 hedera-json-rpc-relay
这是由您在自己的计算机上运行的。
(去中心化是为了胜利!)
因此,它可以不受限制地免费使用(您自己的硬件除外)。
它不需要注册,
但设置它还需要几个额外的步骤,
并且需要开发人员技能/命令行技能才能开始工作。
通过您自己的实例连接到 Hedera Testnethedera-json-rpc-relay
,
初始化钱包/ web3 提供程序实例时使用此 URL:
http://localhost:7546
注意7546
是该项目的默认端口号,
如果您愿意,您可以在其配置中更改它。
为了运行此服务,您需要执行以下先决步骤:
git clone [email protected]:hashgraph/hedera-json-rpc-relay.git
- (2) 创建或编辑名为
.env
在此项目的根目录中,设置以下字段:
HEDERA_NETWORK=testnet
OPERATOR_ID_MAIN=YOUR_OPERATOR_ID
OPERATOR_KEY_MAIN=YOUR_OPERATOR_KEY
CHAIN_ID=0x128
MIRROR_NODE_URL=https://testnet.mirrornode.hedera.com/
- (3) Visit the Hedera Portal, and create a Testnet account
- (4) Copy-paste the confirmation code sent to your email
- (5) Fill out this form
- (6) In the top-left select between Hedera Testnet (default) and Hedera Previewnet
- (7A) From the next screen that shows your accounts, from the "Account Ed25519" section, copy the value of "DER encoded private key", and replace
YOUR_OPERATOR_KEY
in the .env
file with it
- (7B) Alternatively, from the "Account ECDSA" section, copy the value of the "HEX encoded private key", and replace
YOUR_OPERATOR_KEY
in the .env
file with it
- (8) 在同一屏幕中,复制“帐户 ID”的值,然后替换
YOUR_OPERATOR_ID
in the .env
用它归档
- (9) Run
npm install
安装依赖项。建议您使用 NodeJs 版本18
或稍后为此。
- (10) 运行
npm run start
启动 RPC 中继服务器。
配置的完整参考hedera-json-rpc-relay
: docs/configuration.md.