9

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!

murrekatt
  • 261
  • 3
  • 6
  • @BokkyPooBah yes that works but it's for a private chain without --dev – murrekatt Aug 07 '16 at 07:17
  • 1
    --dev is just some additional configs - see https://github.com/ethereum/go-ethereum/blob/master/cmd/utils/flags.go#L125-L128 and https://github.com/ethereum/go-ethereum/blob/master/cmd/utils/flags.go#L724-L744 . maxpeers=0, listenaddr=:0,whisper is enabled, powtest is true and something to do with the olympic genesis block and the gas price. What you can do otherwise is use --dev, mine and move the ETH to your other account. There does not seem to be a convenient way to set preallocated accounts using the --dev setup. – BokkyPooBah Aug 07 '16 at 07:33
  • @BokkyPooBah yes I know it's possible to move ether but as this used to work I'd like to know maybe it still does or if not why it isn't anymore :) – murrekatt Aug 07 '16 at 07:40
  • From https://github.com/ethereum/go-ethereum/releases, With the coming of Geth 1.4 we've deprecated the --genesis <json_file> flag and replaced with a geth init <json file> sub command. This means that you'll no longer be able to mix the destructive --genesis flag with other flags. – BokkyPooBah Aug 07 '16 at 07:44
  • @BokkyPooBah yes I have read that too. I use init with a custom genesis that has accounts as I would like them in alloc. I.e. first I run new account and then I adjust the custom genesis and then run init. No balance if I have the --dev flag. – murrekatt Aug 07 '16 at 07:47
  • I've retracted the close vote. – BokkyPooBah Aug 07 '16 at 07:54
  • 3

2 Answers2

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

KanekiDev
  • 671
  • 3
  • 10
1

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}) }

Lee
  • 8,548
  • 6
  • 46
  • 80