8

I'm trying to set up a private chain with geth using --dev that has several accounts with lots of ether. It seems unclear if this is possible anymore according to this.

Here's what I tried on geth 1.4.x and 1.5:

geth --datadir data --dev --password <(echo -n foobar) account new
geth --datadir data --dev --password <(echo -n foobar) account new
geth --datadir data --dev --password <(echo -n foobar) account new

Then init like so:

geth --datadir data --dev --password <(echo -n foobar) init custom.json

Then running geth with mine:

geth --datadir data --dev --password <(echo -n foobar) \
  --unlock 0,1,2 \
  --verbosity 6 \
  --rpc --rpcaddr "0.0.0.0" --rpccorsdomain '"*"' --nodiscover \
  --rpcapi "admin,db,eth,debug,miner,net,shh,txpool,personal,web3" \
  --mine --minerthreads 1 --gasprice 0

Then I use curl to check the balance of the accounts. Result is 0x0.

If I remove the --dev option there is balance, but it takes forever as it then uses the real DAG. I don't want that as this if for testing.

How to best get multiple preallocated accounts with lots of ether for a private dev chain?

Thanks!

2

It is suppossed to be done by editing your custom genesis file of your testnet. adding something like:

//The genesis file
"alloc":{
        "address":{
                  "balance": "1000000"
                  }
        }
}

Source: https://souptacular.gitbooks.io/ethereum-tutorials-and-tips-by-hudson/content/private-chain.html

  • This does not work anymore for dev...hence my question. – murrekatt Sep 29 '16 at 20:52
  • Ok, if i find any other solution for this, i'll tell you. – KanekiDev Sep 30 '16 at 6:44
  • Tried a bit ago and it worked for me. Check that you are starting the testnet properly with your custom genesis file. – KanekiDev Sep 30 '16 at 7:41
  • I don't use testnet... --dev and private chain – murrekatt Oct 3 '16 at 13:00
  • 1
    using --dev causes your private to start with a preconfigured set of options. So no chance to preallocate as you are not using a custom Genesis.json file but a preconfigured one. – KanekiDev Oct 4 '16 at 7:08
0

I did it like this:

  1. Initialise geth in dev mode with the -- flag

    geth --dev --allow-insecure-unlock

    Never do this in mainnet mode.

  2. Attach a web3 js console

  3. Run this to create 10 unlocked accounts and fund them from the default account:

    for (i=0;i<10;i++){ a = personal.newAccount('pwd') personal.unlockAccount(a,'pwd',0) web3.eth.sendTransaction({from:eth.accounts[0],to:eth.accounts[i+1],value:1000000000000}) }

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.