When I make a RPC to geth running remotely, I cannot get the account list / balance of the account. It also says that the coinbase is not set. But as far as I know, isnt the coinbase supposed to be the first account created if coinbase is explicitly not defined ? If I use geth command line in the remote machine, the two accounts that I have created show up, while the RPC returns 0 accounts. What could be the issue?
6 Answers
Try starting geth with explicit http flags. Note that exposing personal api to internet is not safe, and personal api is deprecated.
geth --http --http.api="eth,personal"
To start with all available apis (important: if you do this make sure your api is not accessible from internet)
geth --http --http.api="admin,debug,web3,eth,txpool,personal,ethash,miner,net"
- 312
- 2
- 13
- 9,673
- 2
- 40
- 72
Create an account.
$ geth account new
Your new account is locked with a password. Please give a password. Do not forget this password.
Passphrase:
Repeat Passphrase:
Address: {168bc315a2ee09042d83d7c5811b533620531f67}
Or
Creates a new account and prints the address.
On the console, use:
personal.NewAccount() ... you will be prompted for a password ...
or
personal.newAccount("passphrase")
https://github.com/ethereum/go-ethereum/wiki/Managing-your-accounts
- 18,036
- 20
- 54
- 82
- 159
- 2
- 6
May be it is a bit late to answer but for others if they need in future. I had a typo in --datadir and --networkid. Hope it helps!
- 81
- 7
Try to set etherbase first:
~ geth console --ropsten
> miner.setEtherbase('0x..........')
> eth.getBalance(eth.coinbase)
- 101
- 1
I faced the same issue and I was defining the wrong data directory. So if you are creating your own blockchain and facing this error, make sure you have specified the correct data directory.
sudo geth --snapshot=false --mine --http --allow-insecure-unlock --http.corsdomain "*" --networkid 1999 --datadir /.ethereum/ console
This worked for me. Also, rpc is replaced with http.
- 1
- 1
It's maybe because coinbase wallet is not made.
In console
personal.newAccount('anypassword')
miner.setEtherbase(personal.listAccounts[1]);
- 1
- 1