Help: Genesis File in a Private Testnet Using Init

Can someone explain in laymens terms how to start a private testnet with a custom genesis file using init and not --genesis?

I've been reading from three different sites on the process of going about it, but have failed numerous times.

I've been doing something like this:

geth --datadir="/path/to/dir/" init /path/to/genesis.json --othercommands console >>2 /path/to/dir.log

I'm not sure if --datadir or init should be listed first. Everytime I try to use the init command I get, Incorrect Usage.

init [arguments...]

The init command initialises a new genesis block and definition for the network.
This is a destructive action and changes the network in which you will be

And messing with the verbosity and the >>2 /path/.log options are changing whether I have control of the geth console after I start geth. I'm really not sure what the ">>2 ...." after "console" even does or means. If someone could clear that up for me it would be awesome.

And as far as the customGenesis file goes, do I just create the file or put something into it?

-Thank you


  • yoregisyoregis Member Posts: 1

    I find my way implementing a private blockchain like this, hope it will help you :

    For each **geth** command, we will define few parameters :
    - networkid: Allow you to specify the P2P network. Use a value > 100 to avoid conflicts. 0: for Olympic 1: for Frontier 2: Morden ...
    - identity: give your node a name
    - nat: port mapping mechanism, de-activate by choosing "none"
    - datadir: allow you to store your node info in a path you choose
    - nodiscover: disables the peer discovery mechanism

    So, our 2 nodes have these options :
    - `--networkid 100 --identity node1 --nodiscover --nat none --datadir=~/myBlockchain/node1:smile:

    You need an identity to interact with Ethereum. We will use **geth** :

    user:~ geth --networkid 100 --identity node1 --verbosity 3 --nodiscover --nat none --datadir=~/myBlockchain/node1 account new

    Give a secure passphrase. Check with your finder that a new account has been created in the directory `~/myblockchain/node1/keystore/`.

    ### Create a Custom Genesis block

    The blockchain is built upon a first block called the Genesis block

    We HAVE to define this first block in the file CustomGenesis.json :

    "nonce": "0xdeadbeefdeadbeef",
    "timestamp": "0x0",
    "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "extraData": "0x0",
    "gasLimit": "0x8000000",
    "difficulty": "0x400",
    "mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "coinbase": "0x3333333333333333333333333333333333333333",
    "alloc": {
    "0xedf0e8c867b633d83b10880dbd57c7d64d30a67d": {
    "balance": "1000"

    Notice that the address *0xedf0e8c867b633d83b10880dbd57c7d64d30a67d* will be credited of 1000 ethers initially. Just change it to your own address.

    We will now build up the Genesis block with the command 'init' and using our CustomGenesis.json file :

    user:~ geth --networkid 100 --identity node1 --verbosity 3 --nodiscover --nat none --datadir=~/myBlockchain/node1 init ~/cheminvers/CustomGenesis.json

    This command will create the chaindata directory which contains all the blockchain informations defined by **geth**

    ### Start node 1 and start mining

    Once the initial block has been built, we just have to start the node and start the mining. On OSX, use the command :

    user:~ geth --networkid 100 --identity node1 --verbosity 3 --nodiscover --nat none --datadir=~/myblockchain/node1 --mine --ipcpath ~/Library/Ethereum/geth.ipc

    Once the DAG created (takes few minutes), mining start. It works as a daemon, to stop it, use Ctrl-C.

    Note: We have only one 1 miner now. You can check your Ethereum Wallet and you'll see that you are continuously credited with ethers.
  • AlwaysSunnyAlwaysSunny Member Posts: 14
    Thank you so much for your help.
    Everything worked as you have explained
    , and I just have two more questions.

    1. Do you have to init a new genesis block for each node?

    2. How does one go from this to creating static-nodes with 2 more geth instances?
  • rupsha11rupsha11 Member Posts: 2

    1. We need to have the same genesis files, and the same network id for all nodes in the private testnet.
    2. I used this to connect static peers to the private testnet. This should work for you too.
Sign In or Register to comment.