0

I have created two personal account on private blockchain with geth. This is the balance of one account

web3.fromWei(eth.getBalance(eth.accounts[0]), "ether");

100000000000

And this is of the second one

 web3.fromWei(eth.getBalance(eth.accounts[1]), "ether");
0

I unlocked first account

personal.unlockAccount(eth.accounts[0])
Unlock account 0x942282c0793fb08dea160c74ac45b5d4f2d03192
Passphrase: 
true

When i try to send transaction or transfer from one to another, it executes successfully

eth.sendTransaction({from: '0x942282c0793Fb08dEA160C74AC45B5D4F2D03192',to: '0x7258CB67ccBCF4AC755e5D7F0891e9415B683129',value: '1000000000'})
INFO [02-19|10:45:22.065] Submitted transaction                    fullhash=0xf6e573bcd1eb92d70b06cfa80e04604f0a83a49d0c75786afc04062ebb975af1 recipient=0x7258CB67ccBCF4AC755e5D7F0891e9415B683129
"0xf6e573bcd1eb92d70b06cfa80e04604f0a83a49d0c75786afc04062ebb975af1"
> INFO [02-19|10:45:24.616] Commit new mining work                   number=1 sealhash=24efa9…31b496 uncles=0 txs=9 gas=189000 fees=0.000189 elapsed=179.547ms

But changes are not reflected when i again check balance accounts.

This is the genesis.json that i have used for blockchain setup.

{
 "config": {
   "chainID": 1234,
   "homesteadBlock": 0,
   "eip155Block": 0,
   "eip158Block": 0
 },
 "alloc": {
    "0x942282c0793fb08dea160c74ac45b5d4f2d03192": {
      "balance": "100000000000000000000000000000"
    }
 },
 "difficulty": "0x4000",
 "gasLimit": "0xffffffff",
 "nonce": "0x0000000000000000",
 "coinbase": "0x0000000000000000000000000000000000000000",
 "mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
 "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
 "extraData": "0x123458db4e347b1234537c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa",
 "timestamp": "0x00"
}
  • AFAIK, function eth.getBalance returns a promise, which you can resolve into a BigNumber object (or possibly a string which represent an integer value). So you should first resolve this promise (for example, by adding await before eth.getBalance). – goodvibration Feb 19 '19 at 11:49
  • @goodvibration Thanks for reply. It turns out my private blockchain was taking too long to mine a new block, at least 20 minutes thus it was not reflecting changes immediately, is it due to difficulty ? How much i should i reduce it, if i have private network of one or two nodes. Can you guide?. TIA – Saeedi Feb 19 '19 at 14:02
  • I use "difficulty": "0x20000" and it works fine. – goodvibration Feb 19 '19 at 15:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.