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, 2019 in Blockchain by slayer
• 29,370 points
1,678 views

1 answer to this question.

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, 2019 by Omkar
• 69,220 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, 2019 in Blockchain by Omkar
• 69,220 points
3,108 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, 2019 in Blockchain by Omkar
• 69,220 points
1,820 views
+1 vote
2 answers

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
• 69,220 points
4,106 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, 2019 in Blockchain by Omkar
• 69,220 points
1,111 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
1,923 views
0 votes
1 answer

Hyperledger Sawtooth vs Quorum in concurrency and speed Ask

Summary: Both should provide similar reliability of ...READ MORE

answered Sep 26, 2018 in IoT (Internet of Things) by Upasana
• 8,620 points
1,451 views
0 votes
0 answers

Error: Unexpected token o in JSON at position 1

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

Mar 6, 2019 in Blockchain by saeedi
• 120 points

edited Mar 6, 2019 by Omkar 2,476 views
–1 vote
1 answer

How to change default account in private ethereum network?

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

answered Jan 10, 2019 in Blockchain by Omkar
• 69,220 points
1,866 views
–1 vote
1 answer

How to import an account in private ethereum network?

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

answered Jan 9, 2019 in Blockchain by Omkar
• 69,220 points
1,568 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP