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,050 points
45 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 by Omkar
• 67,520 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
• 67,520 points
43 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
• 67,520 points
23 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
• 67,520 points
111 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
• 67,520 points
26 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
141 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 375 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 9 in Blockchain by Omkar
• 67,520 points
70 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 in Blockchain by Omkar
• 67,520 points
25 views