eth.getBalance() always returns 0 in testnet

0 votes

I am developing an ethereum wallet api. I want to get the balance for specific address by using eth.getBalace() on running the following testnet:

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.

How can I get balance in my local?

Jul 24, 2018 in Blockchain by sabby
• 4,350 points
465 views

1 answer to this question.

0 votes

You are not connecting to the right network when starting geth, hence the 0 balance. 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\''

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.

answered Jul 24, 2018 by Christine
• 15,790 points

Related Questions In Blockchain

+1 vote
1 answer
+1 vote
1 answer

How to setup testnet environment in Ethereum??

You can connect to a node using ...READ MORE

answered Apr 18, 2018 in Blockchain by Shashank
• 10,350 points
48 views
0 votes
1 answer

How to get the already existing channels in Hyperledger v1.0?

You cannot see all available channels,  but you ...READ MORE

answered Jun 4, 2018 in Blockchain by Perry
• 17,020 points
227 views
0 votes
1 answer

Çannot implement web3.eth.subscribe on Web3 version 1.0.0-beta.27

As the error suggests, pub/sub is not ...READ MORE

answered Jun 19, 2018 in Blockchain by Perry
• 17,020 points

edited Jun 19, 2018 by Perry 280 views
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
141 views
0 votes
1 answer
0 votes
0 answers

Error: Unexpected token o in JSON at position 1

I have been working with Interacting a ...READ MORE

Mar 6 in Blockchain by saeedi
• 120 points

edited Mar 6 by Omkar 374 views
0 votes
1 answer

GetState query via chaincode always returns empty value

fabric uses an ccenv image to build the chaincode when ...READ MORE

answered Jul 17, 2018 in Blockchain by Christine
• 15,790 points
331 views
0 votes
1 answer

How to make sure transactions take no fee in a private Ethereum blockchain?

In a private ethereum network you have ...READ MORE

answered Mar 26, 2018 in Blockchain by Christine
• 15,790 points

edited Mar 26, 2018 by Christine 94 views