[Ethereum] Startup script for creating an account and running geth

accountsgo-ethereum

I am trying to create a startup shell script to create a geth instance with a pre-configured genesis file at the nodes on an Ubuntu Wily OS with geth installed on the system. The objective is to create a private test net with one of the nodes accountable for seeding the accounts and allocating ether to the accounts?

For this purpose, I would need to create the genesis file with a preset allocation of ether to an account.

The only way I found is to create an account non-interactively is to use:

geth --password <path to password file> account new

This would require creating an account and then using the path to the password file created on the system.

Questions:

1. Is it possible to pre-generate a password file on the local host and then use this file to create an account, using the above command? What is the best way to preset a password file? The main goal is to not having to start a geth instance, use personal api for creating an account and then again restarting the geth instance with a modified genesis.json file – the idea is to consolidate these steps in a non-interactive fashion.
2. Any recommendations/suggestions on how this password file can be generated using standard key generation software like Hashicorp Vault and utilized for running the geth instance? On the same note, what are the steps to generate password, protect using Hashicorp Vault or GnuPG and then utilize the same password for creating a geth account?

3. Alternatively, if the geth instance were to be started with a genesis file without allocation of accounts across the nodes on the private net, would it matter if accounts were not part of the genesis file for the private test net?

Best Answer

You could use this python script. It has 4 commands and create a private blockchain in few seconds:

  • init: this command create an account and a genesis with ethers for this account
  • start: start the blockchain and mine on 1 thread.
  • stop: stop (usefull when you don't need your blockchain)
  • destroy: to reset and create a new blockchain

Have Fun

https://github.com/regispietra/CreatePrivateEthereum

If you have idea to improve it, contact us.