blockchain - 通过 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)。
解决方案
- 确保您已将 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。
推荐阅读
- javascript - 如何撤消类更改并将类数据存储在 html 表中
- javascript - javascript中的json数组递归循环
- email - 对时事通讯进行 HTML 编码
- javascript - React ScrollIntoView 在父组件中不起作用
- php - 自动将产品添加到购物车 WooCommerce 时排除某些类别
- bash - 将重复的元素删除到文件中
- javascript - 如何在性能方面优化脚本
- java - 无法使用 SAAJ 发送 ZIP 文件
- javascript - 如何避免将重复项添加到数组中,并且特定属性一次只有一个值?
- sql - 用于更新对象的 JPQL 查询