Hardhat 节点,本地主机上的浏览器中出现错误

Tho*_*DEV 3 blockchain ethereum solidity hardhat

我正在尝试调试和测试我开发的智能合约,但是在测试网上这样做需要花费大量时间,而且我想在本地节点上正确测试。

我可以创建节点并部署合约,从元掩码中的帐户转移到另一个帐户,一切正常,除了当我在浏览器中访问http://127.0.0.1:8545/时 ,我收到此错误:

{"jsonrpc":"2.0","id":null,"error":{"code":-32700,"message":"Parse error: Unexpected end of JSON input"}}
Run Code Online (Sandbox Code Playgroud)

我尝试过勇敢和镀铬,我尝试创建一个不同的安全帽项目,同样的错误。

我能做些什么?谢谢!

Pet*_*jda 6

这是预期的输出。这是对空请求正文的响应:

# request
curl 'http://127.0.0.1:8545/' --data-raw ''
Run Code Online (Sandbox Code Playgroud)
# response
{"jsonrpc":"2.0","id":null,"error":{"code":-32700,"message":"Parse error: Unexpected end of JSON input"}}
Run Code Online (Sandbox Code Playgroud)

如果您发送了有效的 JSON-RPC 请求正文(通常不可能从浏览器地址栏发送,除非您安装了某种浏览器扩展),您将获得有效的响应:

# request
curl 'http://127.0.0.1:8545' --data-raw '{"jsonrpc":"2.0","method":"net_listening","params":[],"id":1}'
Run Code Online (Sandbox Code Playgroud)
# response
{"jsonrpc":"2.0","id":1,"result":true}
Run Code Online (Sandbox Code Playgroud)