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

Sam*_*AYO 13 geth

我开始使用《掌握区块链 - 深入探讨分布式账本、共识协议、智能合约、DApps、加密货币、以太坊》一书进行区块链开发,

我正在使用 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
Run Code Online (Sandbox Code Playgroud)

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

这是我尝试运行的命令:

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

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

小智 26

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

geth --datadir ~/etherprivate/ --networkid 786 --http --http.api 'web3,eth,net,debug,personal' --http.corsdomain '*'
Run Code Online (Sandbox Code Playgroud)

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

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