0

in ethereum page of github,we can see something about genesis file below:

Defining the private genesis state

First, you'll need to create the genesis state of your networks, which all nodes need to be aware of and agree upon. This consists of a small JSON file (e.g. call it genesis.json):

{
"config": {
"chainId": 0,
"homesteadBlock": 0,
"eip155Block": 0,
"eip158Block": 0
},
"alloc" : {},
"coinbase" : "0x0000000000000000000000000000000000000000",
"difficulty" : "0x20000",
"extraData" : "",
"gasLimit" : "0x2fefd8",
"nonce" : "0x0000000000000042",
"mixhash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
"parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
"timestamp" : "0x00"
}

The above fields should be fine for most purposes, although we'd recommend changing the nonce to some random value so you prevent unknown remote nodes from being able to connect to you. If you'd like to pre-fund some accounts for easier testing, you can populate the alloc field with account configs:

"alloc": { "0x0000000000000000000000000000000000000001": {"balance": "111111111"}, "0x0000000000000000000000000000000000000002": {"balance": "222222222"} }

I define "alloc": { "0x0000000000000000000000000000000000000001": {"balance": "111111111"} } in my genesis.json file, then I run command below:

./geth --datadir ethereum init genesis.json

but in geth console, after I run eth.accounts, it returns null

instance: Geth/helloworld/v1.6.6-unstable/linux-amd64/go1.8.3
 modules: admin:1.0 debug:1.0 eth:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 txpool:1.0 web3:1.0

> eth.accounts
[]
>
1

You can follow the steps given in the answer link below to create a private net and the steps also include how to fund your default account while initializing genesis block.

Basically, you need to allocate balance in Genesis file to an account which you might have created using this command -

geth --datadir pnet/ account new

Please take a look at this answer for the steps - How do I set up a private ethereum network?

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.