2

I am trying to create my private testnet using geth. However, even when I use a CustomGenesis block from a json file, when I start geth and run admin.nodeInfo, the genesis and head hashes are of the main network.

Here is the CustomGenesis.json:-

{
"nonce": "0x0ae067964324234907200d849",
"timestamp": "0x0",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"extraData": "0x0",
"gasLimit": "0x8000000",
"difficulty": "0x4000",
"mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"coinbase": "0x16d38897146fb767e709386f416bbc88aed53171",
"alloc": {
    "0x16d38897146fb767e709386f416bbc88aed53171": {
            "balance": "10000000000000000000"
    }
}
}

Here is the command I am using to start my private testnet:-

geth --identity "Dev1" --datadir "/home/dev1admin/ethereum/private_test1/chain" --port "30304" --nodiscover --ipcapi "admin,db,eth,debug,miner,net,shh,txpool,personal,web3" --rpcapi "db,eth,net,web3" --autodag --networkid 1729 --nat "none" --verbosity 5 console init "/home/dev1/ethereum/private_test1/CustomGenesis.json"

The output of admin.nodeInfo command:-

{
enode:"enode://0e576e1aa07d4ee4ea7fc34fe7a0e46ef16f9b835ce58b76dd7b675eea67d7546c3daf3b3115badabc24235d1056c508b108ba7d0f88bbf3687edae5db9165f7@[::]:30304?discport=0",
id: "0e576e1aa07d4ee4ea7fc34fe7a0e46ef16f9b835ce58b76dd7b675eea67d7546c3daf3b3115badabc24235d1056c508b108ba7d0f88bbf3687edae5db9165f7",
ip: "::",
listenAddr: "[::]:30304",
name: "Geth/Dev1/v1.5.5-stable-ff07d548/linux/go1.7.3",
ports: {
discovery: 0,
listener: 30304
},
protocols: {
eth: {
  difficulty: 17179869184,
  genesis: "0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3",
  head: "0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3",
  network: 1729
}
}
}

I don't want to use the --dev option with geth because I want to pre-allocate some ether. Also, just using a network id to differentiate between networks seems wrong to me (I also want to be able to set a custom nonce to ensure that no one else connects to my network unless they know my nonce).

2

Your init is command is super long. This prevented you from noticing that you gave Geth 2 commands: console and init. It went with the first.

So how about you keep the strictly necessary and remove console and the ":

geth --datadir /home/dev1admin/ethereum/private_test1/chain --verbosity 5 init /home/dev1/ethereum/private_test1/CustomGenesis.json
1

The account you are allocating ether to already needs to exist for it to be seeded via the genesis file. Accounts live outside of the blockchain (Geth stores them in the datadir/keystore folder) so you can create them in one blockchain and copy them to another

Here is a possible workflow:

  1. Start geth with your custom genesis file and data directory
  2. Create the accounts via personal.newAccount()
  3. Update the genesis file with the accounts you created in #2
  4. Delete the datadir/geth directory
  5. Start geth again with your custom genesis file and data directory

You might find my github repo on setting up a private ethereum network helpful:

https://github.com/chafey/ethereum-private-network

  • The steps you wrote did not work. In the steps that I followed, I don't think the error was due to adding an account that does not exist to the etherbase and pre-allocation fields(I do change that later after creating a new account and then restart the client). If the error was due to that, geth should (ideally) not have started or should have given an error. – goluhaque Jan 29 '17 at 11:19
  • Geth will only allocate the ether to the accounts when the init command is run. The accounts must therefore be created before you run init. I don't think you can run init and console at the same time - run init first, then start it again with console if you want. – Chris Hafey Jan 29 '17 at 23:40
  • Thanks. That worked. Should have noticed the extra console. – goluhaque Jan 30 '17 at 5:39

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.