I was trying to set-up ethereum private test-net. I was able to create a custom Genesis block and create an account. Now I modified my customGenesis.json to preallocate ethers to my account, I was hit by:
Fatal: failed to write genesis block: wrong genesis block in database (have 6650a0ac6c5e8054, new 423e5a9e61bce67e)
Steps to reproduce:
setup Genesis state:
geth --identity "Prashant" --fast --cache=1024 --rpc --rpcport "8013" --rpccorsdomain "*" --datadir "myPrivateNetwork2" --port "30312" --rpcapi "db,eth,net,web3,admin,debug,miner,personal,web3" --networkid 1902 --nat "any" init customGenesis.json console
Start geth without init to create account:
geth --identity "Prashant" --fast --cache=1024 --rpc --rpcport "8013" --rpccorsdomain "*" --datadir "myPrivateNetwork2" --port "30312" --rpcapi "db,eth,net,web3,admin,debug,miner,personal,web3" --networkid 1902 --nat "any" -ipcpath "/home/prsingh/.ethereum/geth.ipc" console
Create an account in geth console
personal.newAccount("my_password");
Modify customeGenesis.json to preallocate ethers
"alloc":{ "0xe43ee2af5a41385ff951f0c3fe2f5156287757a6": {"balance": "20000000000000000000" } }
Again run geth with init
geth --identity "Prashant" --fast --cache=1024 --rpc --rpcport "8013" --rpccorsdomain "*" --datadir "myPrivateNetwork2" --port "30312" --rpcapi "db,eth,net,web3,admin,debug,miner,personal,web3" --networkid 1902 --nat "any" init customGenesis.json console
At step 5, I am getting the wrong genesis block in database error
. I am quite sure this is because I have already run the geth
with init
param so when I am trying to run it the second time, geth
gives error because these in already a genesis block.
But then the question is: How will I pre-allocate ethers to my account?
Here is my customGenesis.json after adding funds to my account.
{
"nonce": "0x0000000000000042",
"timestamp": "0x0",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"extraData": "0x00",
"gasLimit": "0x8000000",
"difficulty": "0x400",
"mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"coinbase": "0x3333333333333333333333333333333333333333",
"config": {
"chainId": 15,
"homesteadBlock": 0,
"eip155Block": 0,
"eip158Block": 0
},
"alloc":{
"0xe43ee2af5a41385ff951f0c3fe2f5156287757a6":
{"balance": "20000000000000000000" }
}
}
geth --datadir <path to data directory > init <genesis file path>
. Hope it will correct the things.