提供但未定义的标志:-rpc

Flag provided but not defined: -rpc

我开始使用这本书进行区块链开发 掌握区块链 - 深入研究分布式账本、共识协议、智能合约、DApp、加密货币、以太坊

我正在使用 WSL 和 geth 版本 1.10.9。

$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 '*'

任何关于如何解决它的帮助?

1.10.9-stable 版本似乎有问题并返回 -rpc 错误。 GETH 1.10.8-stable 版本在 运行 带有 --rpc

的 geth 命令时工作正常

最新版本的 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

您还可以使用与--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")