2

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?

  • What exactly is the problem here? Security of the file or non-interactivity? How much non-interactivity do you require? What OS? – techraf Jul 5 '16 at 7:13
  • The issue is around non-interactivity. I would like to automate the creation of a private test net. To this extent, I was trying to get a new account address, seed ether to account in the genesis file and run the geth instance. – skarred14 Jul 5 '16 at 8:20
  • You could generate the passwords and protect them with GnuPG for example, but you would need to update the question with your use case. Or you could integrate with Apple's Keychain, but that again would require more details. Or Hashicorp's Vault. – techraf Jul 5 '16 at 8:25
  • Edited the question - am looking for an execution, wherein geth instances need not have to be started/re-started/attached to multiple times in order to have a common genesis file across multiple nodes – skarred14 Jul 5 '16 at 18:17
2

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.

3

There is another method, writing a javascript (a javascript script ;-) ) that includes personal.newAccount(passwd) and loading it via geth --exec 'loadScript("/tmp/test.js")' attach

Of course you can preset your password, but it is not really recommended for Mainnet, only if you are 100% secure.

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.