9

I am trying to create a private network for testing purposes. What I need is:

  1. Fast generating of DAG file.
  2. Fast mining of the first block.
  3. Address with some preallocated amount of Eth.

I found that this could be done by two ways, the first one is:

  • Generate the address.
  • Pass it in the genesis file.
  • Run geth --datadir "." init genesis.json
  • Run geth --dev --mine --datadir "."

    PROBLEM: Address is not preallocated with money (I don't know why, maybe genesis.json file isn't reading properly)

The second one is:

  • Generate the address.
  • Pass it in the genesis file.
  • Run geth --datadir "." init genesis.json
  • Run geth --networkid 123 --nodiscover --mine --maxpeers 0 --datadir "."

    PROBLEM: DAG file is generating too slow.

Q: Any suggestions how I can meet all requirements?

genesis.json:

{
  "nonce": "0xdeadbeefdeadbeef",
  "timestamp": "0x0",
  "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
  "extraData": "0x0",
  "gasLimit": "0x8000000",
  "difficulty": "0x01",
  "mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
  "coinbase": "0xe7b728f368fce77508e4562ef370d3e902bb79dc",
  "alloc": {
    "0xe7b728f368fce77508e4562ef370d3e902bb79dc": {
      "balance": "10000000000000000000"
    }
  }
}

geth info:

Geth
Version: 1.4.3-stable
Protocol Versions: [63 62 61]
Network Id: 1
5

The first one will work,

Once you’ve generated your account, quit geth with and remove every folder except keystore/ from your datatir:

$ cd <your datadir>
$ rm -rf `ls | grep -v keystore`

update your genesis block json, adding the following to the alloc key:

"alloc": {
    "<your account address e.g. 0xcc8C048426978c5877212281b8a75F1B4E71a862>": {
        "balance": "10000000000000000000"
    }
}

Now re-run the geth command using the newly updated genesis json file and the same datadir, when you check your account balance you will find you now have 10 ether:

Check completes steps in my blog lightrains.com

  • Broken link. Can you please update the url – Kiran Kulkarni Apr 17 '17 at 2:52
  • @KiranKulkarni Done, please check. – niksmac Apr 17 '17 at 4:48
  • how to get/set private keys for these accounts? – aleebek Sep 24 '17 at 9:48
  • @aleebek you create wallet and give the pubkey in the genesis file. – niksmac Sep 24 '17 at 14:18
0

The easiest way to do this is with testrpc, it is way faster and has some nice developer features. I struggled with the genesis thing a bit, and just used this:

Install testrpc with: npm install -g ethereumjs-testrpc

Run testrpc like this:

testrpc -a "10" --seed "2553" --debug --account="<acct number>, <amount of wei in hex>" --account="<another account>,<some amount>"

  • 1
    OP is not asking for a rpc method to work, he is trying to solve problem with his current set up. As i understand. – niksmac May 17 '16 at 1:01
  • I uderstood the question as trying to achieve points 1,2 and 3: 1. Fast generating of DAG file. 2. Fast mining of the first block. 3. Address with some preallocated amount of Eth. I had the same objectives/problem, and I solved it by using testrpc. I was able to setup a test environment for dapps that had preallocated accounts, and is able to run tests faster than a geth rpc. – Jose Llausas May 17 '16 at 1:24
  • @niksmac How can I improve my answer? – Jose Llausas May 17 '16 at 1:31
  • May be, you can propose your answer as an alternative solution or try to answer OPs query. Cheers – niksmac May 17 '16 at 2:15
  • How does my answer not answer OP's question to : "I am trying to create a private network for testing purpose, what I need is:..." My answer is a perfect valid way of creating what he is asking for. @niksmac – Jose Llausas May 18 '16 at 16:34

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.