13

Am starting off in blockchain development using the book Mastering Blockchain - A deep dive into distributed ledgers, consensus protocols, smart contracts, DApps, cryptocurrencies, Ethereum,

Am using WSL with geth version 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

Am trying to start geth, but am getting the error that the --rpc flag is not defined.

This is the command I am trying to run:

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

Any help on how I can solve it?

ouflak
  • 2,458
  • 10
  • 44
  • 49
Samuel IZABAYO
  • 155
  • 1
  • 5
  • 1
    Try `geth --help` I didnt find rpc flag in docu for this version – MenyT Oct 06 '21 at 11:05
  • 1
    https://geth.ethereum.org/docs/interface/command-line-options – kostix Oct 06 '21 at 11:21
  • 1
    Please next time 1) Use https://ethereum.stackexchange.com 2) Do not tag such questions with `go` as they have nothing to do with programming in Go and `blockchain` as they are not about the relevant technology but rather about issues using a particular program. Thanks! – kostix Oct 06 '21 at 11:22
  • 1
    Sure, I will consider doing it next time. – Samuel IZABAYO Oct 06 '21 at 11:45

3 Answers3

25

The latest versions of Geth (after 1.10.8-stable) do not support --rpc but fortunately, as you can see in the Command-line Options, it has been replaced by the --http option. So your command should look like this:

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

With all rpc options replaced by their http equivalent:

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

It appears 1.10.9-stable version has a problem and is returning a -rpc error. GETH 1.10.8-stable version works fine when running the geth command with --rpc

HSudler
  • 11
  • 1
1

You can also use other options related to --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")
Dave Lee
  • 316
  • 3
  • 9