如何在nodejs上运行HardHat脚本,以便您可以在不同端口上分配多个EVM链?
我希望能够为我的系统上的一个提供更多的链条(以太坊,BSC等)。
HardHat Doc显示,如何分叉 1链 NPX HARDHAT节点 - fork https:// ...
,效果很好。
但是我想通过 nodejs脚本以编程方式分叉。
当我尝试在下面的nodej上划分链条时,它不起作用。我该怎么办?
谢谢!
`hre.config.networks.networks = {
hardhat: {
forking: {
url: http://localhost:8545
},
}
}
await hre.network.provider.request({
method: "hardhat_reset",
params: [
{
forking: {
jsonRpcUrl: http://localhost:8545,
chainId: chainObj.chain_id,
blockNumber: blockNumber,
},
},
],
});
`
I want to be able to fork more chains (ethereum, bsc, etc.) than just one on my system.
Hardhat doc shows, how to fork 1 chain npx hardhat node --fork https://...
and it works fine.
But I would like to fork them programmatically on a Nodejs script.
When I try to fork a chain on NodeJs like below, it does not work. What can I do?
Thanks!
`hre.config.networks.networks = {
hardhat: {
forking: {
url: http://localhost:8545
},
}
}
await hre.network.provider.request({
method: "hardhat_reset",
params: [
{
forking: {
jsonRpcUrl: http://localhost:8545,
chainId: chainObj.chain_id,
blockNumber: blockNumber,
},
},
],
});
`
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许会有所帮助。
hardhat.config.ts:
package.json:
Maybe it would help.
hardhat.config.ts:
package.json: