【问题标题】:Flag provided but not defined: -rpc提供但未定义的标志:-rpc
【发布时间】:2021-10-06 10:21:31
【问题描述】:

我正在使用 Mastering Blockchain - 深入研究分布式账本、共识协议、智能合约、DApps、加密货币、以太坊一书

开始区块链开发

我正在使用带有 geth 版本 1.10.9 的 WSL。

$geth version
Geth
Version: 1.10.9-stable
Git Commit: eae3b1946a276ac099e0018fc792d9e8c3bfda6d
Architecture: amd64
Go Version: go1.17
Operating System: linux
GOPATH=
GOROOT=go

我正在尝试启动 geth,但我收到了 --rpc 标志未定义的错误。

这是我要运行的命令:

geth --datadir ~/etherprivate/ --networkid 786 --rpc --rpcapi 'web3,eth,net,debug,personal' --rpccorsdomain '*'

对我如何解决它有任何帮助吗?

【问题讨论】:

标签: geth


【解决方案1】:

Geth 的最新版本(1.10.8-stable 之后)不支持 --rpc 但幸运的是,正如您在Command-line Options 中看到的那样,它已被 --http 选项。所以你的命令应该是这样的:

geth --datadir ~/etherprivate/ --networkid 786 --http --http.api 'web3,eth,net,debug,personal' --http.corsdomain '*'

将所有 rpc 选项替换为对应的 http 选项:

  • --rpc => --http
  • --rpcapi => --http.api
  • --rpccorsdomain => --http.corsdomain

【讨论】:

  • 感谢您的帮助。
【解决方案2】:

似乎 1.10.9-stable 版本有问题并返回 -rpc 错误。 使用 --rpc 运行 geth 命令时,GETH 1.10.8-stable 版本可以正常工作

【讨论】:

  • 我遇到了同样的错误,但恢复到 1.10.8 确实有帮助
【解决方案3】:

你也可以使用其他与--rpc相关的选项

  --http                              Enable the HTTP-RPC server
  --http.addr value                   HTTP-RPC server listening interface (default: "localhost")
  --http.port value                   HTTP-RPC server listening port (default: 8545)
  --http.api value                    API's offered over the HTTP-RPC interface
  --http.rpcprefix value              HTTP path path prefix on which JSON-RPC is served. Use '/' to serve on all paths.
  --http.corsdomain value             Comma separated list of domains from which to accept cross origin requests (browser enforced)
  --http.vhosts value                 Comma separated list of virtual hostnames from which to accept requests (server enforced). Accepts '*' wildcard. (default: "localhost")

【讨论】:

    猜你喜欢
    • 2018-05-27
    • 1970-01-01
    • 1970-01-01
    • 2018-11-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多