2

I want to create a test blockchain to play around.
When I try test-rpc there are already ten accounts created but no funds - how can I generate funds? can I import a genesis.json?

My second approach is to use

geth init '/my-path/genesis.json' 

I generated some accounts with https://iancoleman.io/bip39/ and added some funds with alloc in genesis.json:

{
  "config": {
        "chainId": 0,
        "homesteadBlock": 0,
        "eip155Block": 0,
        "eip158Block": 0
    },
  "alloc": {
  "0xFf0333b3Cfa24652646eA24fe98a54f0f1001849": {"balance": "111111111"},
  "0xFEfaf15eEc2D3F06958043acA3aF3766745358aB": {"balance": "111111111"},
  "0xFf0333b3Cfa24652646eA24fe98a54f0f1001849": {"balance": "78111111111"},
  "0xb0A7C9Fa07Be78cBf2F3a5b1A87Cd87BBA72A1Ed": {"balance": "977111111111"},
  "0x4eD82D45102cB38cf8c7b4261675b2FEB577063e": {"balance": "324111111111"},
  "0x46347159a3497d3AC1948D44294268C1E3a3A321": {"balance": "2345234111111111"},
  "0x8a58Cc8EeACeFA52f6f70C4F116F57291438F2dB": {"balance": "224111111111"},
  "0x1a4Ec59De4d833e06dfA1700E8611D4B3a4B4EBd": {"balance": "2424111111111"},
  "0x124BC9eBd0447F5e594F871691415a212A5EcA63": {"balance": "2222244222222222"}
},
  "coinbase"   : "0x0000000000000000000000000000000000000000",
  "difficulty" : "0x20000",
  "extraData"  : "",
  "gasLimit"   : "0x2fefd8",
  "nonce"      : "0x000005678000042",
  "mixhash"    : "0x0000000000000000000000000000000000000000000000000000000000000000",
  "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
  "timestamp"  : "0x00"
}

The problem is I need to add this accounts with private keys manually to the geth "wallet".
What would be a good automatic solution for wallet creation within geth so I can immediately start to move ether around on my new test environment?

  • 1
    probably you can craete accounts in advance using geth --datadir "your_directory" account new – Prashant Prabhakar Singh Feb 23 '18 at 11:53
4

You can create the accounts using geth before you init the chain with the genesis block.

geth --datadir <DATADIR> account new

The keystores are stored to <DATADIR>/keystore

You would:

  1. create the accounts
  2. add the accounts to genesis.json
  3. init/start blockchain

If you need to restart the blockchain from scratch, you can keep the keystore folder in your <DATADIR>, so you don't have to recreate the account again.

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.