2

I am developing ethereum wallet api. For now, I want to get the balance for specific address by using eth.getBalace().

I run testnet following

alias geth = 'geth --ipcpath /home/tom/.ethereum/testnet/geth.ipc'
geth console

At this time, I can see the eth.syncing is true. And I sent 3 ether in http://faucet.ropsten.be:3001/. But I can get balace by using eth.getBalance() method.

When I check the http://etherscan.io, there is success status. And it is also showing in http://myetherwallet.com.

How can I get balance in my local?

crashmstr
  • 28,043
  • 9
  • 61
  • 79
Railway
  • 71
  • 2
  • 13
  • 1
    Probable duplicate: https://ethereum.stackexchange.com/questions/24667/why-is-my-ether-balance-0-in-geth-even-though-the-sync-is-nearly-complete – carver Feb 05 '18 at 19:33

1 Answers1

1

The balance is 0 because you’re not connecting to the correct network when starting geth. The --ipcpath just tells geth where to store the IPC file when other local processes want to connect to your node. You need to specify the --testnet option to connect to Ropsten. It looks like you want to use the coinbase account for checking your balance, so you should also pass in your address with the --etherbase option.

alias geth = 'geth --ipcpath /home/tom/.ethereum/testnet/geth.ipc --testnet --etherbase \'YOUR_ADDRESS_HERE\''

To confirm you're connecting to the correct network, you should see something like this in your geth output:

INFO [02-05|11:33:45] Initialising Ethereum protocol versions="[63 62]" network=3

(Note - network=3 is Ropsten)

You can get the full list of geth commands here.

Once geth starts, you'll also have to wait for your node to sync in order to get your balance.

Adam Kipnis
  • 10,175
  • 10
  • 35
  • 48
  • tom@ubuntu:~$ alias gat="geth --ipcpath /home/tom/.ethereum/testnet/geth.ipc --testnet --etherbase '0x30d4396c2c9054eb2609b81759f288ee5c307cd2' --syncmode 'fast' --cache=2048" tom@ubuntu:~$ gat console etherbase address was got from first address of eth.accounts I run geth again such this, but still return 0. And can't see the correct connection result "network=3" – Railway Feb 06 '18 at 02:51
  • Did you wait for the node to sync? It takes a long time (usually several hours). – Adam Kipnis Feb 06 '18 at 03:39
  • I think you didn't understand me correctly. I am going to get the all balances for all addresses in my wallet in testnet and main network. How can I do? – Railway Feb 06 '18 at 10:48
  • I am having the same issue with my local geth node that is synchronised with ropsten. But so far I have been getting zero for balances. – Thomas Apr 27 '18 at 00:50