How to get account with ethers by default in ethereum private network?

0 votes

I am trying to create a private ethereum network. I have followed the steps of initialization after creating genesis block:

{
   "config": {
      "chainId": 12345,
      "homesteadBlock": 0,
      "eip155Block": 0,
      "eip158Block": 0,
      "byzantiumBlock": 0
   },
   "difficulty": "400",
   "gasLimit": "2000000",
   "alloc": {
      "38dsid27167d208c66584ece7f09d8bc8f8223nd": { 
          "balance": "100000000000000000000000" 
      }
   }
}
geth --datadir ./myDataDir init ./myGenesis.json
and started node:
geth --datadir ./myDataDir --networkid 1114

Now when I type this command to see ethers:

eth.getBalance(eth.coinbase)

It shows 0 ethers even if I have allocated ethers in genesis block.

Jan 9 in Blockchain by slayer
• 29,040 points
25 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

Have you created an account before allocating ethers in Genesis file? Seems like you have not. First create an account using the following command:

geth --datadir ./datadir account new

This command will output an account ID. Use that ID in your genesis file to allocate ethers. Suppose your account ID is 38dsid27167d208c66584ece7f09d8bc8f8223nd, then your genesis block should be like this:

{
   "config": {
      "chainId": 12345,
      "homesteadBlock": 0,
      "eip155Block": 0,
      "eip158Block": 0,
      "byzantiumBlock": 0
   },
   "difficulty": "400",
   "gasLimit": "2000000",
   "alloc": {
      "38dsid27167d208c66584ece7f09d8bc8f8223nd": { 
          "balance": "100000000000000000000000" 
      }
   }
}
answered Jan 9 by Omkar
• 66,910 points

Related Questions In Blockchain

0 votes
1 answer

How to get IP address of peer connected in private ethereum network?

To get these details, you can use ...READ MORE

answered Jan 10 in Blockchain by Omkar
• 66,910 points
24 views
0 votes
1 answer

How to get Node URL in private ethereum network?

You have already noticed that  admin.peers does ...READ MORE

answered Jan 10 in Blockchain by Omkar
• 66,910 points
14 views
0 votes
1 answer

Not able to create new account in geth for private ethereum network

Looks like the account you are trying ...READ MORE

answered Dec 6, 2018 in Blockchain by Omkar
• 66,910 points
46 views
0 votes
1 answer

Not able to send ethers in private ethereum network

Your account is locked by default due ...READ MORE

answered Jan 9 in Blockchain by Omkar
• 66,910 points
14 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
82 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 161 views
0 votes
1 answer

How to change default account in private ethereum network?

First list the accounts: > eth.accounts NOTE: Even ...READ MORE

answered Jan 9 in Blockchain by Omkar
• 66,910 points
34 views
0 votes
1 answer

How to import an account in private ethereum network?

 When you create a new account, the ...READ MORE

answered Jan 9 in Blockchain by Omkar
• 66,910 points
14 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.