[Ethereum] Geth not synchronizing to MetaMask

accountsgo-ethereumimportmetamasktestnets

I want to import my account of MetaMask(testnet) to the geth accounts list.

First I copied the private key from MetaMask and saved to a txt file.

After that I run this command :

geth account import /path/to/file.txt --testnet console

Absolutely, I get my account to the list:

geth account list

But in MetaMask I have some ethers, but from the geth console when I want to check my balance for the same account, I get 0 ether.

Is it possible to sync the balance ?,by the way I run the update command:

geth account update 0x....

I got the same problem.

Best Answer

Unfortunately, you had successfully synced your local GEth but with a different network other than the one you checking your Ether at!

This confusion happen because there was an attack on Ropesten network that has been corrected by some nodes but the other nodes still having the old data. And when you run your command:

geth --testnet --rpc --rpcaddr "localhost" --rpcport "8545" --rpcapi "web3,eth,net,personal" --rpccorsdomain "*" --datadir "./data" --identity "localnode" --fast

You are not specifying in the command any specific node to connect to. And by mistake you are connected to node(s) that is still running on the old deprecated obsolete network blockchain data!

And deleting the "chaindata" folder, will not inform GEth to try with other nodes. Because, it will pick the same nodes from the folder "nodes".

To choose new nodes to sync with, you have either to:

  • Delete the "nodes" folder and also specify an updated nodes to be used by GEth using "--bootnodes" option.
  • Or, add the nodes even after sync using the command: "admin.addPeer('enode://ADDRESS@IP:PORT')". this is after you attach to Geth in terminal using "geth attach ipc:/home/developer/.ethereum/testnet/geth.ipc"

However, because there is no clear listing on which nodes had been forked and updated to correct the hack, and because of many other issues like the large size of the full network node, I recommend using Parity to connect to the correct Ropsten nodes' network.

To use parity I recommend following one of those links:

So, thanks to Parity! You can specify your desired network using "--chain" easily by running: "parity --chain ropsten"

Answer copied from mine at: https://stackoverflow.com/questions/46765878/local-node-geth-failed-to-sync-from-testnet/47301387#47301387

Related Topic