Web3.js getBalance always showing 0

CurdixCurdix Member Posts: 1
Hi !

I would like to get my ethereum wallet balance so i made an app with web3.js and an ethereum node running with go-ethereum.

I have some ethers on my wallet and the node is synced i think, but my balance always show 0 ether.

This is my app :
var Web3 = require('web3');
var web3 = new Web3();
web3.setProvider(new web3.providers.HttpProvider('http://localhost:8545'));
balance = web3.eth.getBalance('0x...');
console.log(balance);
The node is started with this command

geth --rpc --rpccorsdomain "*"

Status of the node with web3.js :
API Version : 0.19.0
Node Version : Geth/v1.7.2-stable-1db4ecdc/darwin-amd64/go1.9.1
Network Version : 1
Ethereum Version : 63
isConnected : true
{host: "http://localhost:8545", timeout: 0}
Listening : true
Peer Count : 25
{currentBlock: 4518408, highestBlock: 4518717, knownStates: 2018181, pulledStates: 2006507, startingBlock: 4494680}
When i fetch a transaction with
web3.eth.getTransaction('0x..')
I can see a transfer of some ethers on my wallet. When i check on etherscan, I still have theses ethers on my wallet, but the balance from web3.js is still returning 0.

When i check the last block :

web3.eth.getBlock("latest").number;

Or with :

web3.eth.blockNumber;

It's returning 0. It doesn't seems normal ?!

Thanks for your help

Comments

Sign In or Register to comment.