Geth – Why Doesn’t Geth Have –rpcapi Option?

go-ethereumsmart-contract-wallets

I am new to Ethereum and trying to setup a private network by using geth command. I have installed geth:

$ geth version
Geth
Version: 1.10.12-stable
Architecture: amd64
Go Version: go1.17.2
Operating System: darwin
GOPATH=
GOROOT=go

I have read some doc about how to launch a node in private network and many mentioned to use a command like geth --datadir=./chaindata/ --ipcpath $HOME/.ethereum/geth.ipc --rpc --rpcapi db,eth,net,web3,personal,miner.

However, I got this error flag provided but not defined: -rpcapi on above command. And I checked the geth doc https://geth.ethereum.org/docs/interface/command-line-options but it doesn't have any option for rpcapi. Is this flag deprecated? what is the alternative one I should use?

In the end, I end up using geth --datadir data/node1 --http --dev --http.corsdomain "*" --http.api web3,eth,debug,personal,net --mine command to launch the node. Is there anything different by using http than rpc?

One issue I have is after I attach to the console, geth attach http://localhost:8545, I can't find miner instance: ReferenceError: miner is not defined. How can I get the miner in order to mine more ether for my accounts?

Best Answer

Why doesn't geth have --rpcapi option?

Because the --rpc* flags were changed in favor of --http* (--rpc became --http and --rpcapi became --http.api), support for the legacy --rpc* flags was dropped on geth 1.10.9.

How can I get the miner in order to mine more ether for my accounts?

You need to enable the miner namespace too as you did in your first command:

geth --datadir data/node1 --http --dev --http.corsdomain "*" --http.api web3,eth,debug,personal,net,miner --mine
Related Topic