首页 > 解决方案 > 通过 rpc 从 Remix 连接到本地区块链时出错

问题描述

geth --datadir  ./accnt1   --port 30306 --networkid 2018 --rpc --rpcport 8545 --rpccorsdomain=”*” --nodiscover --rpcapi “db,personal,eth,net,web3,debug”  --rpcaddr="127.0.0.1" --rpcport 8545 console

使用上述命令启动控制台,将 remix 连接到私有区块链。甚至尝试使用 localhost 进行 rpcaddr。还使用了 http 版本的remix。仍然低于错误。

无法连接到 Web3 提供程序。确保提供程序正在运行并且连接已打开(通过 IPC 或 RPC)。

标签: blockchainethereumgo-ethereumremix

解决方案


  • 确保您已将 remix 中的环境更改为 Web3 提供程序
  • 在启动 geth 时,如果您想将其连接到 remix,那么您需要允许远程连接到 ethereum node 。这可以通过添加 --rpccorsdomain "URL OF THE WEBSITE" 来完成
  • 以下命令中的大写单词表示您需要根据需要指定。

    geth --datadir="创世纪块目录" --rpc --rpcport PORTNUMBER --rpccorsdomain "网站的 URL"

示例:geth --datadir="." --rpc --rpcport 8545 --rpccorsdomain="*" --rpcapi="miner,web3,debug,net,eth" 控制台 2>>logger.log

  • rpc 允许通过 HTTP 而不是 HTTPS,因此在 url 中将 https 更改为http://remix.ethereum.org/并且 ide 应该通过 http 而不是通过 https 连接。使用此行中提供的链接连接到 ide。

推荐阅读