8

I setup a local testnet using geth following these instructions. I was able to mine my initial Ether and all was working. After deploying some contracts I quickly spent all the Ether I had. Now it seems I'm unable to mine any more Ether. How do you continue to fund your account with Ether on a private testnet?

Aren't blocks processed every so often regardless of the number of transactions? That doesn't seem to be happening on my test node.

Updated: Here's the output when I manually start the miner (note, account is unlocked)

>miner.start();
I0128 15:22:16.501677    8525 backend.go:584] Automatic pregeneration of ethash DAG ON (ethash dir: /Users/testgeth/.ethash)
I0128 15:22:16.501789    8525 backend.go:591] checking DAG (ethash dir: /Users/testgeth/.ethash)
I0128 15:22:16.501843    8525 miner.go:119] Starting mining operation (CPU=8 TOT=10)
true
> I0128 15:22:16.503824    8525 worker.go:570] commit new work on block 48 with 0 txs & 0 uncles. Took 1.893754ms
I0128 15:22:16.503953    8525 ethash.go:220] Generating DAG for epoch 0 (size 1073739904) (0000000000000000000000000000000000000000000000000000000000000000)
I0128 15:22:17.432934    8525 ethash.go:237] Done generating DAG for epoch 0, it took 928.992201ms

UPDATE: What seems to work is to send a transaction. Once geth reached the stopping point I mention above, I sent a transaction and the normal block processing began.

4
  • Yes, mining should continue regardless of the number of transactions. Show/link to the Geth output could give clues on why mining stopped...
    – eth
    Commented Jan 28, 2016 at 21:07
  • Thanks for the response. I added some output from the console above.
    – dbryson
    Commented Jan 28, 2016 at 21:27
  • There's no need to unlock the account, but make sure that eth.coinbase returns the address you want. Just fyi Commented Jan 28, 2016 at 23:39
  • If the answer helped you get your query solved, please consider marking it as correct answer my checking the tick icon below the voting icons.
    – niksmac
    Commented Apr 18, 2016 at 6:13

2 Answers 2

11

If you are on a private net/chain you actually don't need to mine to get ethers, but just to confirm transactions.

You can fund your account(s) by specifying the amount in wei you want that account to start with, in your genesis json file:

"alloc": {
    "<your account address e.g. 0xaaabd38c8f1a188a0b8bbf93bdca420cfdd760aa>": {
        "balance": "10000000000000000000"
    }
}

Another thing you can do if you still want to mine to get ethers is lower the difficulty, again in the genesis block, a value of "0x400" or `"0x200" will let you mine faster the first blocks. If your geth is stuck and doesn't mine anymore (on osx I found it common when you put the computer in sleep), simply kill it with Crtl-C and restart it.


To specify your genesis block you can pass these parameters to the geth command:

$ geth --genesis <genesis json file path> --datadir <some path to an empty folder> 

A sample genesis block is:

{
  "nonce": "0x000000000000002a",
  "timestamp": "0x0",
  "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
  "extraData": "0x0",
  "gasLimit": "0x8000000",
  "difficulty": "0x400",
  "mixhash":  "0x0000000000000000000000000000000000000000000000000000000000000000",
  "coinbase": "0x0000000000000000000000000000000000000000",
  "alloc": {
  }
}

You can find a more complete guide here

5
  • Thanks. I've tried this. In fact I also followed the guide you link to. I was able to mine the initial blocks just fine. After that the problem seems to be there's nothing happening - no blocks generated or transactions processed
    – dbryson
    Commented Jan 29, 2016 at 13:08
  • the genesis block option seems to be deprecated. only option now is to mine and get some gas I believe.
    – Aravind
    Commented Jul 13, 2016 at 6:53
  • 2
    no, from geth 1.5 you have to follow the new chain generation procedure wich it is to use geth --datadir <your datadir> init path/to/genesis.json after you created the accounts and wrote them in the genesis block, you don't want to use the --genesis anymore as these parameters are actually loaded from the datadir :)
    – makevoid
    Commented Aug 3, 2016 at 14:31
  • «more complete guide» link is offline, must be accessed via Web Archive.
    – lapo
    Commented Oct 18, 2016 at 13:00
  • @lapo as the link is offline now (and the guide was for geth and quite old) I want to point you to an updated guide using parity which is very advanced for dev-chains: medium.com/decentralized-capital/… - for devchains parity is ideal because it has the instant-(local)-mining which should be the fastest method to bootstrap a dev node to try out ethereum (other than waiting for the main chain and getting some ethers, which can be quick too if you have disk space and already have experience with cryptocurrencies)
    – makevoid
    Commented Oct 19, 2016 at 19:20
0

Not sure whether it is possible to add ether to an existing account without mining. If you want to add ether balance for accounts a the beginning, following article explains the process step by step.

Ethereum : How to setup a local test node with initial ether balance using geth

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.